aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-07-26 21:05:11 +0200
committerCozz Lovan <cozzlovan@yahoo.com>2014-10-03 04:29:51 +0200
commitccca27a788fe1ae13661308243c20a1d7a3d0074 (patch)
treeb862f0f1e0fe98fdd1957cc2236076fef899cc50 /src/wallet.cpp
parent29f96e8bc652cb14c6fdefe5279ee983054faa2a (diff)
downloadbitcoin-ccca27a788fe1ae13661308243c20a1d7a3d0074.tar.xz
[Wallet] Watch-only fixes
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index b20b0007ce..1653084495 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -87,6 +87,13 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
AssertLockHeld(cs_wallet); // mapKeyMetadata
if (!CCryptoKeyStore::AddKeyPubKey(secret, pubkey))
return false;
+
+ // check if we need to remove from watch-only
+ CScript script;
+ script = GetScriptForDestination(pubkey.GetID());
+ if (HaveWatchOnly(script))
+ RemoveWatchOnly(script);
+
if (!fFileBacked)
return true;
if (!IsCrypted()) {
@@ -169,6 +176,20 @@ bool CWallet::AddWatchOnly(const CScript &dest)
return CWalletDB(strWalletFile).WriteWatchOnly(dest);
}
+bool CWallet::RemoveWatchOnly(const CScript &dest)
+{
+ AssertLockHeld(cs_wallet);
+ if (!CCryptoKeyStore::RemoveWatchOnly(dest))
+ return false;
+ if (!HaveWatchOnly())
+ NotifyWatchonlyChanged(false);
+ if (fFileBacked)
+ if (!CWalletDB(strWalletFile).EraseWatchOnly(dest))
+ return false;
+
+ return true;
+}
+
bool CWallet::LoadWatchOnly(const CScript &dest)
{
return CCryptoKeyStore::AddWatchOnly(dest);