wallet: IsLockedCoin, 'COutPoint' arg instead of (hash, index)

This commit is contained in:
furszy 2022-04-27 10:37:50 -03:00
parent 9472ca0a65
commit 91902b7720
No known key found for this signature in database
GPG Key ID: 5DD23CCC686AA623
5 changed files with 6 additions and 8 deletions

View File

@ -245,7 +245,7 @@ public:
bool isLockedCoin(const COutPoint& output) override bool isLockedCoin(const COutPoint& output) override
{ {
LOCK(m_wallet->cs_wallet); LOCK(m_wallet->cs_wallet);
return m_wallet->IsLockedCoin(output.hash, output.n); return m_wallet->IsLockedCoin(output);
} }
void listLockedCoins(std::vector<COutPoint>& outputs) override void listLockedCoins(std::vector<COutPoint>& outputs) override
{ {

View File

@ -345,7 +345,7 @@ RPCHelpMan lockunspent()
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected unspent output"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected unspent output");
} }
const bool is_locked = pwallet->IsLockedCoin(outpt.hash, outpt.n); const bool is_locked = pwallet->IsLockedCoin(outpt);
if (fUnlock && !is_locked) { if (fUnlock && !is_locked) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected locked output"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected locked output");

View File

@ -179,7 +179,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(outpoint)) if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(outpoint))
continue; continue;
if (wallet.IsLockedCoin(wtxid, i)) if (wallet.IsLockedCoin(outpoint))
continue; continue;
if (wallet.IsSpent(wtxid, i)) if (wallet.IsSpent(wtxid, i))

View File

@ -2449,12 +2449,10 @@ bool CWallet::UnlockAllCoins()
return success; return success;
} }
bool CWallet::IsLockedCoin(uint256 hash, unsigned int n) const bool CWallet::IsLockedCoin(const COutPoint& output) const
{ {
AssertLockHeld(cs_wallet); AssertLockHeld(cs_wallet);
COutPoint outpt(hash, n); return setLockedCoins.count(output) > 0;
return (setLockedCoins.count(outpt) > 0);
} }
void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const

View File

@ -450,7 +450,7 @@ public:
/** Display address on an external signer. Returns false if external signer support is not compiled */ /** Display address on an external signer. Returns false if external signer support is not compiled */
bool DisplayAddress(const CTxDestination& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool DisplayAddress(const CTxDestination& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool IsLockedCoin(const COutPoint& output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool LockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool LockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool UnlockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool UnlockCoin(const COutPoint& output, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);