Skip to content

Commit f2d00bf

Browse files
committed
wallet: Add CWallet::IsMine(COutPoint)
It is useful to have an IsMine function that can take an outpoint.
1 parent 64f7a19 commit f2d00bf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,19 @@ bool CWallet::IsMine(const CTransaction& tx) const
14211421
return false;
14221422
}
14231423

1424+
isminetype CWallet::IsMine(const COutPoint& outpoint) const
1425+
{
1426+
AssertLockHeld(cs_wallet);
1427+
auto wtx = GetWalletTx(outpoint.hash);
1428+
if (!wtx) {
1429+
return ISMINE_NO;
1430+
}
1431+
if (outpoint.n >= wtx->tx->vout.size()) {
1432+
return ISMINE_NO;
1433+
}
1434+
return IsMine(wtx->tx->vout[outpoint.n]);
1435+
}
1436+
14241437
bool CWallet::IsFromMe(const CTransaction& tx) const
14251438
{
14261439
return (GetDebit(tx, ISMINE_ALL) > 0);

src/wallet/wallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
684684
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
685685
isminetype IsMine(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
686686
bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
687+
isminetype IsMine(const COutPoint& outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
687688
/** should probably be renamed to IsRelevantToMe */
688689
bool IsFromMe(const CTransaction& tx) const;
689690
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;

0 commit comments

Comments
 (0)