fix(cli): bump SDK pin past #397 + treat invoice amounts as human units#35
Merged
Merged
Conversation
== Two fixes, one PR ==
(1) ci: bump SPHERE_SDK_SHA from 3f3dadf → d949844 (current sphere-sdk
main tip), which includes:
- 903fc80 fix(accounting)(#397): route invoice delivery through
the token pipeline (the architectural fix)
- 541b448 feat(accounting)(#401): wire publishUxfBundle into
OUTBOX/SENT + recovery exhaustion event
- 85700b6 Merge PR #400 (#397)
- d949844 Merge PR #402 (#401)
Pre-bump symptom: `manual-test-accounting-roundtrip.sh` failed at
Alice's "wait for invoice to be ingested" step. Bob's `invoice
deliver` reported `sent: 1, failed: 0` but Alice's `invoice list`
showed "No invoices found" forever, because the old SDK still used
the bespoke `invoice_delivery:` NIP-17 DM and the soak script (and
the matching receiver decoder) was authored against the new
TOKEN_TRANSFER (kind 31113) pipeline.
(2) cli(legacy-cli.ts): make invoice-create and invoice-return treat
the `--asset <amount> <coin>` amount as HUMAN units (e.g.
"7 UCT" = 7 whole UCT, "0.5 BTC" = 0.5 BTC), matching what
`payments send 7 UCT` does. Convert to smallest-unit integers
via toSmallestUnit(amount, decimals) before handing off to the
SDK (AccountingModule treats the amount as a raw atom count with
decimals: 0).
Closes the cross-command inconsistency that PR #32 set out to
eliminate but missed at rebase time. The accounting soak's
`--asset 7 UCT` now produces a 7-UCT invoice instead of a
7-atom invoice; the assertion that bob receives exactly
7000000000000000000 atoms passes.
== Verification ==
- npx tsc --noEmit: clean
- npx vitest run: 126/126 pass
- manual-test-accounting-roundtrip.sh (real testnet): ALL GREEN
(bob +7 UCT, alice -7 UCT, invoice COVERED/CLOSED)
- manual-test-roundtrip-391.sh and manual-test-full-recovery.sh
unaffected (they don't use --asset for invoice amounts)
This was referenced Jun 5, 2026
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.
Two related fixes surfaced by re-running the soak suite (
manual-test-{full-recovery,roundtrip-391,accounting-roundtrip}.sh) againstmainafter merging PR #33 (canonical UX) and PR #34 (integration/all-fixes rollup).(1) ci: bump pinned sphere-sdk SHA from
3f3dadf→d949844The previous pin (
3f3dadf) predates sphere-sdk PR #400 / #397, whichroutes invoice delivery through the standard TOKEN_TRANSFER pipeline
(Nostr kind 31113) instead of the bespoke
invoice_delivery:NIP-17 DM.Symptom against the old pin:
The new pin (
d949844) is sphere-sdk main and includes:903fc80fix(accounting)(#397): route invoice delivery through the token pipeline541b448feat(accounting)(#401): wire publishUxfBundle into OUTBOX/SENT85700b6Merge PR #400 (#397)d949844Merge PR #402 (#401)After bump, the receiver decoder recognises bob's invoice DM (because
it's just a TOKEN_TRANSFER of an
INVOICE_TOKEN_TYPE_HEXtoken), theexisting OUTBOX/SENT/at-least-once machinery handles it end-to-end,
and Alice's
invoice listsurfaces it within seconds.(2) cli: invoice-create + invoice-return amount in human units
Cross-command inconsistency that PR #32 (canonical UX) was supposed to
eliminate but missed at rebase time. Before this PR:
After this PR, all three accept human units (the same shape
payments sendalready did). Conversion is done viatoSmallestUnit(amount, decimals)wheredecimalscomes fromresolveCoin(symbol). TheSDK's
AccountingModule.createInvoicecontinues to treat the amountas a raw atom count (
decimals: 0) — the conversion happens entirelyin the CLI, matching the
payments sendpattern.Bonus:
0.5 BTCand other fractional inputs now work for invoices.invoice-pay --amountis intentionally NOT changed in this PR — itneeds an additional SDK lookup for the invoice's coin/decimals, which
warrants its own change. The soak doesn't exercise
--amountso thisis non-blocking. (TODO follow-up.)
Verification
The other two soaks (
roundtrip-391,full-recovery) are unaffectedby either change — they don't pass
--asset <amount> <coin>for aninvoice amount.
Risk
was passing pre-converted atom counts to
invoice create --asset/
invoice return --asset. The fix matchespayments send'sestablished convention, so anyone already passing
7 UCTwassilently creating an invoice for 7 atoms (almost certainly a bug,
not intended behavior). Documented in the commit message + the
COMMAND_HELP help blocks.