Skip to content

I18n/cleanup - #1107

Merged
bordalix merged 3 commits into
masterfrom
i18n/cleanup
Oct 28, 2026
Merged

bordalix merged 3 commits into
masterfrom
i18n/cleanup

Conversation

@bordalix

@bordalix bordalix commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Removed unused translation entries; displayed text remains unchanged.
    • Updated language-related checks to verify that translations used by the app are available.
  • Tests
    • Updated automated checks for wallet setup, receiving, and asset screens to match the current labels.
    • Added a brief wait for mnemonic suggestions to appear before navigating them.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7dc64121-0b8d-4288-9af5-669837af945c
Commits

Reviewing files that changed from the base of the PR and between dbdc2ab and 65f2703.

Files selected for processing: 1
  • src/lib/i18n.ts
Files with no reviewable changes: 1
  • src/lib/i18n.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The English and Spanish translation dictionaries remove entries. The parity test collects source translation keys and checks them against the English dictionary. End-to-end tests update translation selectors, and the mnemonic autocomplete test adds a short wait.

Changes

Translation cleanup and test updates

Layer / File(s) Summary
Collect translation keys used by source
src/providers/language.tsx, src/test/lib/i18n.parity.test.ts
The settings option key map is exported. The parity test collects keys from translation calls, Lightning transaction keys, and settings mappings.
Remove translation entries and check parity
src/lib/i18n.ts, src/test/lib/i18n.parity.test.ts
The English and Spanish dictionaries remove entries across multiple sections, including the announcement entries. The parity test checks for unused English keys and verifies that collected keys resolve in English.
Update end-to-end test selectors and timing
src/test/e2e/asset.test.ts, src/test/e2e/init.test.ts, src/test/e2e/lnurl.test.ts, src/test/e2e/mnemonic-autocomplete.test.ts, src/test/e2e/receive.test.ts, src/test/e2e/utils.ts
End-to-end tests use updated empty-state, receive, and backup selectors. The mnemonic autocomplete test waits 100 ms before navigating suggestions.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

Suggested reviewers: delgado74

Merge Risk: Minimal · up to 65f27

No missing translation or other merge-blocking behavior was established. The change is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change as an internationalization cleanup. It is concise and related to the translation, test, and export changes.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65f2703
Status: ✅  Deploy successful!
Preview URL: https://9e9f2068.arkade-wallet.pages.dev
Branch Preview URL: https://i18n-cleanup.arkade-wallet.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Deploying wallet-bitcoin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65f2703
Status: ✅  Deploy successful!
Preview URL: https://93acec3c.wallet-bitcoin.pages.dev
Branch Preview URL: https://i18n-cleanup.wallet-bitcoin.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
src/test/e2e/mnemonic-autocomplete.test.ts: 1

23-23: Trivial · Functional Correctness · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Wait for the suggestion instead of a fixed delay.

If the suggestion appears after 100 ms, Enter can submit the incomplete phrase instead of selecting a word. Wait for the agree option to be visible before pressing ArrowDown. (raw.githubusercontent.com)

Based on learnings: Playwright tests should use condition-based waits instead of fixed delays.

Source: Learnings


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aff75b91-9f40-4e09-871f-2b5f00d21c2b
Commits

Reviewing files that changed from the base of the PR and between 4586262 and dbdc2ab.

Files selected for processing: 9
  • src/lib/i18n.ts
  • src/providers/language.tsx
  • src/test/e2e/asset.test.ts
  • src/test/e2e/init.test.ts
  • src/test/e2e/lnurl.test.ts
  • src/test/e2e/mnemonic-autocomplete.test.ts
  • src/test/e2e/receive.test.ts
  • src/test/e2e/utils.ts
  • src/test/lib/i18n.parity.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@arkana-ai-bot arkana-ai-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — I18n/cleanup

No protocol, signing, VTXO, or financial logic touched. All findings are test/tooling quality.


Correctness of removals ✓

Grepped every deleted key against production src/ (excluding i18n.ts and test files).
All removed keys are genuinely dead in production code. Key cross-checks performed:

  • transaction.sentSuccessfully ('sent successfully', no interpolation) removed — production code uses send.sentSuccessfully ('{amount} sent successfully') which is kept. Correct.
  • transaction.receivedSuccessfully — kept. Used by Receive/Success.tsx. Correct.
  • errors.{lnurl,solverNotResponding,insufficientFunds,noEligibleToSettle,…} — no production t() calls found.
  • scanner.{pointAtQr,unsupported,permissionDenied} — Scanner.tsx only calls scanner.cameraError and scanner.tryAgain, both kept.
  • send.{confirmPayment,to,sign,networkFee,inputTotal,goBack,quoteExpired,missingAssetsList,…} — no production callers found.
  • common.loading — kept in common namespace and still used by several screens. The PR removes only loading.loading (a separate namespace entry). Correct.

New "no unused keys" parity test — minor notes

src/test/lib/i18n.parity.test.ts

Space-sensitive ternary regex (new collectUsedKeys, inline):

/\bt\([^?)]+ \? ['"]([A-Za-z0-9_.]+)['"] : ['"]([A-Za-z0-9_.]+)['"]/g

The character class [^?)] with a trailing literal space means compact ternaries without whitespace around ? (e.g. t(cond?'a':'b')) are silently missed. Not a current problem — the codebase consistently uses spaced ternaries — but worth documenting. The companion "every t() resolves" test catches the failure mode (missing key → runtime fallback), so the risk is bounded.

