Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 774 Lines • ▼ Show 20 Lines | if (ExtractDestination(srctx->tx->vout[n].scriptPubKey, dst)) { | ||||
AddDestData(batch, dst, "used", "p"); | AddDestData(batch, dst, "used", "p"); | ||||
} else if (!used && GetDestData(dst, "used", nullptr)) { | } else if (!used && GetDestData(dst, "used", nullptr)) { | ||||
EraseDestData(batch, dst, "used"); | EraseDestData(batch, dst, "used"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
bool CWallet::IsUsedDestination(const CTxDestination &dst) const { | |||||
LOCK(cs_wallet); | |||||
return IsMine(dst) && GetDestData(dst, "used", nullptr); | |||||
} | |||||
bool CWallet::IsUsedDestination(const TxId &txid, unsigned int n) const { | bool CWallet::IsUsedDestination(const TxId &txid, unsigned int n) const { | ||||
AssertLockHeld(cs_wallet); | |||||
CTxDestination dst; | CTxDestination dst; | ||||
const CWalletTx *srctx = GetWalletTx(txid); | const CWalletTx *srctx = GetWalletTx(txid); | ||||
return srctx && ExtractDestination(srctx->tx->vout[n].scriptPubKey, dst) && | if (srctx) { | ||||
IsUsedDestination(dst); | assert(srctx->tx->vout.size() > n); | ||||
LegacyScriptPubKeyMan *spk_man = GetLegacyScriptPubKeyMan(); | |||||
// When descriptor wallets arrive, these additional checks are | |||||
// likely superfluous and can be optimized out | |||||
assert(spk_man != nullptr); | |||||
for (const auto &keyid : | |||||
GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) { | |||||
PKHash pkh_dest(keyid); | |||||
if (GetDestData(pkh_dest, "used", nullptr)) { | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
return false; | |||||
} | } | ||||
bool CWallet::AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose) { | bool CWallet::AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose) { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
WalletBatch batch(*database, "r+", fFlushOnClose); | WalletBatch batch(*database, "r+", fFlushOnClose); | ||||
const TxId &txid = wtxIn.GetId(); | const TxId &txid = wtxIn.GetId(); | ||||
▲ Show 20 Lines • Show All 3,686 Lines • Show Last 20 Lines |