From be7b97abb3b758a59a8a6dcde51cec38fe85ec1c Mon Sep 17 00:00:00 2001 From: pernas Date: Fri, 5 Feb 2016 11:08:06 -0500 Subject: [PATCH] feat(addkey): now add to watch only import if non-existent. --- src/blockchain-wallet.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/blockchain-wallet.js b/src/blockchain-wallet.js index 4651d66ef..f874fe1ce 100644 --- a/src/blockchain-wallet.js +++ b/src/blockchain-wallet.js @@ -475,7 +475,17 @@ Wallet.prototype.addKeyToLegacyAddress = function (privateKey, addr, secPass, bi var modifyAddress = function (newKey) { var watchOnlyKey = this._addresses[addr]; if (newKey.address !== watchOnlyKey.address) { - throw 'addressDoesNotMatchWithTheKey' + if (!this.containsLegacyAddress(newKey.address)) { + console.log(newKey) + return this.importLegacyAddress(privateKey, null, secPass, bipPass); + } else { + if (this.key(newKey.address).isWatchOnly) { + watchOnlyKey = this._addresses[newKey.address]; + } else { + throw 'privateKeyOfAnotherNonWatchOnlyAddress' + } + } + } watchOnlyKey._priv = newKey._priv; if (this.isDoubleEncrypted) {