@@ -320,7 +320,7 @@ bool CWallet::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& secret, const C
320
320
secret.GetPrivKey (),
321
321
mapKeyMetadata[pubkey.GetID ()]);
322
322
}
323
- UnsetWalletFlag ( WALLET_FLAG_BLANK_WALLET);
323
+ UnsetWalletFlagWithDB (batch, WALLET_FLAG_BLANK_WALLET);
324
324
return true ;
325
325
}
326
326
@@ -431,7 +431,7 @@ bool CWallet::AddCScriptWithDB(WalletBatch& batch, const CScript& redeemScript)
431
431
if (!CCryptoKeyStore::AddCScript (redeemScript))
432
432
return false ;
433
433
if (batch.WriteCScript (Hash160 (redeemScript), redeemScript)) {
434
- UnsetWalletFlag ( WALLET_FLAG_BLANK_WALLET);
434
+ UnsetWalletFlagWithDB (batch, WALLET_FLAG_BLANK_WALLET);
435
435
return true ;
436
436
}
437
437
return false ;
@@ -460,7 +460,7 @@ bool CWallet::AddWatchOnlyWithDB(WalletBatch &batch, const CScript& dest)
460
460
UpdateTimeFirstKey (meta.nCreateTime );
461
461
NotifyWatchonlyChanged (true );
462
462
if (batch.WriteWatchOnly (dest, meta)) {
463
- UnsetWalletFlag ( WALLET_FLAG_BLANK_WALLET);
463
+ UnsetWalletFlagWithDB (batch, WALLET_FLAG_BLANK_WALLET);
464
464
return true ;
465
465
}
466
466
return false ;
@@ -1561,10 +1561,16 @@ void CWallet::SetWalletFlag(uint64_t flags)
1561
1561
}
1562
1562
1563
1563
void CWallet::UnsetWalletFlag (uint64_t flag)
1564
+ {
1565
+ WalletBatch batch (*database);
1566
+ UnsetWalletFlagWithDB (batch, flag);
1567
+ }
1568
+
1569
+ void CWallet::UnsetWalletFlagWithDB (WalletBatch& batch, uint64_t flag)
1564
1570
{
1565
1571
LOCK (cs_wallet);
1566
1572
m_wallet_flags &= ~flag;
1567
- if (!WalletBatch (*database) .WriteWalletFlags (m_wallet_flags))
1573
+ if (!batch .WriteWalletFlags (m_wallet_flags))
1568
1574
throw std::runtime_error (std::string (__func__) + " : writing wallet flags failed" );
1569
1575
}
1570
1576
0 commit comments