From 4ffc8e27e1384cbd70ad6036eb4a86e74202571d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 10 Jun 2015 00:03:08 -0700 Subject: [PATCH] Also remove pay-2-pubkey from watch when adding a priv key --- src/script/standard.cpp | 5 +++++ src/script/standard.h | 1 + src/wallet/wallet.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index e94dfb38b..a2bc5c576 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -306,6 +306,11 @@ CScript GetScriptForDestination(const CTxDestination& dest) return script; } +CScript GetScriptForRawPubKey(const CPubKey& pubKey) +{ + return CScript() << std::vector(pubKey.begin(), pubKey.end()) << OP_CHECKSIG; +} + CScript GetScriptForMultisig(int nRequired, const std::vector& keys) { CScript script; diff --git a/src/script/standard.h b/src/script/standard.h index b3db522ba..037b22851 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -94,6 +94,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector& addressRet, int& nRequiredRet); CScript GetScriptForDestination(const CTxDestination& dest); +CScript GetScriptForRawPubKey(const CPubKey& pubkey); CScript GetScriptForMultisig(int nRequired, const std::vector& keys); // insightexplorer diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 718d389ca..1d20194a6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -260,6 +260,9 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey) // check if we need to remove from watch-only CScript script; script = GetScriptForDestination(pubkey.GetID()); + if (HaveWatchOnly(script)) + RemoveWatchOnly(script); + script = GetScriptForRawPubKey(pubkey); if (HaveWatchOnly(script)) RemoveWatchOnly(script);