From 51749eab935b7f1396f7ed50a64cd06ebd3ea3bb Mon Sep 17 00:00:00 2001 From: Robert Sayakhov Date: Thu, 20 Feb 2020 16:51:00 +0300 Subject: [PATCH] XNET-40 | Validation of private key (#7) * feat: added valiadtion of private key * chore: version update --- package.json | 2 +- src/views/SignTX.vue | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 628676e..f212613 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-ots", - "version": "0.4.3", + "version": "0.4.4", "private": true, "scripts": { "serve": "vue-cli-service serve", diff --git a/src/views/SignTX.vue b/src/views/SignTX.vue index 983924a..bff1ae8 100644 --- a/src/views/SignTX.vue +++ b/src/views/SignTX.vue @@ -208,10 +208,19 @@ export default { this.isZipFile = false }, onSignAndDownload () { + const _keyPattern = (value) => { + const pattern = /^[A-Fa-f0-9]{64}$/ + if (!pattern.test(value)) return false + return true + } if (!this.sign.privateKey.length) { this.$message.error('Private key can\'t be empty!') return } + if (!_keyPattern(this.sign.privateKey)) { + this.$message.error('Invalid private key!') + return + } if (this.isZipFile) { this.onSignZip() .then(txs => this.onSaveTransactions(txs))