fix(invoice): accept @nametag as --target#17
Open
vrogojin wants to merge 2 commits into
Open
Conversation
`sphere invoice create --target @bob-tag --asset "1000000 UCT"` now resolves the @NameTag (or chain pubkey, or alpha1 address) to the canonical `DIRECT://` address before calling `AccountingModule.create Invoice`. Symmetric with `payments send --recipient @nametag` which already accepts these forms. Why resolve at the CLI layer: - `AccountingModule.createInvoice` validates `target.address.starts With('DIRECT://')` (modules/accounting/AccountingModule.ts:906) and throws `INVOICE_INVALID_ADDRESS` otherwise. This is correct SDK behaviour — invoice terms cryptographically bind the recipient identity, so the canonical DIRECT:// form is what gets signed and shipped. - The CLI is the right layer to translate user-facing identifiers (@NameTag, chain pubkey, alpha1) into canonical addresses. The same pattern is already in `dm-history` (legacy-cli.ts:3108) and in `payments send --recipient`. - Resolution happens once at create-time; the resolved DIRECT:// address is what's persisted in the invoice's signed terms, so a later nametag rename does NOT invalidate the invoice (which is the correct semantic). Before this fix: $ sphere invoice create --target @bob-tag --asset "1000000 UCT" Error: Invalid target address: must be DIRECT:// format After: $ sphere invoice create --target @bob-tag --asset "1000000 UCT" Invoice created: { ... "address": "DIRECT://0000..." ... } Validated against live testnet during issue-223 cross-process manual recovery test (see sphere-sdk's manual-test-full-recovery.sh + walkthrough doc on PR #222 / branch docs/issue-218-full-recovery-manual-test). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6 tasks
…gration/all-fixes tip The previous pinned SHA `86468103a` was the tip of `refactor/extract-cli-to-sphere-cli` at the time the workflow was added. That branch has since been deleted from the public sphere-sdk repo. The commit still exists in the GitHub repo's object database but is no longer reachable via any branch tip, so a default `git clone` does not fetch it and the subsequent `git checkout --detach $SHA` fails with `fatal: unable to read tree`. PR #17's CI started failing for this reason — symptom unrelated to PR contents. Fix: re-pin to `02cb4550fac` (the tip of `integration/all-fixes` after PR #225, the cross-process UXF delivery fix). That branch contains the same CLI-consumed type exports (`CreateInvoiceRequest`, `PayInvoice Params`, `InvoiceRequestedAsset`, encrypt/decrypt helpers, ...) that the original pin provided. Verified locally: grep -E 'CreateInvoiceRequest|PayInvoiceParams|InvoiceRequestedAsset' \ sphere-sdk/index.ts CreateInvoiceRequest, InvoiceRequestedAsset, PayInvoiceParams, Defense-in-depth: add `git fetch origin "$SPHERE_SDK_SHA" || true` before checkout so the workflow keeps working when integration/all- fixes advances past this commit (the SHA stays pinned for supply-chain integrity, but the explicit fetch picks it up via the object database even if it's no longer on a branch tip). Both `ci.yml` and `integration-nightly.yml` updated together so a nightly run stays hermetic with PR CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
sphere invoice create --target @bob-tag --asset "1000000 UCT"now resolves the@nametag(and chain pubkey /alpha1...) to the canonicalDIRECT://address before callingAccountingModule.createInvoice. Symmetric withpayments send --recipient @nametagwhich already accepts these forms.Why resolve at the CLI layer
AccountingModule.createInvoicevalidatestarget.address.startsWith('DIRECT://')and throwsINVOICE_INVALID_ADDRESSotherwise. This is correct SDK behaviour — invoice terms cryptographically bind the recipient identity, so the canonical DIRECT:// form is what gets signed and shipped.dm-historyandpayments send --recipient.Before / After
Before:
After:
Test plan
manual-test-full-recovery.sh(sphere-sdk PR #222) — §C.1 invoice create now succeeds with@bob-...target; resolved address appears in the signed invoice terms.manual-test-full-recovery.shto confirm §C.1 passes end-to-end.Related