Merge bitcoin/bitcoin#36375: wallet: accept uppercase addresses without amount in sendall
What changed, and why it matters
This patch fixes a bug in Bitcoin Core's `sendall` wallet command. If a user typed a bech32 address in uppercase letters, the command would fail with a confusing 'below dust threshold' error instead of sending the funds. The fix compares decoded address data rather than raw text, so uppercase and lowercase addresses are treated the same. It is a usability/functional bug, not a vulnerability that lets someone steal funds.
No urgent security action required. Treat as a normal bug-fix merge; ensure the new regression test passes.
Security signals we found
Functional bug in RPC command causing unexpected transaction failure
Case-sensitivity mismatch between user input and canonical address encoding
No memory safety, cryptographic, or authorization issue evident
Regression test added to prevent re-introduction
Evidence from the diff
In src/wallet/rpc/spend.cpp, sendall previously stored recipient addresses without amounts as raw strings and later matched them against EncodeDestination() output, which is lowercase for bech32. Uppercase bech32 addresses are valid but never matched, leaving the placeholder output amount at 0 and triggering a dust-threshold error. The patch stores CTxDestination objects (decoded via DecodeDestination) and compares those, making matching case-insensitive. A regression test sendall_uppercase_address is added.
Changed components
Bitcoin Core wallet RPCsrc/wallet/rpc/spend.cppsendall commandInspect captured patch +22 / −5
### src/wallet/rpc/spend.cpp
@@ -1387,7 +1387,7 @@ RPCMethod sendall()
PreventOutdatedOptions(options);
- std::set<std::string> addresses_without_amount;
+ std::set<CTxDestination> addresses_without_amount;
UniValue recipient_key_value_pairs(UniValue::VARR);
const UniValue& recipients{request.params[0]};
for (unsigned int i = 0; i < recipients.size(); ++i) {
@@ -1396,7 +1396,9 @@ RPCMethod sendall()
UniValue rkvp(UniValue::VOBJ);
rkvp.pushKV(recipient.get_str(), 0);
recipient_key_value_pairs.push_back(std::move(rkvp));
- addresses_without_amount.insert(recipient.get_str());
+ // Store the decoded destination, so it matches the outputs below
+ // also when the address was given in another case (e.g. uppercase bech32)
+ addresses_without_amount.insert(DecodeDestination(recipient.get_str()));
} else {
recipient_key_value_pairs.push_back(recipient);
}
@@ -1560,8 +1562,7 @@ RPCMethod sendall()
for (CTxOut& out : rawTx.vout) {
CTxDestination dest;
ExtractDestination(out.scriptPubKey, dest);
- std::string addr{EncodeDestination(dest)};
- if (addresses_without_amount.contains(addr)) {
+ if (addresses_without_amount.contains(dest)) {
out.nValue = per_output_without_amount;
if (!gave_remaining_to_first) {
out.nValue += remainder % addresses_without_amount.size();
@@ -1574,7 +1575,7 @@ RPCMethod sendall()
} else {
if (IsDust(out, pwallet->chain().relayDustFee())) {
// Specified output amount is dust
- throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Specified output amount to %s is below dust threshold.", addr));
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Specified output amount to %s is below dust threshold.", EncodeDestination(dest)));
}
}
}
### test/functional/wallet_sendall.py
@@ -90,6 +90,19 @@ def sendall_two_utxos(self):
)
self.assert_balance_swept_completely(tx_from_wallet, pre_sendall_balance)
+ @cleanup
+ def sendall_uppercase_address(self):
+ self.log.info("Testing sendall to an uppercase bech32 address without amount")
+ pre_sendall_balance = self.add_utxos([10, 11])
+ tx_from_wallet = self.test_sendall_success(sendall_args=[self.remainder_target.upper()])
+
+ self.assert_tx_has_outputs(tx=tx_from_wallet,
+ expected_outputs=[
+ {"address": self.remainder_target, "value": pre_sendall_balance + tx_from_wallet["fee"]}
+ ]
+ )
+ self.assert_balance_swept_completely(tx_from_wallet, pre_sendall_balance)
+
@cleanup
def sendall_split(self):
self.log.info("Testing sendall where two recipients have unspecified amount")
@@ -523,6 +536,9 @@ def run_test(self):
# Basic sweep: everything to one address
self.sendall_two_utxos()
+ # Sendall to an uppercase bech32 address
+ self.sendall_uppercase_address()
+
# Split remainder to two addresses with equal amounts
self.sendall_split()
Why this scored 27/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.