fix: count the network fee in the confirm-screen balance check (closes #154)
All checks were successful
check / check (push) Successful in 26s
All checks were successful
check / check (push) Successful in 26s
The Send button was enabled whenever the amount alone fit the balance, so a max-value ETH send passed the confirmation screen and failed at broadcast, after the user had committed to it. The arithmetic moves into src/shared/txValidation.js as a pure function over 18-decimal fixed point: native ETH now requires amount + fee <= balance, and an ERC-20 transfer requires the ETH balance to cover the fee on top of the token check, reported as its own error. Validation re-runs when the async estimate resolves; Send stays disabled while the estimate is pending and when it fails, so an unknown fee is never treated as zero. The fee messages are static elements that already reserve their space, so nothing moves when the estimate lands. The fee reserved is the one the node will actually require. The send pins no fee fields, so ethers broadcasts a type-2 transaction and the node validates it against value + gasLimit * maxFeePerGas; gating on gasPrice would under-reserve by roughly gasLimit * baseFee and let through exactly the broadcast failure this change exists to prevent. feeReserveWei() derives that reserve, falling back to gasPrice only where no type-2 pricing exists. The reserve is read when the screen opens and the broadcast derives its own, so a base fee that roughly doubles while the user is at the password field can still outrun it: this turns a deterministic failure on every max-value send into a rare one, not into none. The fee line shows both numbers rather than one - what the transfer is expected to cost, and below it the larger amount reserved until it confirms. Quoting only the reserve overstates the typical mainnet cost by roughly double on every send; quoting only the estimate contradicts the gate. The second line holds its space from the first paint. validateTransfer() fails closed: a feeWei that is not a non-negative bigint under FEE_KNOWN, any unrecognised feeStatus, and a negative amount all block, rather than counting as a fee of zero or as an amount that passes every comparison trivially.
This commit is contained in:
5
TODO.md
5
TODO.md
@@ -55,6 +55,11 @@ undefined identifiers, which is how
|
||||
- 2026-08-11: UTC Timestamps checkbox moved from the Token Spam Protection well
|
||||
into Display, next to the theme selector
|
||||
([#212](https://git.eeqj.de/sneak/AutistMask/issues/212)).
|
||||
- 2026-08-11: Network fee counted in the confirmation-screen balance check for
|
||||
both ETH and ERC-20 sends, reserving what the node actually charges a type-2
|
||||
transaction, with the arithmetic in a pure, unit-tested
|
||||
`src/shared/txValidation.js`
|
||||
([#154](https://git.eeqj.de/sneak/AutistMask/issues/154)).
|
||||
- 2026-08-11: A dust threshold of `0` now means "hide nothing" instead of
|
||||
falling back to the 100,000 gwei default, and every address comparison in
|
||||
`src/shared/transactions.js` goes through one case-normalising helper so a
|
||||
|
||||
Reference in New Issue
Block a user