Skip to content

fix(onchain): show the real on-chain fee, and name the minimum when a payment is too small - #555

Merged
islandbitcoin merged 3 commits into
mainfrom
fix/onchain-minimum-amount-message
Nov 27, 2026
Merged

islandbitcoin merged 3 commits into
mainfrom
fix/onchain-minimum-amount-message

Conversation

@islandbitcoin

@islandbitcoin islandbitcoin commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #554, from the first real payments on production. Two defects on the Cash wallet's on-chain confirm screen, both in how this API reports what IBEX said.

1. The fee was shown as $0.00

IBEX's on-chain fee estimate names the fee twice: feeSat in sats, and fee in the wallet's currency in dollars. Production answered:

{ "fee": 0.409916881285, "feeSat": 686 }

That is 41 cents. Both Cash-wallet fee queries returned resp.fee unchanged into a field typed FractionalCentAmount, and clients read that field as cents. So 41 cents became 0.41 of a cent, and the confirm screen showed "$0.00" for a fee that was then charged.

onChainUsdTxFee has done this since it moved to IBEX. onChainUsdTxFeeAsBtcDenominated inherited it in #554.

Fix: onChainFeeCentsFromIbex (src/services/ibex/on-chain-fee.ts) scales the fee to cents, and both queries use it. It also refuses a fee that is missing, not a number, not finite or negative, instead of passing it on.

2. A too-small payment told the payer to contact support

IBEX has a minimum for on-chain sends and answers a smaller amount, on both the estimate and the send, with:

400 {"error":"minimum amount is 5500 Satoshi"}

errorHandler had no class for that text, so it became a generic IbexError, which error-map turns into "An error occurred. Contact support if error persists."

Fix: IbexAmountBelowMinimum, a new IbexError subclass classified through the existing needle list. The minimum is read from IBEX's answer, never kept as a number here. It maps to INVALID_INPUT with: "This amount is below the minimum of 5,500 sats. Enter a larger amount." If IBEX's text carries no usable number, the message drops the number and nothing else. Level is Info: it is the payer's input.

Decisions worth a reviewer's eye

  • The fee change is a 100x change in a returned number. It moves the value to what the schema has always declared (cents). The mobile app reads the field as cents with no correction of its own, and I found no other client of these two queries in the Flash repos. An outside API consumer that worked around the old value by multiplying by 100 would now be 100x high.
  • Only the two on-chain queries change. lnUsdInvoiceFeeProbe also returns an IBEX fee as it comes. I did not check its units and did not touch it.
  • Fractions of a cent are kept, to six decimals. The field is a fractional cent amount and clients round for display.
  • The minimum-amount needle is generic. Any IBEX endpoint that answers "minimum amount is N Satoshi" gets the class, so the message says "this payment".
  • No pre-check before calling IBEX. IBEX is the authority on its own minimum; a local copy would drift.
  • The fee query still fails for a too-small amount, now with the message in the GraphQL error. Current app versions show their own fixed text for a failed fee, so the visible change is on the send.

Tests

  • on-chain-fee.spec.ts: production's answer becomes 40.99 cents; always 100 times the dollar figure; float noise from the multiplication is dropped; fractions of a cent kept; zero stays zero; missing, null, string, NaN, infinite, negative and object fees are refused.
  • on-chain-usd-tx-fee-query.spec.ts (new; this query had no spec): fee in cents; the dollar figure never reaches the field; zero fee; wallet, IBEX, minimum-amount and malformed-fee failures; bad inputs; authentication required.
  • on-chain-usd-tx-fee-query-as-sats.spec.ts: the same unit assertions, and a non-numeric fee fails.
  • errors.spec.ts: the real 400 body is classified and the minimum read out; Info level; still an IbexError; another minimum is followed; case-insensitive and plain-text bodies; text only in the wrapped message, with no stack and no vendor name reaching the payer; no number, zero and an oversized number fall back to the message without a number; an insufficient-balance answer is not mistaken for a minimum.
  • error-map.spec.ts and the sat-denominated send spec: the message reaches the client as INVALID_INPUT.
  • Ran locally: the GraphQL, IBEX, payments and wallets unit suites (83 suites, 1054 tests) pass. eslint and prettier clean on the touched files.
  • Not clean locally: two tsc errors in src/servers/graphql-server.ts and graphql-admin-server.ts, untouched here, from older local dependencies. CI is the reference.
  • Not run against IBEX. The response bodies are the ones production returned on 2026-11-27. How a deployed build displays in the app is unverified until it ships.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gn2VCc25BAQjEu33uLycvP

islandbitcoin and others added 2 commits November 27, 2026 13:00
IBEX refuses an on-chain send or fee estimate under its minimum with
`400 {"error":"minimum amount is 5500 Satoshi"}`. That fell through as a
generic IbexError, so the app showed "An error occurred. Contact support if
error persists." for what is a too-small amount.

Classify it as IbexAmountBelowMinimum, read the minimum out of IBEX's answer
(never a number kept here) and map it to INVALID_INPUT with a message the
payer can act on: "This amount is below the minimum of 5,500 sats. Enter a
larger amount."

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gn2VCc25BAQjEu33uLycvP
IBEX's on-chain fee estimate names the fee in dollars (0.41 is forty-one
cents). Both Cash-wallet fee queries passed that number straight into a
FractionalCentAmount field, which clients read as cents. A 41 cent fee was
shown as $0.00 on the confirm screen and then charged.

onChainUsdTxFee and onChainUsdTxFeeAsBtcDenominated now scale it through one
converter, onChainFeeCentsFromIbex, which also refuses a fee that is not a
finite, non-negative number.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gn2VCc25BAQjEu33uLycvP
@islandbitcoin islandbitcoin changed the title fix(ibex): tell the payer the minimum when a payment is too small fix(onchain): show the real on-chain fee, and name the minimum when a payment is too small Nov 27, 2026
onChainUsdTxFee returned domain errors raw, so graphql-js reported their
message verbatim: an unclassified IBEX failure carried the server stack and
the vendor text, and the below-minimum error arrived without INVALID_INPUT.
It now throws mapError(...) like onChainUsdTxFeeAsBtcDenominated, and the
spec asserts the mapped codes and that no IBEX text or stack leaks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gn2VCc25BAQjEu33uLycvP
@islandbitcoin
islandbitcoin merged commit 117f8b5 into main Nov 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant