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