Support firma usernames for firma token sends in Cashtab
Details
- Reviewers
Fabien - Group Reviewers
Restricted Project - Commits
- rABCfdb602887973: [Cashtab] Resolve Firma usernames on send
npm test
Diff Detail
- Repository
- rABC Bitcoin ABC
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) Find some code, review it up, all day long you'll have good luck!
────────────────────────────────────────────────────────────────────────
minor [Functional Correctness] → ]8;;vscode://file//work/cashtab/src/components/Send/SendXec.tsx:789cashtab/src/components/Send/SendXec.tsx:789-791]8;; Track the resolved Firma handle per recipient form. resolvedFirmaHandle is one state value, but the XEC form (formData.address) and the token forms (tokenFormData.address) hold independent recipients. Both inputs write to the same handle. Result: after the user resolves @alice in XEC mode and then edits the token recipient, the shared handle is overwritten. confirmSendLabel at Line 3086 and the resolved-recipient label then describe one form with the other form's handle, or lose the handle. Use a separate handle state for the token form, or clear resolvedFirmaHandle when isTokenMode changes. Also applies to: 3425-3430, 3507-3510, 3926-3929
────────────────────────────────────────────────────────────────────────
major [Security & Privacy]
→ ]8;;vscode://file//work/cashtab/src/components/Send/SendRecipientInput.tsx:255cashtab/src/components/Send/SendRecipientInput.tsx:255-262]8;;
Restrict implicit Patron lookups to reduce data leakage.
looksLikeFirmaUsernameInput accepts any 1–21 character lowercase
alphanumeric string. Every debounced keystroke that matches then sends
that string to patron.firma.cash. A user who types a contact name, a
wallet name, or a private label sends that text to a third-party service,
although the user did not request a username lookup.
Narrow the trigger. One option: query Patron only when the input is
explicit (@…), or only when searchSendRecipients returns no local
match.
🔒️ Proposed narrowing
const firmaSearch = useFirmaUsernameSearch({
query,
enabled:
isEditing &&
!disabled &&
- (looksLikeFirmaUsernameInput(query) ||
- isExplicitFirmaUsernameInput(query)),
+ (isExplicitFirmaUsernameInput(query) ||
+ (looksLikeFirmaUsernameInput(query) &&
+ searchSendRecipients(query, contactList, wallets).length ===
+ 0)),
});────────────────────────────────────────────────────────────────────────
minor [Maintainability & Code Quality] → ]8;;vscode://file//work/cashtab/src/components/Send/__tests__/SendXec.test.js:75cashtab/src/components/Send/__tests__/SendXec.test.js:75-85]8;; Set an explicit jest-when fallback for global.fetch. when(fetch).calledWith(...) does not provide a reliable fallback to the earlier implementation; unmatched calls can return undefined, causing resolveFirmaHandleToAddress to read .ok from undefined. Register defaultImplementation and reject unexpected URLs instead of returning undefined.
────────────────────────────────────────
Review complete
3 findings ✔
Major 1
Minor 2
14 files reviewed:
- cashtab/src/components/App/__tests__/App.test.js
- cashtab/src/components/Configure/__tests__/Configure.test.tsx
- cashtab/src/components/Send/SendRecipientInput.tsx
- cashtab/src/components/Send/SendXec.tsx
- cashtab/src/components/Send/__tests__/SendByUrlParams.test.js
- cashtab/src/components/Send/__tests__/SendXec.test.js
- cashtab/src/components/Send/helpers/index.ts
- cashtab/src/components/Send/helpers/recipientResolve.test.ts
- cashtab/src/components/Send/helpers/recipientResolve.ts
- cashtab/src/config/firma.ts
... and 4 more files
────────────────────────────────────────
Print all AI prompts: coderabbit review --show-prompts
Purple Firma logo for username (keep green token icon). Split XEC/token handle state. Lookup Patron only for @username or when no local match. Fetch mock throws on unexpected URLs.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) This code is a locked door with the key taped to it.
────────────────────────────────────────────────────────────────────────
major [Functional Correctness]
→ ]8;;vscode://file//work/cashtab/src/components/Send/SendXec.tsx:789cashtab/src/components/Send/SendXec.tsx:789-800]8;;
Bind the Firma handle to the resolved recipient address.
A handle is stored by the current mode, not by recipient identity. For
@alice?token_id=..., resolution starts in XEC mode, so
setResolvedXecFirmaHandle runs. handleAddressChange then switches to
token mode. The token recipient uses resolvedTokenFirmaHandle, so the
resolved display and confirmation omit @alice.
A later parent-driven address prefill can also retain a handle for a
different recipient. Store { handle, address } metadata, pass the
resolved address through onFirmaHandleChange, and use the handle only
when it matches the active recipient address. Add a regression test for a
Firma username with a token BIP21 suffix.────────────────────────────────────────
Review complete
1 finding ✔
Major 1
16 files reviewed:
- cashtab/src/assets/firma-logo.png
- cashtab/src/components/App/__tests__/App.test.js
- cashtab/src/components/Common/CustomIcons.tsx
- cashtab/src/components/Configure/__tests__/Configure.test.tsx
- cashtab/src/components/Send/SendRecipientInput.tsx
- cashtab/src/components/Send/SendXec.tsx
- cashtab/src/components/Send/__tests__/SendByUrlParams.test.js
- cashtab/src/components/Send/__tests__/SendXec.test.js
- cashtab/src/components/Send/helpers/index.ts
- cashtab/src/components/Send/helpers/recipientResolve.test.ts
... and 6 more files
────────────────────────────────────────
Print all AI prompts: coderabbit review --show-prompts
Bind the resolved Firma handle to its cashaddr so @username?token_id=… still shows @handle after switching to token send.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) Brace yourself. Winter is coming...for your bugs.
────────────────────────────────────────
Review complete
No findings ✔
16 files reviewed:
- cashtab/src/assets/firma-logo.png
- cashtab/src/components/App/__tests__/App.test.js
- cashtab/src/components/Common/CustomIcons.tsx
- cashtab/src/components/Configure/__tests__/Configure.test.tsx
- cashtab/src/components/Send/SendRecipientInput.tsx
- cashtab/src/components/Send/SendXec.tsx
- cashtab/src/components/Send/__tests__/SendByUrlParams.test.js
- cashtab/src/components/Send/__tests__/SendXec.test.js
- cashtab/src/components/Send/helpers/index.ts
- cashtab/src/components/Send/helpers/recipientResolve.test.ts
... and 6 more files
────────────────────────────────────────
Only resolve Firma usernames when sending FIRMA, fCHF, or fEUR. XEC and other tokens stay address/contact only.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) torvalds@linux:~$ git review
────────────────────────────────────────────────────────────────────────
major [Stability & Availability] → ]8;;vscode://file//work/cashtab/src/services/firmaHandleService.ts:17cashtab/src/services/firmaHandleService.ts:17-22]8;; Bound the Patron lookup request. Pass a service-level timeout AbortSignal, or combine it with a caller-owned signal. Without one, fetch can remain pending indefinitely and block recipient resolution.
────────────────────────────────────────────────────────────────────────
major [Data Integrity & Integration] → ]8;;vscode://file//work/cashtab/src/services/__tests__/firmaHandleService.test.ts:26cashtab/src/services/__tests__/firmaHandleService.test.ts:26-29]8;; Remove the Content-Type header from the GET lookup. application/json is not CORS-safelisted. A cross-origin GET with this header triggers a preflight request. Remove the header from the service and update this assertion. Use Accept: application/json if needed.
────────────────────────────────────────────────────────────────────────
major [Stability & Availability] → ]8;;vscode://file//work/cashtab/src/hooks/useFirmaUsernameSearch.ts:84cashtab/src/hooks/useFirmaUsernameSearch.ts:84-117]8;; Abort the Patron lookup and bound it with a timeout. resolveFirmaHandleToAddress runs without an AbortSignal. If Patron does not respond, the hook remains in status: 'checking' indefinitely. A superseded request also continues until completion after cleanup discards its result. Pass an AbortSignal to resolveFirmaHandleToAddress, abort it during cleanup, and abort it after a manually managed timeout. The browser targets support AbortController; do not rely on AbortSignal.timeout, which is not available in the oldest supported browsers. Keep Jest fetch tests on compatible mocks because JSDOM provides AbortController but not fetch.
────────────────────────────────────────
Review complete
3 findings ✔
Major 3
14 files reviewed:
- cashtab/src/assets/firma-logo.png
- cashtab/src/components/Common/CustomIcons.tsx
- cashtab/src/components/Send/SendRecipientInput.tsx
- cashtab/src/components/Send/SendXec.tsx
- cashtab/src/components/Send/__tests__/SendXec.test.js
- cashtab/src/components/Send/helpers/index.ts
- cashtab/src/components/Send/helpers/recipientResolve.test.ts
- cashtab/src/components/Send/helpers/recipientResolve.ts
- cashtab/src/config/firma.test.ts
- cashtab/src/config/firma.ts
... and 4 more files
────────────────────────────────────────
Print all AI prompts: coderabbit review --show-prompts
Drop Content-Type on Patron GET (skip CORS preflight). Time out lookups at 8s and abort in-flight requests when the hook cleans up.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) Carpe Debug. Seize the bugs.
────────────────────────────────────────
Review complete
No findings ✔
14 files reviewed:
- cashtab/src/assets/firma-logo.png
- cashtab/src/components/Common/CustomIcons.tsx
- cashtab/src/components/Send/SendRecipientInput.tsx
- cashtab/src/components/Send/SendXec.tsx
- cashtab/src/components/Send/__tests__/SendXec.test.js
- cashtab/src/components/Send/helpers/index.ts
- cashtab/src/components/Send/helpers/recipientResolve.test.ts
- cashtab/src/components/Send/helpers/recipientResolve.ts
- cashtab/src/config/firma.test.ts
- cashtab/src/config/firma.ts
... and 4 more files
────────────────────────────────────────
| cashtab/src/components/Send/helpers/recipientResolve.ts | ||
|---|---|---|
| 137 ↗ | (On Diff #60919) | I suppose it requires a single @ ? At least that's what the above function assumes. Might be better to also assert this |
| cashtab/src/config/firma.ts | ||
| 5 ↗ | (On Diff #60919) | that's weird, consider rearranging the files so it's not separated |
Require a single leading @ for explicit usernames. Keep FIRMA/fCHF/fEUR token ids next to FIRMA in constants/tokens.ts so config/firma.ts does not import constants.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) If you don't make mistakes, you're not working on hard enough problems. - Frank Wilczek
────────────────────────────────────────
Review complete
No findings ✔
14 files reviewed:
- cashtab/src/assets/firma-logo.png
- cashtab/src/components/Common/CustomIcons.tsx
- cashtab/src/components/Send/SendRecipientInput.tsx
- cashtab/src/components/Send/SendXec.tsx
- cashtab/src/components/Send/__tests__/SendXec.test.js
- cashtab/src/components/Send/helpers/index.ts
- cashtab/src/components/Send/helpers/recipientResolve.test.ts
- cashtab/src/components/Send/helpers/recipientResolve.ts
- cashtab/src/config/firma.ts
- cashtab/src/constants/tokens.ts
... and 4 more files
────────────────────────────────────────