diff options
author | ishaanam <ishaana.misra@gmail.com> | 2023-12-09 23:05:15 -0500 |
---|---|---|
committer | ishaanam <ishaana.misra@gmail.com> | 2024-02-10 16:38:37 -0500 |
commit | 36757941a05b65c2b61a83820afdf5effd8fc9a2 (patch) | |
tree | 2491b5d08e68762a134ecec1515cc0462326af3a /src | |
parent | 544131f3fba9ea07fee29f9d3ee0116cd5d8a5b2 (diff) | |
download | bitcoin-36757941a05b65c2b61a83820afdf5effd8fc9a2.tar.xz |
wallet, rpc: implement ancestor aware funding for sendall
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpc/spend.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 0a43293b22..1474c4ef4e 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -1467,10 +1467,18 @@ RPCHelpMan sendall() } } + std::vector<COutPoint> outpoints_spent; + outpoints_spent.reserve(rawTx.vin.size()); + + for (const CTxIn& tx_in : rawTx.vin) { + outpoints_spent.push_back(tx_in.prevout); + } + // estimate final size of tx const TxSize tx_size{CalculateMaximumSignedTxSize(CTransaction(rawTx), pwallet.get())}; const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)}; - const CAmount effective_value{total_input_value - fee_from_size}; + const std::optional<CAmount> total_bump_fees{pwallet->chain().calculateCombinedBumpFee(outpoints_spent, fee_rate)}; + CAmount effective_value = total_input_value - fee_from_size - total_bump_fees.value_or(0); if (fee_from_size > pwallet->m_default_max_tx_fee) { throw JSONRPCError(RPC_WALLET_ERROR, TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED).original); |