AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 62 Bitcoin

Merge bitcoin/bitcoin#36342: wallet: reject recipient amounts above MAX_MONEY

Public commit record

What the developer wrote

Authored by Ava Chow

86/100 · Strong
Merge bitcoin/bitcoin#36342: wallet: reject recipient amounts above MAX_MONEY

bab579e56aa8b80a6f2923285e55cbcb2a7730b8 wallet: reject recipient amounts outside MoneyRange (Bruce0X)

Pull request description:

`CreateTransaction` checks that recipient amounts aren't negative, but not that they're within `MAX_MONEY`. `CreateTransactionInternal` then sums them into `recipients_sum` (spend.cpp:1100) with no range check, and that sum can overflow.

Easiest way to hit it is `fundrawtransaction` with a raw tx that has two outputs of 2^62 sat. It can also be reached with only valid amounts through `walletcreatefundedpsbt`/`send`/`sendmany` and a few thousand 21M BTC outputs. The "Transaction too large" check only runs after coin selection, so it doesn't stop this. On master the node aborts:

```
Assertion failed: (!m_selected_inputs.empty()), function RecalculateWaste, file coinselection.cpp, line 904.
```

UBSan reports the overflow at spend.cpp:1100 first. With other values the sum wraps to a small positive number instead, and `fundrawtransaction` returns success for a tx with outputs of 46116860184 BTC each.

This checks every amount and the running sum against `MoneyRange` in the existing recipients loop of `CreateTransactionInternal`, before the amount is added to `recipients_sum`, and returns "Transaction output amount must be valid" before coin selection starts. The same check rejects negative amounts, so the separate negative check in `CreateTransaction` is removed. The new `test_outputs_above_max_money` in `wallet_fundrawtransaction.py` covers a single output above MAX_MONEY, two outputs whose sum is above it, a sum that overflows int64, and a negative output. On master the first case returns "Insufficient funds" and the overflow case crashes the node; with the fix all of them get the new error. `wallet_fundrawtransaction.py`, `wallet_send.py`, `wallet_basic.py` and `rpc_psbt.py` pass.

ACKs for top commit:
maflcko:
lgtm ACK bab579e56aa8b80a6f2923285e55cbcb2a7730b8
Zippo76:
tACK bab579e56a
furszy:
utACK bab579e56aa8b80a6f2923285e55cbcb2a7730b8
achow101:
ACK bab579e56aa8b80a6f2923285e55cbcb2a7730b8

Tree-SHA512: 068c3bd19e37c2c3da237ddcf28cd88f3792a23c39ab1fa0469fdef9745117edc0ca5382174c184cef82155c725aac29b44df7b1d5f90b0c48ec94a9f0087a2b
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This patch fixes a bug in Bitcoin Core's wallet transaction creation where extremely large output amounts could cause an integer overflow or even crash the node. Before the fix, a user could craft a transaction whose outputs added up to more than the maximum allowed bitcoin amount (about 21 million BTC), leading to incorrect math, a failed internal assertion, or a successful but invalid transaction. The fix now rejects such oversized or overflowing amounts early with a clear error message.

Recommended action

Apply the patch. The fix is small, well-tested, and prevents a reachable crash/overflow in wallet RPCs. No additional immediate action is required beyond normal backporting to maintained release branches.

Security signals we found

01

Integer overflow in recipient amount summation

02

Node abort via failed assertion in coin selection

03

Possible creation of a transaction with wrapped/invalid total output value

04

Missing upper-bound validation on user-supplied output amounts

05

Functional test explicitly demonstrates crash/invalid-result scenarios on master

Risk score

Why this scored 62/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 8/15
Affected reach 10/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.