Skip to content

feat(nipcash,nipcw): add bech32 encoding for Hub connection strings - #16

Merged
naliyi merged 3 commits into
ohstr:mainfrom
flokiorg:feat/hub-connection-bech32
Sep 7, 2026
Merged

feat(nipcash,nipcw): add bech32 encoding for Hub connection strings#16
naliyi merged 3 commits into
ohstr:mainfrom
flokiorg:feat/hub-connection-bech32

Conversation

@git-nostr

Copy link
Copy Markdown
Contributor

Adds EncodeHubConnection/DecodeHubConnection to nip47, an alternative bech32 encoding of the same pairing data BuildPairingURI/ParsePairingURI already carry — for use by anything exposing a special-purpose Hub-style NWC connection (a Cash Hub, a Circle Wallet Hub, etc.) that wants a single recognizable, copy-paste-safe string instead of a raw nostr+walletconnect:// URI.

  • Same TLV/bech32 mechanics as the existing cash-token-family format (nipcash.Token), reused via the public bech32 package rather than nipcash's own unexported helpers.
  • Fields: wallet pubkey, relay (repeatable), secret, and an optional human-readable label — the label lets an issuer embed a friendly name ("Ada's Family Circle") so a recipient can see what they're being handed before decoding/dialing it.
  • HRP is caller-supplied (same pattern as nipcash.Token.HRP), so this isn't tied to any one Hub kind.
  • 6 new unit tests: round-trip (with and without label), multiple HRPs, unknown-TLV-type-ignored (forward compatibility), and malformed-input rejection.

Test plan

  • go build ./...
  • go test ./nip47/...

EncodeHubConnection/DecodeHubConnection package a Cash Hub's or Circle
Wallet Hub's own connection (wallet pubkey, relay, secret, optional
label) as a cashhub1.../circlehub1... bech32 string, alongside the
existing PairingInfo/BuildPairingURI/ParsePairingURI. Same TLV/bech32
mechanics as the cash-token-family format, reused via the public
bech32 package rather than nipcash's own unexported helpers.
git-nostr added a commit to flokiorg/lokihub that referenced this pull request Sep 7, 2026
Consolidates 4 hand-rolled nostr+walletconnect:// URI builders
(api.CreateApp, GetCashWalletConnection, the circle-wallet controller,
cashwallet.Create) onto nmilat's own nip47.BuildPairingURI, which was
already a dependency but never actually called. Uses the resulting
single choke point to add the new bech32 token: CreateApp now returns
cashHubToken/circleHubToken alongside pairingUri for cash_hub/circle_hub
respectively, via nmilat's new nip47.EncodeHubConnection, using the
app's own Name as the token's label.

Temporarily depends on flokiorg/nmilat's feat/hub-connection-bech32
branch (ohstr/nmilat#16) for the new encoder; revert to a plain require
once a released nmilat version ships it.
cashhub1.../circlehub1... are NIP-CASH/NIP-CW concepts, not base
NIP-47 ones — move them into the packages that already own their own
protocol's wire formats (mirroring nipcash.Token's existing bech32
codec), instead of a shared nip47.HubConnection.

Each package's HRP is now fixed internally (EncodeCashHubConnection
always emits cashhub1..., EncodeCircleHubConnection always emits
circlehub1...) rather than caller-supplied, closing off a class of
mix-up (passing the wrong HRP for the kind of Hub) the previous,
generic design allowed. nipcash's version reuses its own existing
writeTLV/readTLV/decodeKeyHex directly, now that it's in the same
package; nipcw's duplicates the same small helpers locally, same
size/reasoning as nipcash's own token codec.
@git-nostr git-nostr changed the title feat(nip47): add bech32 encoding for Hub connection strings feat(nipcash,nipcw): add bech32 encoding for Hub connection strings Sep 7, 2026
@naliyi
naliyi merged commit 516e0f6 into ohstr:main Sep 7, 2026
3 checks passed
naliyi added a commit that referenced this pull request Sep 7, 2026
Covers the three merged-but-unreleased PRs since v0.2.7: the NWC client
NIP-44 fallback + CLOSED-message fixes (#14), the relay combined-kind
cursor fairness fix (#15), and the nipcash/nipcw Hub connection bech32
encoding (#16). PR #12 (README wording cleanup) is docs-only and not
user-facing, so it's omitted per house style.
naliyi added a commit that referenced this pull request Sep 7, 2026
changelog: add 0.2.8 entries for PRs #14, #15, #16
git-nostr added a commit to flokiorg/lokihub that referenced this pull request Sep 7, 2026
ohstr/nmilat#16 (cashhub1.../circlehub1... Hub connection codecs) is now
merged upstream and tagged as part of v0.2.8, so the temporary
replace pointing at the flokiorg/nmilat fork's pseudo-version is no
longer needed.
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