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