@@ -2611,10 +2611,16 @@ util::Result<void> CWallet::DisplayAddress(const CTxDestination& dest)
2611
2611
return util::Error{_ (" There is no ScriptPubKeyManager for this address" )};
2612
2612
}
2613
2613
2614
+ void CWallet::LoadLockedCoin (const COutPoint& coin, bool persistent)
2615
+ {
2616
+ AssertLockHeld (cs_wallet);
2617
+ m_locked_coins.emplace (coin, persistent);
2618
+ }
2619
+
2614
2620
bool CWallet::LockCoin (const COutPoint& output, WalletBatch* batch)
2615
2621
{
2616
2622
AssertLockHeld (cs_wallet);
2617
- setLockedCoins. insert (output);
2623
+ LoadLockedCoin (output, batch != nullptr );
2618
2624
if (batch) {
2619
2625
return batch->WriteLockedUTXO (output);
2620
2626
}
@@ -2624,7 +2630,7 @@ bool CWallet::LockCoin(const COutPoint& output, WalletBatch* batch)
2624
2630
bool CWallet::UnlockCoin (const COutPoint& output, WalletBatch* batch)
2625
2631
{
2626
2632
AssertLockHeld (cs_wallet);
2627
- bool was_locked = setLockedCoins .erase (output);
2633
+ bool was_locked = m_locked_coins .erase (output);
2628
2634
if (batch && was_locked) {
2629
2635
return batch->EraseLockedUTXO (output);
2630
2636
}
@@ -2636,26 +2642,24 @@ bool CWallet::UnlockAllCoins()
2636
2642
AssertLockHeld (cs_wallet);
2637
2643
bool success = true ;
2638
2644
WalletBatch batch (GetDatabase ());
2639
- for (auto it = setLockedCoins. begin (); it != setLockedCoins. end (); ++it ) {
2640
- success &= batch.EraseLockedUTXO (*it );
2645
+ for (const auto & [coin, _] : m_locked_coins ) {
2646
+ success &= batch.EraseLockedUTXO (coin );
2641
2647
}
2642
- setLockedCoins .clear ();
2648
+ m_locked_coins .clear ();
2643
2649
return success;
2644
2650
}
2645
2651
2646
2652
bool CWallet::IsLockedCoin (const COutPoint& output) const
2647
2653
{
2648
2654
AssertLockHeld (cs_wallet);
2649
- return setLockedCoins .count (output) > 0 ;
2655
+ return m_locked_coins .count (output) > 0 ;
2650
2656
}
2651
2657
2652
2658
void CWallet::ListLockedCoins (std::vector<COutPoint>& vOutpts) const
2653
2659
{
2654
2660
AssertLockHeld (cs_wallet);
2655
- for (std::set<COutPoint>::iterator it = setLockedCoins.begin ();
2656
- it != setLockedCoins.end (); it++) {
2657
- COutPoint outpt = (*it);
2658
- vOutpts.push_back (outpt);
2661
+ for (const auto & [coin, _] : m_locked_coins) {
2662
+ vOutpts.push_back (coin);
2659
2663
}
2660
2664
}
2661
2665
0 commit comments