mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-07 21:28:40 +02:00
refactor: use GetWalletTx in SelectCoins instead of access mapWallet
This commit is contained in:
@@ -441,15 +441,14 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
|
|||||||
for (const COutPoint& outpoint : vPresetInputs) {
|
for (const COutPoint& outpoint : vPresetInputs) {
|
||||||
int input_bytes = -1;
|
int input_bytes = -1;
|
||||||
CTxOut txout;
|
CTxOut txout;
|
||||||
std::map<uint256, CWalletTx>::const_iterator it = wallet.mapWallet.find(outpoint.hash);
|
auto ptr_wtx = wallet.GetWalletTx(outpoint.hash);
|
||||||
if (it != wallet.mapWallet.end()) {
|
if (ptr_wtx) {
|
||||||
const CWalletTx& wtx = it->second;
|
|
||||||
// Clearly invalid input, fail
|
// Clearly invalid input, fail
|
||||||
if (wtx.tx->vout.size() <= outpoint.n) {
|
if (ptr_wtx->tx->vout.size() <= outpoint.n) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
input_bytes = GetTxSpendSize(wallet, wtx, outpoint.n, false);
|
input_bytes = GetTxSpendSize(wallet, *ptr_wtx, outpoint.n, false);
|
||||||
txout = wtx.tx->vout.at(outpoint.n);
|
txout = ptr_wtx->tx->vout.at(outpoint.n);
|
||||||
} else {
|
} else {
|
||||||
// The input is external. We did not find the tx in mapWallet.
|
// The input is external. We did not find the tx in mapWallet.
|
||||||
if (!coin_control.GetExternalOutput(outpoint, txout)) {
|
if (!coin_control.GetExternalOutput(outpoint, txout)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user