Skip to content

Fix/altpayment btc flow - #671

Draft
chedieck wants to merge 6 commits into
masterfrom
fix/altpayment-btc-flow
Draft

Fix/altpayment btc flow#671
chedieck wants to merge 6 commits into
masterfrom
fix/altpayment-btc-flow

Conversation

@chedieck

Copy link
Copy Markdown
Collaborator

Description

Fixes altpayment="BTC" buttons.

If the customer could choose the amount (editable="true", or no amount set),
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 BTC came back
as "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 the
Uncaught (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, then http://localhost:10001/index.html:

  1. Pay with BTC (fixed amount): lands on "Send Bitcoin for eCash" with a
    deposit address, amount, QR and shift ID.
  2. Pay with BTC (editable): loading screen straight to the rate + amount box,
    no coin/network dropdown flashing by. Same with no amount set.
  3. Type 0.0001 there and send: order is for exactly 0.0001 BTC. Check both
    currency="XEC" and currency="USD".
  4. Dead ws-base-url: after 25s you get "Could not reach SideShift" + Back.
  5. to="15Etyxpus9UeLSvpkmdBDqp7tVz7F6EcBe": button renders with
    "Invalid Recipient" under it.
  6. Switch tabs and come back with a button open: no console errors.

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.

chedieck and others added 6 commits August 14, 2026 15:06
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
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ff35fd7-3b61-4181-b6e0-87d03c8ea514

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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