Repository navigation
fix(onchain): show the real on-chain fee, and name the minimum when a payment is too small - #555
Merged
Merged
Conversation
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
feeSatin sats, andfeein the wallet's currency in dollars. Production answered:That is 41 cents. Both Cash-wallet fee queries returned
resp.feeunchanged into a field typedFractionalCentAmount, 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.onChainUsdTxFeehas done this since it moved to IBEX.onChainUsdTxFeeAsBtcDenominatedinherited 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:
errorHandlerhad no class for that text, so it became a genericIbexError, whicherror-mapturns into "An error occurred. Contact support if error persists."Fix:
IbexAmountBelowMinimum, a newIbexErrorsubclass classified through the existing needle list. The minimum is read from IBEX's answer, never kept as a number here. It maps toINVALID_INPUTwith: "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
lnUsdInvoiceFeeProbealso returns an IBEXfeeas it comes. I did not check its units and did not touch it.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 anIbexError; 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.tsand the sat-denominated send spec: the message reaches the client asINVALID_INPUT.tscerrors insrc/servers/graphql-server.tsandgraphql-admin-server.ts, untouched here, from older local dependencies. CI is the reference.🤖 Generated with Claude Code
https://claude.ai/code/session_01Gn2VCc25BAQjEu33uLycvP