feat: add nipcash + nipcw packages (NIP-CASH, NIP-CW client SDK) - #9
Merged
Conversation
New nipcash/nipcash-client and nipcw/nipcw-client packages let any nmilat-based app mint/hold/redeem/transfer/split/consolidate cash tokens or self-serve a Circle Wallet, without hand-rolling either protocol on top of raw nip47. Built on nipAZ/nipIC for Web-Identity recipients, reuses relay/client's NWCClient for transport. Defines kind 23198 (NIP-CASH's per-call proof) and kind 23199 (NIP-CW's), both deliberately distinct from NIP-IC's kind 35521. Also adds a relay regression test (case_tags_zero_at_subscribe_then_live) covering a kind+tag subscription whose filter matches nothing at subscribe time and only gains a match after EOSE -- the shape every NIP-47 request/response round trip has, since each proof/request event ID is freshly generated. Passes against current source; added after live-testing nipcash/client against a real deployment surfaced what turned out to be a stale relay binary (a month behind HEAD), not a current bug -- this closes the coverage gap that let it go unnoticed.
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
nipcash/nipcash/clientpackages implementing NIP-CASH (Cash Hub): mint, hold, redeem, transfer, split, and consolidate cash tokens (lokicash1.../satscash1...), built onnipAZ/nipICfor Web-Identity recipients andrelay/client.NWCClientfor transport. Defines kind 23198 (its own per-call proof, deliberately not NIP-IC's kind 35521).nipcw/nipcw/clientpackages implementing NIP-CW (Circle Wallet): self-servicecreate_circle_wallet. Defines kind 23199.case_tags_zero_at_subscribe_then_live(relay/store_test.go): a kind+tag subscription whose filter matches nothing at subscribe time, then gains exactly one live match after EOSE — the shape every NIP-47 request/response round trip has, since each proof/request event ID is freshly generated and can never have pre-existed. Passes against current source.Context on that last test
While live-testing
nipcash/clientagainst a real, independently-running deployment, every NWC call hung forever even though the wallet side had already published its reply. I isolated it to exactly the scenario the new test covers, then reproduced it in-process against currentmain— where it passes. The actual live deployment turned out to be running a relay binary built ~1 month before this branch's base commit, so the hang was a stale-deployment issue, not a defect in this code. The test is included anyway since that exact scenario (subscribe on a filter with zero current matches, then a live match arrives) had no prior coverage despite being NIP-47's normal shape.Test plan
go build ./...,go vet ./...,go test -race ./...— all greengofmt -l .clean,go mod tidyproduces no diffgolangci-lint run ./...(v2.13) — 0 issuesgovulncheck ./...— 0 vulnerabilities