Also remove pay-2-pubkey from watch when adding a priv key

This commit is contained in:
Matt Corallo 2015-06-10 00:03:08 -07:00 committed by Jack Grigg
parent ea4ee8a222
commit 4ffc8e27e1
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
3 changed files with 9 additions and 0 deletions

View File

@ -306,6 +306,11 @@ CScript GetScriptForDestination(const CTxDestination& dest)
return script;
}
CScript GetScriptForRawPubKey(const CPubKey& pubKey)
{
return CScript() << std::vector<unsigned char>(pubKey.begin(), pubKey.end()) << OP_CHECKSIG;
}
CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
{
CScript script;

View File

@ -94,6 +94,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
CScript GetScriptForDestination(const CTxDestination& dest);
CScript GetScriptForRawPubKey(const CPubKey& pubkey);
CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
// insightexplorer

View File

@ -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);