aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpc/spend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/rpc/spend.cpp')
-rw-r--r--src/wallet/rpc/spend.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 86c5492e01..169f72c406 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -1295,7 +1295,7 @@ RPCHelpMan sendall()
{
return RPCHelpMan{"sendall",
"EXPERIMENTAL warning: this call may be changed in future releases.\n"
- "\nSpend the value of all (or specific) confirmed UTXOs in the wallet to one or more recipients.\n"
+ "\nSpend the value of all (or specific) confirmed UTXOs and unconfirmed change in the wallet to one or more recipients.\n"
"Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the avoid_reuse wallet flag.\n"
"If your wallet contains many small inputs, either because it received tiny payments or as a result of accumulating change, consider using `send_max` to exclude inputs that are worth less than the fees needed to spend them.\n",
{
@@ -1470,10 +1470,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);