mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
wallet: clean AllInputsMine code, use InputIsMine internally
Instead of duplicate the exact same code twice.
This commit is contained in:
parent
bf310b0e8c
commit
47ea70fbb8
@ -22,20 +22,8 @@ isminetype InputIsMine(const CWallet& wallet, const CTxIn& txin)
|
|||||||
bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter)
|
bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter)
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
|
for (const CTxIn& txin : tx.vin) {
|
||||||
for (const CTxIn& txin : tx.vin)
|
if (!(InputIsMine(wallet, txin) & filter)) return false;
|
||||||
{
|
|
||||||
auto mi = wallet.mapWallet.find(txin.prevout.hash);
|
|
||||||
if (mi == wallet.mapWallet.end())
|
|
||||||
return false; // any unknown inputs can't be from us
|
|
||||||
|
|
||||||
const CWalletTx& prev = (*mi).second;
|
|
||||||
|
|
||||||
if (txin.prevout.n >= prev.tx->vout.size())
|
|
||||||
return false; // invalid input!
|
|
||||||
|
|
||||||
if (!(wallet.IsMine(prev.tx->vout[txin.prevout.n]) & filter))
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user