Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CWallet::IsUsedDestination(const TxId &txid, unsigned int n) const { | bool CWallet::IsUsedDestination(const TxId &txid, unsigned int n) const { | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
CTxDestination dst; | CTxDestination dst; | ||||
const CWalletTx *srctx = GetWalletTx(txid); | const CWalletTx *srctx = GetWalletTx(txid); | ||||
if (srctx) { | if (srctx) { | ||||
assert(srctx->tx->vout.size() > n); | assert(srctx->tx->vout.size() > n); | ||||
CTxDestination dest; | |||||
if (!ExtractDestination(srctx->tx->vout[n].scriptPubKey, dest)) { | |||||
return false; | |||||
} | |||||
if (GetDestData(dest, "used", nullptr)) { | |||||
return true; | |||||
} | |||||
if (IsLegacy()) { | |||||
LegacyScriptPubKeyMan *spk_man = GetLegacyScriptPubKeyMan(); | LegacyScriptPubKeyMan *spk_man = GetLegacyScriptPubKeyMan(); | ||||
// When descriptor wallets arrive, these additional checks are | |||||
// likely superfluous and can be optimized out | |||||
assert(spk_man != nullptr); | assert(spk_man != nullptr); | ||||
for (const auto &keyid : | for (const auto &keyid : | ||||
GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) { | GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) { | ||||
PKHash pkh_dest(keyid); | PKHash pkh_dest(keyid); | ||||
if (GetDestData(pkh_dest, "used", nullptr)) { | if (GetDestData(pkh_dest, "used", nullptr)) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
return false; | 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); | ||||
▲ Show 20 Lines • Show All 4,100 Lines • Show Last 20 Lines |