@@ -362,12 +362,6 @@ void CWallet::LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata&
362
362
m_script_metadata[script_id] = meta;
363
363
}
364
364
365
- // Writes a keymetadata for a public key. overwrite specifies whether to overwrite an existing metadata for that key if there exists one.
366
- bool CWallet::WriteKeyMetadata (const CKeyMetadata& meta, const CPubKey& pubkey, const bool overwrite)
367
- {
368
- return WalletBatch (*database).WriteKeyMetadata (meta, pubkey, overwrite);
369
- }
370
-
371
365
void CWallet::UpgradeKeyMetadata ()
372
366
{
373
367
AssertLockHeld (cs_wallet);
@@ -432,10 +426,16 @@ void CWallet::UpdateTimeFirstKey(int64_t nCreateTime)
432
426
}
433
427
434
428
bool CWallet::AddCScript (const CScript& redeemScript)
429
+ {
430
+ WalletBatch batch (*database);
431
+ return AddCScriptWithDB (batch, redeemScript);
432
+ }
433
+
434
+ bool CWallet::AddCScriptWithDB (WalletBatch& batch, const CScript& redeemScript)
435
435
{
436
436
if (!CCryptoKeyStore::AddCScript (redeemScript))
437
437
return false ;
438
- if (WalletBatch (*database) .WriteCScript (Hash160 (redeemScript), redeemScript)) {
438
+ if (batch .WriteCScript (Hash160 (redeemScript), redeemScript)) {
439
439
UnsetWalletFlag (WALLET_FLAG_BLANK_WALLET);
440
440
return true ;
441
441
}
@@ -457,20 +457,32 @@ bool CWallet::LoadCScript(const CScript& redeemScript)
457
457
return CCryptoKeyStore::AddCScript (redeemScript);
458
458
}
459
459
460
- bool CWallet::AddWatchOnly ( const CScript& dest)
460
+ bool CWallet::AddWatchOnlyWithDB (WalletBatch &batch, const CScript& dest)
461
461
{
462
462
if (!CCryptoKeyStore::AddWatchOnly (dest))
463
463
return false ;
464
464
const CKeyMetadata& meta = m_script_metadata[CScriptID (dest)];
465
465
UpdateTimeFirstKey (meta.nCreateTime );
466
466
NotifyWatchonlyChanged (true );
467
- if (WalletBatch (*database) .WriteWatchOnly (dest, meta)) {
467
+ if (batch .WriteWatchOnly (dest, meta)) {
468
468
UnsetWalletFlag (WALLET_FLAG_BLANK_WALLET);
469
469
return true ;
470
470
}
471
471
return false ;
472
472
}
473
473
474
+ bool CWallet::AddWatchOnlyWithDB (WalletBatch &batch, const CScript& dest, int64_t create_time)
475
+ {
476
+ m_script_metadata[CScriptID (dest)].nCreateTime = create_time;
477
+ return AddWatchOnlyWithDB (batch, dest);
478
+ }
479
+
480
+ bool CWallet::AddWatchOnly (const CScript& dest)
481
+ {
482
+ WalletBatch batch (*database);
483
+ return AddWatchOnlyWithDB (batch, dest);
484
+ }
485
+
474
486
bool CWallet::AddWatchOnly (const CScript& dest, int64_t nCreateTime)
475
487
{
476
488
m_script_metadata[CScriptID (dest)].nCreateTime = nCreateTime;
@@ -4469,12 +4481,12 @@ bool CWallet::GetKeyOrigin(const CKeyID& keyID, KeyOriginInfo& info) const
4469
4481
return true ;
4470
4482
}
4471
4483
4472
- bool CWallet::AddKeyOrigin ( const CPubKey& pubkey, const KeyOriginInfo& info)
4484
+ bool CWallet::AddKeyOriginWithDB (WalletBatch& batch, const CPubKey& pubkey, const KeyOriginInfo& info)
4473
4485
{
4474
4486
LOCK (cs_wallet);
4475
4487
std::copy (info.fingerprint , info.fingerprint + 4 , mapKeyMetadata[pubkey.GetID ()].key_origin .fingerprint );
4476
4488
mapKeyMetadata[pubkey.GetID ()].key_origin .path = info.path ;
4477
4489
mapKeyMetadata[pubkey.GetID ()].has_key_origin = true ;
4478
4490
mapKeyMetadata[pubkey.GetID ()].hdKeypath = WriteHDKeypath (info.path );
4479
- return WriteKeyMetadata (mapKeyMetadata[pubkey.GetID ()], pubkey, true );
4491
+ return batch. WriteKeyMetadata (mapKeyMetadata[pubkey.GetID ()], pubkey, true );
4480
4492
}
0 commit comments