Dynamic key construction: The hardcoded special-case for transaction.lightning${stemKey}${suffix} (from lib/swapDisplay.ts) is the only dynamic pattern today. If another dynamic pattern is ever added, collectUsedKeys must be updated manually or the "no unused keys" test will false-positive on the next cleanup. A comment pointing at swapDisplay.ts for this reason would help future readers (I see a comment is present — good).

es values are real translations allowList (src/test/lib/i18n.parity.test.ts:54–93, unmodified by this PR):
The allowList still references common.sat, transaction.boarding, and solvers.fieldRelays, all of which are removed from i18n.ts by this PR. These are dead entries — harmless because collectLeafKeys(translations.en) will no longer emit them — but slightly misleading. Worth cleaning up in a follow-on.


announcement: {} — vestigial namespace

src/lib/i18n.ts (both en and es)

Emptying the object rather than removing the key entirely leaves a namespaced tombstone. Both locales correctly have announcement: {} (parity test still passes), but a future contributor adding announcement.foo in one locale without the other would silently break the en/es parity test. Removing the key altogether is cleaner, though this is a very minor style point.


sleep(100) in mnemonic autocomplete test

src/test/e2e/mnemonic-autocomplete.test.ts — new sleep(100) before ArrowDown

This fixes a real flake (suggestions not yet visible when the key is pressed). A Playwright waitFor / expect(page.getByRole('option')).toBeVisible() would be more robust on slow CI than a hardcoded 100 ms, but this is test-only and not blocking.


SETTINGS_OPTION_KEY export — fine

src/providers/language.tsx:48 — the constant is exported solely for the parity test. It is a read-only lookup table of i18n key paths with no protocol or security surface.


Summary

Mechanically correct cleanup. The removed keys are verified unused in production. The new "no unused keys" test is a genuine improvement that will prevent this class of drift from returning. The nits above are all non-blocking.

@arkana-ai-bot arkana-ai-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status: 1 commit since last pass (65f2703, "nit: remove empty key in translations") — 2 lines deleted, 1 file. 1 prior finding fixed, 3 non-blocking nits remain open (unchanged).


Prior findings — closure

Fixed — announcement: {} vestigial namespace (65f2703)
Exactly the change I suggested: both en and es now have the announcement key removed entirely from src/lib/i18n.ts. The tombstone is gone.

Still open — space-sensitive ternary regex (src/test/lib/i18n.parity.test.ts, unmodified)
collectUsedKeys regex [^?)] with a trailing literal space still misses compact ternaries. Not touched by this commit; bounded by the companion "every t() resolves" test. Non-blocking.

Still open — dead allowList entries (src/test/lib/i18n.parity.test.ts:54–93, unmodified)
common.sat, transaction.boarding, solvers.fieldRelays remain in the allowList but are no longer in i18n.ts. Harmless but misleading. Non-blocking.

Still open — sleep(100) in mnemonic autocomplete test (src/test/e2e/mnemonic-autocomplete.test.ts, unmodified)
A condition-based wait would be more robust on slow CI. Non-blocking.


Incremental findings

None. The diff is two deletions of empty objects; no new logic, no new test surface, no protocol or security surface touched.


No blocking issues. All prior concerns are either resolved or unchanged non-blocking nits.

