Skip to content

Commit 3675794

Browse files
committed
wallet, rpc: implement ancestor aware funding for sendall
1 parent 544131f commit 3675794

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,10 +1467,18 @@ RPCHelpMan sendall()
14671467
}
14681468
}
14691469

1470+
std::vector<COutPoint> outpoints_spent;
1471+
outpoints_spent.reserve(rawTx.vin.size());
1472+
1473+
for (const CTxIn& tx_in : rawTx.vin) {
1474+
outpoints_spent.push_back(tx_in.prevout);
1475+
}
1476+
14701477
// estimate final size of tx
14711478
const TxSize tx_size{CalculateMaximumSignedTxSize(CTransaction(rawTx), pwallet.get())};
14721479
const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)};
1473-
const CAmount effective_value{total_input_value - fee_from_size};
1480+
const std::optional<CAmount> total_bump_fees{pwallet->chain().calculateCombinedBumpFee(outpoints_spent, fee_rate)};
1481+
CAmount effective_value = total_input_value - fee_from_size - total_bump_fees.value_or(0);
14741482

14751483
if (fee_from_size > pwallet->m_default_max_tx_fee) {
14761484
throw JSONRPCError(RPC_WALLET_ERROR, TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED).original);

0 commit comments

Comments
 (0)