mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-12 18:44:59 +01:00
wallet: Have IsSpent take a min_conf
A min_conf parameter is added to IsSpent so that it can set a confirmation threshold for whether something is considered spent.
This commit is contained in:
parent
bc1c12cb29
commit
710a59dcc4
2 changed files with 10 additions and 4 deletions
|
@ -762,7 +762,7 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
|
|||
* Outpoint is spent if any non-conflicted transaction
|
||||
* spends it:
|
||||
*/
|
||||
bool CWallet::IsSpent(const COutPoint& outpoint) const
|
||||
bool CWallet::IsSpent(const COutPoint& outpoint, int min_depth) const
|
||||
{
|
||||
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
|
||||
range = mapTxSpends.equal_range(outpoint);
|
||||
|
@ -772,8 +772,14 @@ bool CWallet::IsSpent(const COutPoint& outpoint) const
|
|||
const auto mit = mapWallet.find(wtxid);
|
||||
if (mit != mapWallet.end()) {
|
||||
const auto& wtx = mit->second;
|
||||
if (!wtx.isAbandoned() && !wtx.isBlockConflicted() && !wtx.isMempoolConflicted())
|
||||
return true; // Spent
|
||||
int depth = GetTxDepthInMainChain(wtx);
|
||||
if (depth == 0) {
|
||||
if (min_depth == 0 && !wtx.isAbandoned() && !wtx.isMempoolConflicted()) {
|
||||
return true;
|
||||
}
|
||||
} else if (depth >= min_depth) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -548,7 +548,7 @@ public:
|
|||
//! check whether we support the named feature
|
||||
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return IsFeatureSupported(nWalletVersion, wf); }
|
||||
|
||||
bool IsSpent(const COutPoint& outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
bool IsSpent(const COutPoint& outpoint, int min_depth = 0) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
|
||||
// Whether this or any known scriptPubKey with the same single key has been spent.
|
||||
bool IsSpentKey(const CScript& scriptPubKey) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
|
|
Loading…
Add table
Reference in a new issue