@bordalix
bordalix merged commit ca398bf into master Oct 28, 2026
8 checks passed
Kukks added a commit that referenced this pull request Oct 28, 2026
Master's #1107 fails when a translation key is not referenced by a literal
t('...') call. The claim error messages were reached through a code-to-key
map and a dynamic t(key), so six used keys read as unused. They are now
literal t() calls in a code-to-message map; the messages are unchanged.
Kukks added a commit that referenced this pull request Oct 28, 2026
… page (#1084)

* chore(deps): add @arkade-os/lnurl-client 0.6.0 and @web3icons/react 4.1.24

The published LNURL client the payer, receiver and activity work builds
on, and the chain icons the token receive rails badge their logos with.
Both pinned. Nothing imports either yet.

Split out of #1000.

* fix(bip21): read a Lightning address back from lightning= (#1079)

* fix(bip21): read a Lightning address back from lightning=

decodeBip21 read any lightning= value that starts with "ln" as an invoice
and dropped anything else, so a Lightning address in lightning= was lost
("alice@...") or misread as an invoice ("lnbob@..."). A value with "@" is
now kept as an LNURL when it is a valid Lightning address, and never read
as an invoice: bech32 has no "@".

encodeBitcoinLink builds the unified bitcoin: link with ark=, lightning=
and an amount= that sizes only the on-chain and Arkade parts, and puts a
Lightning address in lightning= (not BIP321, which is BOLT11 only). It
lands here with the decoder so the two are tested as a round trip; the
receive redesign is its first caller.

Split out of #1068.

* test(bip21): pin which link parts amount= sizes

encodeBitcoinLink writes amount= only beside an on-chain or Arkade part;
a Lightning-only link leaves it out because the invoice or LNURL carries
the amount. Both cases are now asserted.

* docs(bip21): say the decoder relies on isValidLnUrl accepting user@domain

The Lightning-address branch depends on lnurl-client's isValidLnUrl
accepting the user@domain form, so a future change there would drop
these addresses; the comment now names that dependency.

* fix(bip21): escape query delimiters inside link values

encodeBitcoinLink wrote ark= and lightning= values raw, so a value
holding '&amount=1' (a Lightning address comes from the LNURL server)
added a parameter, and decoders reading the first amount= saw the
injected one. Only what would end or split a query value is escaped now
(% & = # + ? and whitespace); '@' stays literal, and URLSearchParams
decodes the rest.

* chore(deps): adopt published LNURL client 0.7.0

* test(bip21): check the decoded Lightning address in the delimiter case

The case already checked that a query delimiter inside a Lightning address does not add a parameter; it now also checks that decodeBip21 hands the address back intact. Suggested by CodeRabbit on #1073.

* chore(deps): adopt published LNURL client 0.8.0

0.8.0 ships the glue the LNURL layers above this one still write by hand:
the localStorage watermark and sent-payment stores, sync that stops on a
signal, receiver discovery that refreshes destinations and orders writes per
identity and server, sessionLnurl() and addresses() on the facade, and the
token-quote, payable-range, first-quote and chain-name helpers. Each layer
adopts its part on top of this bump.

The release also removes the package's HD receive entry point, which the
wallet never imported, and with it the @scure/bip32 dependency.

* feat(activity): show who an LNURL payment came from or went to

lnurlPaymentRepository keeps the payments the lnurl-client sync store
writes: an IndexedDB store, with per-address watermarks in localStorage,
behind the package's PaymentSyncStore interface. Its activity resolver is
registered on the wallet at startup, and a wallet reset clears the store,
since it holds preimages.

activitiesToTxs tags a row from either lnurl-client resolver with the
address and the rail. A receive names the wallet's own lightning address
it arrived at, never the payer: "Received at alice@...", or "Received via
arkade" for a nameless one. A send names who it paid. The transaction
details show Received at and Rail for a receive (en/es). A send that both
a swap group and the sent group claim shows once, as the swap.

Split out of #1000.

* fix(activity): localize LNURL activity labels, and close the store on errors

lnurlLabel built 'Received at …', 'Sent to …' and '… via …' in English,
so a Spanish wallet's activity list mixed languages. It now takes t like
lnSwapLabel, with transaction.lnurl{SentTo,ReceivedAt,SentVia,ReceivedVia}
in en and es.

The IndexedDB payment store closed its connection only on success; a
failed read, write or clear left it open. Each error path now closes it
before rejecting.

* refactor(activity): skip a sent: group only when it has members

The swap-dedup check skipped a sent: activity when every member was also
claimed by another group, which [].every made true for an empty group.
An empty group yields no rows either way, so this changes no output; the
length check states the intent. The txid is also read once per member.

* fix(activity): read a malformed watermark map as empty

getStorageItem falls back only when JSON.parse throws, so a stored value
that parses to something other than a plain object (null, an array, a
number) reached the watermark code, which threw on read or write, or lost
the write, until storage was cleared. Such a value now reads as no
watermarks.

* fix(activity): clear LNURL payments before a reset turns destructive

The reset cleared the payment store after clearStorage() and swallowed the
failure, so a clear that failed left the previous wallet's LNURL records,
preimages included, in IndexedDB while the reset reported success. The next
wallet's activity resolver then read them. The step now runs before anything
destructive and rejects, leaving the wallet intact for a retry.

syncLnurlActivity was not the only writer either: the claim-triggered
sync() calls in receive/lnurlRail.ts are fire-and-forget through the shared
sync store, so waiting on any per-caller tracker could miss them and let a
write land after the clear. The repository therefore owns one write gate and
one in-flight tracker, and clearLnurlPaymentsForReset closes the gate, waits
out the accepted writes, then clears. The gate does not reopen, which a
reset need not survive: it reloads the app. The watermark write honours it
too, so a late sync cannot re-seed localStorage after clearStorage().

The swap-record clear stays non-fatal, as stale swap rows beat a wallet
half-cleared. Reset.tsx now shows settings.resetFailed (en/es) instead of
only logging, with a fixed message so a store error cannot surface payment
data.

* fix(activity): reopen the LNURL store when a reset's clear fails

A failed clear abandons the reset with the wallet intact, but the store
stayed closed, so every later LNURL write was dropped silently until a
reload. The gate now reopens before the error is rethrown.

* fix(activity): settle the LNURL store's IndexedDB calls on abort

A transaction that fails at commit — a quota overrun, say — finds every
request already done, so no request error fires and only `abort` reaches
the transaction. `write` and `clear` listened for `complete` and `error`
only, so the promise never settled and the connection stayed open.

That stranded a wallet reset: `upsert` left the write in `inFlight`
forever, `clearLnurlPaymentsForReset` awaited `writesSettled()`, and
`resetWallet` never returned, so the Reset screen never reported the
failure. A synchronous throw out of `transaction()` or `put()` rejected
but leaked the connection in the same way.

All three operations now run through one helper that rejects on `error`,
on `abort` and on a synchronous throw, and closes the connection on
every path.

* fix(settings): say a failed reset may have cleared some data

The LNURL step is the only fatal one, and it runs before anything
destructive. Past it, `clearStorage()`, `svcWallet.clear()` and the
repository clears can each throw with data already gone, so "Nothing was
cleared" was a promise the screen could not keep. Copy only — no
rollback.

* fix(activity): reject an IndexedDB failure with its own error

A request error bubbles to tx.onerror before IndexedDB sets tx.error, so
rejecting there gave a bare AbortError and lost the cause (a quota
overrun, say). The abort that always follows an uncancelled error
carries it, so the store now settles on abort alone. The test fake now
fires error before setting tx.error, as IndexedDB does, and the
rejection assertions match the error's name: rejects.toThrow(regex)
also passes for a null rejection.

* fix(activity): abort the IndexedDB transaction when queuing a write throws

A put that throws mid-batch (an invalid key, say) rejected the write but
left the transaction live, and close() waits for it rather than
cancelling it, so the puts queued before the throw still committed. The
store now aborts that transaction and rejects with the original error
once the abort lands. A result that cannot be read at completion now
rejects instead of throwing out of oncomplete and leaving the promise
pending.

The abort-only cases now run for read as well as write and clear.

* feat(send): pay LNURL targets through the router, and track the receiver's confirmation (#1080)

* feat(send): pay LNURL targets through the router, and track the receiver's confirmation

The payer path moves onto @arkade-os/lnurl-client. Send resolves a
lightning address or LNURL with the client, and the router gains the
package's two LNURL rails: Arkade, ranked first, and Lightning, which
needs the swap client. quoteLnurl tries them in order, a rail that cannot
quote yields to the next, and the client refuses an invoice for any other
amount before a solver is asked. lib/lnurl.ts keeps only fetchArkAddress
(the ?method=ark call), which the package has no equivalent for.

The form drops the previous target when the recipient changes, holds
Continue until the LNURL conditions load, drops a quote that lands after
the amount or recipient changed, and lets a BIP21 pay its address or
invoice when its LNURL fails. A tab that is not driving swaps can still
pay an LNURL over Arkade (sendRouter swapsOptional). The success screen
calls an LNURL send over Lightning on its way and one inside Arkade sent.

Each LNURL send is recorded (lnurlSends) and labelled in activity by the
sent-payment resolver. When the rail hands out a verify URL, the wallet
polls it in one batch per endpoint, resumes after a reload, and the
transaction screen shows whether the receiver confirmed the payment
settled (en/es). A reset forgets the pending checks.

Split out of #1000.

* fix(send): keep a resumed receiver confirmation to its original window

Every reload resumed pending confirmations with a fresh three-minute
deadline, so a send whose receiver's server stayed down never reached
'not confirmed' for a user who reopened the app. A confirmation now
takes the time its wait began, and resuming passes the send's
createdAt: an already-lapsed window fails on the first tick.

The ?method=ark branch's comment also says it wins over the router's
rails and pays a plain Arkade send, with no receiver confirmation.

* fix(send): cut off a batch verify request that is held open

The confirmation loop skips a tick while the previous one runs, and a
batchVerify request has no timeout of its own. An endpoint holding the
request open therefore stopped every later tick, the deadline sweep
included, so a send waiting on that receiver never reached 'not
confirmed'. Each batch request is now aborted after 10 s, or at the
group's earliest deadline if sooner.

* refactor: adopt LNURL client storage and send lifecycle helpers

* fix(send): honor supported LNURL option bounds

* fix(lnurl): reject non-array stored send history

* fix: skip onchain fee lookup for optional LNURL routers

* test(lnurl): drop tests of lnurl-client internals

0.7.0 moved the payment repository, its reset gate, the IndexedDB store,
pending confirmations and the send tracker into @arkade-os/lnurl-client.
The package's own suite covers them (packages/client/test: repository,
browser, confirmations, sends, activity); lnurlConfirmations.test.ts was a
verbatim copy of ten of its cases. The wallet kept these tests running
through thin re-exports, which is the only thing those exports were for.

Keep what the wallet owns: the localStorage watermark adapter, including
malformed maps; reset purging its key; the prepare-time reread that lets
history see a sync written after construction; the stored-send parser;
same-tab notification only after a successful write; and one wiring test
each for recording a send and resolving it.

Drop the test-only exports with them: createLnurlPaymentSyncStore (an
identity function), the store and type re-exports, and lnurlConfirmations'
re-exports of the package factory.

* fix(send): show LNURL send refusals in the wallet's language

Two refusals this PR added on the Details screen went out in English
whatever the language: an account that may not send offchain, and a quote
made for another target or amount. The first already had a key; the second
gets one. The neighbouring guard for a quote made for another invoice gets
the same treatment, since it is the same message family. Raised by Arkana
on #1078.

* refactor(lnurl): take the send and history glue from lnurl-client 0.8.0

The package now ships what this layer wrote by hand. The watermark and
sent-payment stores come from its localStorage adapters, under the same keys
and in the same formats, so existing wallets keep their cursors and recorded
sends. Send listeners are the tracker's own subscribe, the receive resolver
reads the repository through the package's async getter, history rows read
resolver metadata through lnurlActivity, the send form takes its bounds from
lnurlPayableRanges, and the router quotes through firstQuote and isLnurlRail.
quoteLnurl keeps its own refusal for an address with no LNURL route, so that
message does not change.

The watermark tests that covered the adapter's parsing move with it; the
wallet keeps the one showing its existing key is read and reset purges it.

resumeLnurlConfirmations() gains a note on why every unlock may call it: the
tracker keys each watch by txid, and the confirmation queue ignores a key it
already holds.

* test(lnurl): drop tests the lnurl-client suite already runs

Each of these now exercises only package code.

lnurl.test.ts called isValidLnUrl, toPayRequestUrl and the client's resolve
and requestInvoice directly, with no wallet code in the path. The package's
encoding, resolve and request-invoice tests cover every case it had,
including the undecodable and wrong-amount invoices.

The stored-send parser and same-tab notification were kept at 0.7.0 because
the wallet owned them; 0.8.0 moved both into the package, whose browser and
sends tests cover them ("reads %s as no sends, without rewriting it", "tells
listeners after a write lands, never after one that failed, until they
unsubscribe").

The three hand-built activity rows tested lnurlIntentOf's metadata parsing,
which is now lnurlActivity and covered by the package's activity test. The
wallet's mapping onto the row stays covered by the tests that drive the real
resolvers end to end.

The wiring tests stay: the existing storage key, the onError report, one
recorded send, and the resolver reading the live store.

* test: drop the LNURL fixtures only the removed lnurl test read

* feat(receive): receive at a lightning address over the LNURL rail

With VITE_LNURL_SERVER set (and VITE_LNURL_DOMAIN where the LUD-16
domain differs from the API host), Receive composes a second rail beside
the solver swap rail. useLnurlRail resolves the identity's own receiver
at that server through the lnurl-client arkadeLnurl facade. When the
server allows nameless receivers it registers the wallet LNURL, which
encodes the wallet id and needs no name, and shows it in the QR as soon
as it is derived locally. Receive offers naming only when the user can
choose a name ("Add a name", "Pick one for me").

Lightning is the invoice the receiver's own LNURL issues for the amount,
as any payer would get it, or without one the receiver's address (its
LNURL while nameless). With config.receiveViaLnurl the Arkade and Bitcoin
legs resolve through the LNURL too; a destination the wallet can tell is
not its own (an Arkade address on another operator, an on-chain address
it did not register) is refused, and each rail that falls back to the
wallet's own address says why. The flag defaults off; its toggle ships
with the Settings page. The copy sheet gains the lightning address.

The swap rail stays off while an lnurl-server is configured, and takes
over when that server fails. Unset, Receive is the swap rail alone.

Deploy: the image reads VITE_LNURL_SERVER and VITE_LNURL_DOMAIN through
fromRuntimeEnv, like VITE_ARK_SERVER. The old VITE_LNURL_SERVER_URL is
gone; nothing in src/ read it, so a deploy still setting only that name
builds a wallet with the lnurl rail off, without an error.

Split out of #1000.

* fix(receive): wait for the wallet's own addresses before resolving the LNURL legs

With receiveViaLnurl on, useLnurlRails asked for the Arkade and on-chain
legs before the wallet's own addresses had loaded, then refused the
server's answers as 'not this wallet's' or 'another operator' until the
addresses arrived. A leg is now requested only once its own address is
known; Lightning resolves straight away and the effect already re-runs
when the addresses load.

The rail panel and name form were English-only (unavailable notice, Add a
name, Choose a name, Claim code, Claim name, Pick one for me); they now
read receive.* keys in en and es. The trust comment on the Arkade check
now says plainly that only the operator is verified.

* fix(receive): localize claim errors, keep the facade ref to commits, and drop a stale swap invoice

Claim errors (taken, not allowed, bad claim code, unavailable option,
rate limited, and the fallback) were English-only; lnurlClaimErrorMessage
now takes t and reads receive.* keys in en and es.

The ref run() checks against was assigned during render, so an abandoned
concurrent render could point it at an uncommitted facade. It is set in a
layout effect now.

A swap invoice left in the flow by an earlier visit was still preferred
over the LNURL's invoice once the LNURL rail served Lightning. The QR now
reads recvInfo.invoice only while the swap rail is on.

* test(receive): pin that a late boarding address settles back on the same receiver

A boarding address arriving after a session registered rebuilds the
facade; the rail returns to ready with the same LNURL and no error. The
claim-error key map is also typed Partial so a missing code reads as
undefined.

* fix(receive): drop trailing slashes from the configured LNURL server

configuredLnurlServer kept a trailing slash from VITE_LNURL_SERVER, so
https://lnurl.example/ derived the wallet LNURL as
https://lnurl.example//lnurl/<id>, and handed the same base to the
facade and the client. The base now loses trailing slashes once, where
every caller reads it.

* feat(lnurl): attribute receives that landed while the wallet was closed (#1082)

* feat(lnurl): attribute receives that landed while the wallet was closed

A receive that completed while the wallet was closed is one it can never
witness itself, so once the wallet is usable syncLnurlActivity pulls the
payments of the identity's receiver at the configured lnurl-server into
the lnurl payment store. It is not awaited and resolves to zero with no
server or no owned address, so an unreachable server costs the activity
view its labels, never the wallet its startup.

A VTXO or UTXO update pulls again about 3s and 20s later, since the
server records a payment as it settles and can trail the coin, and the
history reloads whenever a pull wrote something. Locking or resetting
cancels pending pulls. Writes stop once the init session aborts, and a
reset waits out the writes already in flight before it clears the store,
so a late sync cannot write the previous wallet's records back.

Split out of #1000.

* fix(lnurl): skip the post-sync reload once the init session is aborted

A sync that wrote records before a lock or reset could still reload the
wallet afterwards. reloadAfterSync now checks the init session's signal,
so neither the startup sync nor a payment-triggered resync reloads a
wallet that was locked or reset in the meantime.

* refactor(activity): drop the per-caller write tracker for the store's own

inFlightWrites only saw the writes syncLnurlActivity wrapped, so the
claim-triggered sync() calls in receive/lnurlRail.ts — fire-and-forget on
the shared sync store — were never in it, and a reset that waited on
lnurlSyncWritesSettled could still clear ahead of them. The repository now
gates and tracks every write itself, so this tracker only duplicated it for
the one caller it could see; clearLnurlPaymentsForReset replaces the export.

The signal check stays: it stops this module's own sync on a lock, where
nothing closes the store. Its test for waiting out an in-flight write moves
to the repository spec, which is where the tracker now lives.

* fix(lnurl): forward readWatermark through the abort-aware store wrapper

The wrapper spread the store to keep readWatermark, which copies only
own properties: a PaymentSyncStore written as a class lost the method,
and the receiver's sync failed before pulling anything. All three
methods are now forwarded explicitly; the interface has no others.

* refactor: adopt client receive bootstrap and rail helpers

* fix: complete LNURL receive review follow-up

* fix(receive): retain Lightning when LNURL cannot be claimed

* docs(receive): say why a named receiver's panel shows no LNURL error

bootstrapReceiver returns a named receiver before it asks for capabilities, so capabilitiesError cannot accompany one, and the panel offers naming only while nameless. Answers the open Arkana item on #1081.

* refactor(receive): take the session LNURL, address list and sync signal from lnurl-client 0.8.0

The facade now names its own session LNURL and lists every address on its
domain, so the hook no longer derives the wallet id from the token itself or
builds a second client to filter the list. Claim error keys are typed
against the server's error codes. The activity sync hands its signal to
receiver.sync(), which checks it before each write, instead of wrapping the
store in a gate: a lock still stops writes, and the store passes through
unwrapped.

0.8.0 also runs a facade's claim, discovery and upgrade one at a time per
identity and server. Discovery under a new facade therefore waits for a
claim still in flight and then finds it, so the hook test that expected such
a claim to be dropped now expects the receiver to be held.

* test(receive): drop resolveLnurlRails tests the package already runs

The "consumer boundaries" block came over when the wallet's own rail
resolution moved into lnurl-client, and since then it has called the
package's resolveLnurlRails through a bare re-export, with no wallet code in
the path. Every case has an equivalent in the package's receive-rails
tests: picking the bitcoin option past token and disabled ones, refusing a
Lightning rail the options omit, checking option bounds before the
callback, and refusing a callback that answers for another option.

* feat(receive): token rails from the LNURL, behind an opt-in setting

With receiveViaLnurl and receiveViaTokens both on and an amount set,
Receive offers the receiver's LNURL token options (stablecoins a third
party swaps to Arkade BTC) beside its bitcoin rails. useLnurlTokenRails
lists the options that are up, verifiable, name the provider holding the
deposit and accept the amount, and quotes only the one picked, since a
quote is a real provider order: re-requested when the amount changes and
once it expires. A USD stablecoin quote outside 0.8x to 1.25x of what the
sats are worth at the wallet's own price is treated as a misquote. Chain
labels follow the BTCPay plugin's names.

A token is picked from a sheet with its logo and a chain badge
(@web3icons), which also replaces the Arkade mark in the QR centre. The
note under the QR says what to send and how long the quote holds; on a
phone it links the payment URI to the installed wallet. That URI is used
only when it parses as a transfer of the quoted amount, token and chain
to the quoted deposit (EIP-681 or Solana Pay), else the bare deposit.
Copy takes the deposit address, never the URI, and the copy sheet now
offers only the shown method's values; one value is copied outright.
The QR stage is height-capped so it sits above the buttons on a short
phone.

lnurl-client states a rail's bounds in millisats; extractError now says
"Amount must be between 10,000 and 100,000,000 sats" (errors.amountBetween).
The receiveViaTokens flag defaults off; its toggle ships with the
Settings page.

Reviewed as #1051 before it merged into #1000. Split out of #1000.

* fix(receive): offer only token options that state verifiable, and keep Copy off without a quote

A token option with no verifiable flag was offered; lnurl-client calls an
absent flag unknown, and lnurl-server always states it (true) for its
FixedFloat options, so only an explicit verifiable: true is offered now.

After a failed token quote the footer Copy stayed enabled but copied
nothing, since there is no deposit to copy. It is disabled until the
picked token has a quote.

* fix(receive): refuse payment URIs with repeated bound fields, and keep Share off without a quote

paysQuote read only the first value of each field it binds, so a URI that
named a second, conflicting recipient or amount passed while the QR kept
the whole URI, and a wallet reading the last value would pay elsewhere.
address, uint256, spl-token and amount must now appear exactly once; any
repeat falls back to the bare deposit address.

Share stayed enabled when the picked token had no quote. It is disabled
then, as Copy already is; the token-error test enables browser sharing so
the assertion can fail.

* test(receive): pin that Solana Pay URIs with a repeated field fall back

paysQuote refuses a URI naming a bound field twice, but only the EIP-681
fields were tested. A Solana Pay quote now has a control that keeps its
URI, plus a repeated spl-token and a repeated amount, each of which must
show the bare deposit address instead.

* fix(receive): expire a stablecoin quote by the clock, and regenerate it on request (#1085)

* fix(receive): expire a stablecoin quote by the clock, and regenerate it on request

Each token quote is a real provider order plus a solver swap, so
useLnurlTokenRails no longer places a new one on its own at expiresAt.
It marks the quote expired, stops exposing it, and offers regenerate();
a new quote is asked for only when the user taps. A sleeping phone holds
setTimeout back, so the quote also counts as expired once Date.now()
passes expiresAt, and a visibilitychange re-checks it on wake.

offers(sats, id) says whether an option would still be offered for an
amount, so a caller can drop a token pick before that amount lands.

The hook's tests hold the regenerate request and check that no quote,
old or new, is exposed while it is in flight. The Receive screen's
expired notice and its "Get a new quote" button come with the receive
redesign, which builds on this.

Split out of #1068.

* fix(receive): keep regenerate stable, and test which options an amount offers

regenerate was a new function every render, so a caller using it in an
effect or memo would re-run needlessly; it is memoised now. offers() had
no direct test: it is false before the payRequest arrives, for an unknown
or missing id, and for an amount out of the option's bounds or zero. The
cleanup's comment now says why the expiry mark is cleared as well.

* refactor(receive): use shared token quote normalization

* fix(lnurl): keep shared rail bounds readable in sats

* fix(receive): preserve keypad drafts across background updates

* fix: allow retrying token receive quotes

* refactor(receive): take token bounds, quotes and chain names from lnurl-client 0.8.0

tokenOptionAccepts checks an amount against an option's own bounds, and
requestTokenQuote asks for the quote, refuses an answer that is not a token
destination or that expires too soon, and normalizes the rest; the rails use
both instead of repeating them. chainName replaces chainLabels.ts, which
mirrored the same BTCPay chain directory. Its test goes too: lnurl-server
now checks every chain it offers has a name (test/ff-catalogue.test.ts), and
the package tests the fallback to the raw chain id.

The wallet keeps its own refusals on top: a deposit that needs a memo the QR
cannot carry, base units that are not a canonical positive integer, and a
quote far from what the amount is worth.

* feat(settings): a Lightning address page

Settings > Advanced gains Lightning address, listed only when an
lnurl-server is configured. It shows every address the wallet owns on
the server, the wallet LNURL included as an entry of its own, and the
server, and what a payer can send on each bitcoin rail in sats, as the
receiver's own payRequest advertises it (lnurlRailLimits: token options
are not rails of their own). A nameless receiver can be named here,
with a claim code for a reserved name too; Receive offers only a chosen
name or "Pick one for me".

The Receive toggles live here, both off by default: "Route every receive
through it" sets receiveViaLnurl, and, when the LNURL offers tokens,
"Accept tokens" sets receiveViaTokens, after a one-time explainer that a
third party holds the deposit. en/es.

Split out of #1000.

* fix(settings): show why the rail limits are missing, and drop a guessed server row

A failed payRequest on the Lightning address page was only logged, so
'What payers can send' silently stayed empty. The error now shows under
that heading.

The server row is built only when a server is configured, rather than
rendering server?.domain, and the receiveViaLnurl toggle handler is no
longer an async function with nothing to await.

* test(settings): cover the Lightning address page when the rail fails

With no owned address and a failing capabilities call, the rail fails;
the page now has a test that it shows the error and offers no naming.

* refactor(settings): keep Arkade and Bitcoin routing out of Lightning address

* refactor(settings): keep Arkade and Bitcoin routing out of Lightning address

* fix(settings): hide the Receive section when no token option is offered

The section's only control is the token switch, so a server advertising no token option left an orphaned "Receive" heading. Guard the whole section the way the limits section above it is guarded. Raised by Arkana on #1084.

* fix(settings): say why the Lightning address page cannot load

Two states left the page without a reason, both raised by CodeRabbit on
#1084:

- When the wallet's own addresses failed to load, no facade was ever
  built, so the rail stayed off and the page showed "Loading..." for good.
  It now shows the error.
- A nameless receiver whose domain lookup failed was ready with an error
  but no naming choices, and the error only rendered inside the hidden
  naming section. It now renders under the address when there is nothing
  to name.

* refactor(receive): stop re-exporting resolveLnurlRails, which nothing imports from here

* feat(receive): offer to pay with stablecoins, shown as overlapping Tether and USDC logos

The token rails the server offers are USD stablecoins, so the picker names them as such and shows the two most payers will recognise, Tether in front. The logos are aria-hidden: the button's accessible name stays its label.

* fix(send): keep an LNURL's own query when asking for its Ark address

fetchArkAddress appended '?method=ark' to the decoded payRequest URL, so an LNURL that already carries a query string (?id=abc) produced ?id=abc?method=ark and the server never saw the method. Set it through URLSearchParams instead. Raised by CodeRabbit.

* fix(wallet): keep the wallet live when a reset's LNURL purge fails

resetWallet stopped the status ping, the pending reload and the service-worker message listener before purging LNURL records. A rejected purge leaves the wallet intact, by design, but it then stopped updating balance and history until a reload. Only the LNURL writers need stopping before the purge: aborting the init session stops the history sync, and the resync is cancelled. The listeners now stop after the purge succeeds. Raised by CodeRabbit.

* fix(receive): explain a lapsed quote where its code was, and offer a way back

An expired or failed stablecoin quote left a blank square where the code had been, with a Try again button above the method tabs. That square now says the quote expired and not to send to the old address, or why there is no quote, with a Get a new quote button. A chosen stablecoin also gets a button beside it that goes back to the code shown before it; the tabs did this too, but with none of them lit after picking a stablecoin, nothing said so.

* test(receive): pin the failed-rail message and an expired quote's disabled actions

The unreachable-server test now also asserts the 'Lightning address unavailable' line that the failed rail renders, and the expired-quote test asserts that Copy and Share stay disabled. Both raised by Arkana.

* ui fix

* lint

* fix(send): take an LNURL rail's fee out of the amount when sending Max

Max set the amount to the whole balance and asked the LNURL rail to
deliver all of it, so any rail with a fee (the Lightning swap) quoted a
total above the balance and the sign screen refused with "Insufficient
funds, you just have N sats". Max now re-quotes for the balance less
the quoted fee, at most twice, and shows the amount that will arrive.
A typed amount is left as typed.

* fix(receive): stop requesting an LNURL invoice once the payment arrives

The payment listener writes the paid amount into recvInfo.satoshis before
it navigates to the success screen, and useLnurlRails asks for a new
invoice whenever that amount changes. So every receive requested one more
invoice, for the amount just received. On mainnet that left an unpaid
hold invoice at the solver each time: a 1381-sat quote at 05:31:25, right
after a 1381-sat payout.

The LNURL and token rails now request nothing once recvInfo.received is
set. A new receive starts from emptyRecvInfo, which clears the flag.

* fix(send): route an LNURL send when this tab's swap client failed to start

On the tab that holds the swap client, `sendRouter({ swapsOptional: true })`
awaited `driving()`, which rejects when the client's repository is unreadable.
The LNURL send then failed before quoting, even through the Arkade rail, which
needs no swap client. The optional path now builds its router without the
client in that case, as the tab that is not driving already does. The
non-optional router still refuses. Raised by CodeRabbit on #1084.

* feat(settings): claim a name from a sheet, with the claim code behind a link

Settings → Lightning address showed the whole naming form inline: a name
field, a claim code field and both buttons. Most users have no claim code, so
the page now offers Claim name and Pick one for me, and Claim name opens a
sheet. In the sheet the claim code stays behind a subtle "I have a claim
code" link, which reveals and focuses the field. The sheet closes once the
name lands.

Receive is unchanged: it never offers claim codes, so its inline form shows
no link.

* feat(settings): let the claim code link show and hide its field

The "I have a claim code" link now stays in place and toggles the claim code
field, also on servers where a chosen name needs a code. A code typed and
then hidden is not sent. The link reports its state through aria-expanded.

Adds a test that a refused claim keeps the sheet open with its reason
(Arkana).

* feat(lnurl): ask for the claim code first where a name needs one; copy the address from Receive

Claim sheet: on a server that offers claim codes but no `self` mode, a chosen
name cannot be claimed without a code. The sheet now asks for the code first,
above the name field, instead of hiding it behind the "I have a claim code"
link. Where the code is optional, the link still shows and hides the field.

Receive: the lightning address under the QR now shows only on the Unified and
Lightning views, which are the ones it pays, and tapping it copies it, the way
other copyable text in the wallet does.

* feat(lnurl): claim with a code alone, and with a code when already named

On @arkade-os/lnurl-client 0.9.0 and lnurl-server 0.6.0, a claim code can
carry its own name:

- On a server where a chosen name needs a code, the name field is now
  optional. A reserved name's code claims that name on its own. A code for any
  free name answers username_required, which the sheet explains: add a name
  and claim again.
- A wallet that already has a lightning address can still redeem a code. Its
  addresses list offers "I have a claim code", and the claim registers a
  further address, since an upgrade only renames a nameless one. The sheet
  closes once the address changes and stays open with the reason when a claim
  is refused.

The client bump is otherwise a drop-in: 0.9.0 adds registered methods and
receive amounts, which the wallet does not use, and a facade given no
methods never touches them.

* feat(lnurl): choose the primary lightning address, and bind a claim that failed half way

On @arkade-os/lnurl-client 0.9.1, whose owned({ handle }) returns a given
active address:

- Settings → Lightning address lists a "Primary address" picker when the
  wallet owns more than one active address. The choice is saved in the
  config as lnurlPrimary, and both Settings and Receive pass it to
  owned({ handle }), so Receive uses it straight away and after a restart.
  A new choice switches the receiver in place, without reloading the rail.
- An address claimed with a code by an already named wallet becomes the
  primary, so Receive no longer falls back to the older one (CodeRabbit).
- A claim can register its address and then fail to bind the identity,
  leaving the address with no Arkade destination. After a failed claim, the
  rail now runs a best-effort owned({ refresh: true }), which binds whatever
  was left unbound (CodeRabbit).
- The username_required test goes on to add a name and claim (Arkana).

The picker hides while the claim sheet is open, because Select reads arrow
keys page-wide and the claim code field would feed it.

* fix(lnurl): never offer a random name to a wallet that already holds one

The rail can hold a nameless receiver while the identity owns a named
address too: owned() picks the session address first, and the user can
pick the nameless LNURL as primary. Settings and Receive then treated the
wallet as unnamed and offered "Pick one for me".

The rail now reports ownsName: the receiver's own name, or, when the
receiver is nameless, any active named address in the identity's list,
which it reads once. Both screens drop the random choice while it is true.
Choosing a name, or claiming one with a code, stays available.

* fix(i18n): spell out the claim error strings for the unused-key check

Master's #1107 fails when a translation key is not referenced by a literal
t('...') call. The claim error messages were reached through a code-to-key
map and a dynamic t(key), so six used keys read as unused. They are now
literal t() calls in a code-to-message map; the messages are unchanged.

* fix(lnurl): adopt the address a failed claim's refresh binds

After a claim that registered its address but failed to bind it, the
background owned({ refresh: true }) bound the address, but its result was
dropped. A first-time claimer stayed on the error until they left the
screen. A wallet that had no address when it claimed now adopts the one the
refresh finds and clears the error. A wallet that already had one keeps it
(Arkana).

---------

Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
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.

2 participants