Fix/altpayment btc flow - #671
Draft
chedieck wants to merge 6 commits into
Draft
Conversation
Some API versions return the transaction address (and each input address) as a nested object instead of a plain string. That object was copied straight into Transaction.address, and the next address parse threw "Invalid address prefix.", which surfaced on the host page as an uncaught promise rejection whenever the widget re-checked the transaction history (for instance on tab focus). Normalize the address as soon as it arrives, fall back to the queried address when the API sends none, and stop a failing transaction handler from rejecting unhandled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBtWogj1C1LvKsLY5NTtMv
A failing chronik connection rejected inside an unawaited async effect, which both showed up as an uncaught error on the host page and skipped the SideShift socket setup entirely. Log the failure instead and carry on with the altpayment connection, which does not depend on chronik. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBtWogj1C1LvKsLY5NTtMv
With a preselected coin the widget went straight to the "Loading SideShift..." screen and waited for a shift, but the automatic rate/quote requests were skipped whenever the amount was editable — which is also the case for buttons with no amount at all. The result was a spinner that never resolved. Editable buttons now request the rate as soon as the coin is preselected and show the amount form (prefilled with the converted amount, labelled with the deposit coin) instead of the automatic loading screen. An unrecognized ticker falls back to the regular coin selector, and every SideShift step gives up with an error message instead of spinning forever when the service never answers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBtWogj1C1LvKsLY5NTtMv
Covers the case where the user types the BTC amount instead of paying a fixed one, which previously never left the loading screen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBtWogj1C1LvKsLY5NTtMv
A mistyped or non-eCash/BCH address made getCurrencyTypeFromAddress throw while rendering, so the whole button vanished from the page with an "Invalid currency" error in the console — even though both PayButton and Widget already have an "Invalid Recipient" message for exactly this case. Components now fall back to a default ticker when the address cannot be parsed and let that message render. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBtWogj1C1LvKsLY5NTtMv
Typing an amount fed the converted settle amount back into the button amount,
which for fiat buttons is denominated in the fiat currency: the value grew on
every round trip, and the quote — built from that derived value rather than from
the input — asked SideShift for a wildly larger deposit ("Amount too high.
Maximum deposit amount: …") on a perfectly valid amount.
The quote now uses the typed amount directly, and the widget converts the settle
amount back into the button currency before updating it.
Also stop the coin/network pickers from flashing by before the rate arrives when
the coin is preselected, and drop the back button that pointed at a coin step
that does not exist in that case.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VBtWogj1C1LvKsLY5NTtMv
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Description
Fixes
altpayment="BTC"buttons.If the customer could choose the amount (
editable="true", or noamountset),the widget got stuck on "Loading SideShift..." forever: it was waiting for an
order nobody had requested. It now shows the rate and an amount box in BTC.
Typing an amount was broken too. The typed value was written back to the button
amount in the wrong unit, so it grew every time it round-tripped, and the order
was built from that inflated number instead of the input.
0.0001 BTCcame backas "Amount too high". The order now uses what was typed.
Smaller things in here: SideShift steps time out after 25s with an error instead
of spinning forever, an unknown coin ticker falls back to the coin picker, a bad
to=address shows "Invalid Recipient" instead of the button vanishing, and theUncaught (in promise) Error: Invalid address prefix.in the console is gone(the API can return the tx address as an object; the widget now handles both).
Test plan
yarn watch, thenhttp://localhost:10001/index.html:deposit address, amount, QR and shift ID.
no coin/network dropdown flashing by. Same with no
amountset.0.0001there and send: order is for exactly0.0001 BTC. Check bothcurrency="XEC"andcurrency="USD".ws-base-url: after 25s you get "Could not reach SideShift" + Back.to="15Etyxpus9UeLSvpkmdBDqp7tVz7F6EcBe": button renders with"Invalid Recipient" under it.
SideShift's minimum is around US$10, below that the button stays disabled with
"Amount is below minimum". Use ~3,000,000 XEC for a real order.