mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
wallet: replace GetTxSpendSize with CalculateMaximumSignedInputSize
This commit is contained in:
@@ -58,7 +58,8 @@ static void CoinSelection(benchmark::Bench& bench)
|
||||
// Create coins
|
||||
std::vector<COutput> coins;
|
||||
for (const auto& wtx : wtxs) {
|
||||
coins.emplace_back(COutPoint(wtx->GetHash(), 0), wtx->tx->vout.at(0), /*depth=*/6 * 24, GetTxSpendSize(wallet, *wtx, 0), /*spendable=*/true, /*solvable=*/true, /*safe=*/true, wtx->GetTxTime(), /*from_me=*/true, /*fees=*/ 0);
|
||||
const auto txout = wtx->tx->vout.at(0);
|
||||
coins.emplace_back(COutPoint(wtx->GetHash(), 0), txout, /*depth=*/6 * 24, CalculateMaximumSignedInputSize(txout, &wallet, false), /*spendable=*/true, /*solvable=*/true, /*safe=*/true, wtx->GetTxTime(), /*from_me=*/true, /*fees=*/ 0);
|
||||
}
|
||||
|
||||
const CoinEligibilityFilter filter_standard(1, 6, 0);
|
||||
|
||||
@@ -27,11 +27,6 @@ using interfaces::FoundBlock;
|
||||
namespace wallet {
|
||||
static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100};
|
||||
|
||||
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig)
|
||||
{
|
||||
return CalculateMaximumSignedInputSize(wtx.tx->vout[out], &wallet, use_max_sig);
|
||||
}
|
||||
|
||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig)
|
||||
{
|
||||
CMutableTransaction txn;
|
||||
@@ -198,7 +193,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
|
||||
// Filter by spendable outputs only
|
||||
if (!spendable && only_spendable) continue;
|
||||
|
||||
int input_bytes = GetTxSpendSize(wallet, wtx, i, (coinControl && coinControl->fAllowWatchOnly));
|
||||
int input_bytes = CalculateMaximumSignedInputSize(output, provider.get(), coinControl && coinControl->fAllowWatchOnly);
|
||||
result.coins.emplace_back(outpoint, output, nDepth, input_bytes, spendable, solvable, safeTx, wtx.GetTxTime(), tx_from_me, feerate);
|
||||
result.total_amount += output.nValue;
|
||||
|
||||
@@ -289,8 +284,9 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet)
|
||||
) {
|
||||
CTxDestination address;
|
||||
if (ExtractDestination(FindNonChangeParentOutput(wallet, *wtx.tx, output.n).scriptPubKey, address)) {
|
||||
const auto out = wtx.tx->vout.at(output.n);
|
||||
result[address].emplace_back(
|
||||
COutPoint(wtx.GetHash(), output.n), wtx.tx->vout.at(output.n), depth, GetTxSpendSize(wallet, wtx, output.n), /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ false, wtx.GetTxTime(), CachedTxIsFromMe(wallet, wtx, ISMINE_ALL));
|
||||
COutPoint(wtx.GetHash(), output.n), out, depth, CalculateMaximumSignedInputSize(out, &wallet, false), /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ false, wtx.GetTxTime(), CachedTxIsFromMe(wallet, wtx, ISMINE_ALL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -447,7 +443,7 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
|
||||
if (ptr_wtx->tx->vout.size() <= outpoint.n) {
|
||||
return std::nullopt;
|
||||
}
|
||||
input_bytes = GetTxSpendSize(wallet, *ptr_wtx, outpoint.n, false);
|
||||
input_bytes = CalculateMaximumSignedInputSize(ptr_wtx->tx->vout[outpoint.n], &wallet, false);
|
||||
txout = ptr_wtx->tx->vout.at(outpoint.n);
|
||||
} else {
|
||||
// The input is external. We did not find the tx in mapWallet.
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace wallet {
|
||||
/** Get the marginal bytes if spending the specified output from this transaction.
|
||||
* use_max_sig indicates whether to use the maximum sized, 72 byte signature when calculating the
|
||||
* size of the input spend. This should only be set when watch-only outputs are allowed */
|
||||
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig = false);
|
||||
|
||||
//Get the marginal bytes of spending the specified output
|
||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* pwallet, bool use_max_sig = false);
|
||||
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* pwallet, bool use_max_sig = false);
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@ static void add_coin(std::vector<COutput>& coins, CWallet& wallet, const CAmount
|
||||
auto ret = wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), std::forward_as_tuple(MakeTransactionRef(std::move(tx)), TxStateInactive{}));
|
||||
assert(ret.second);
|
||||
CWalletTx& wtx = (*ret.first).second;
|
||||
coins.emplace_back(COutPoint(wtx.GetHash(), nInput), wtx.tx->vout.at(nInput), nAge, GetTxSpendSize(wallet, wtx, nInput), /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ true, wtx.GetTxTime(), fIsFromMe, feerate);
|
||||
const auto txout = wtx.tx->vout.at(nInput);
|
||||
coins.emplace_back(COutPoint(wtx.GetHash(), nInput), txout, nAge, CalculateMaximumSignedInputSize(txout, &wallet, false), /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ true, wtx.GetTxTime(), fIsFromMe, feerate);
|
||||
}
|
||||
|
||||
/** Check if SelectionResult a is equivalent to SelectionResult b.
|
||||
|
||||
Reference in New Issue
Block a user