Skip to content

feat: Add decodeLightningInvoice to Keymaster#146

Merged
macterra merged 5 commits intomainfrom
145-decode-lightning-invoice
Mar 2, 2026
Merged

feat: Add decodeLightningInvoice to Keymaster#146
macterra merged 5 commits intomainfrom
145-decode-lightning-invoice

Conversation

@macterra
Copy link
Collaborator

@macterra macterra commented Mar 2, 2026

Summary

  • Add decodeLightningInvoice() method to Keymaster class using light-bolt11-decoder for local BOLT11 decoding
  • Add POST /api/v1/lightning/decode API endpoint; KeymasterClient calls the API like all other methods
  • Add lightning-decode CLI command
  • Add 6 unit tests using BOLT11 spec test vectors (coffee invoice, donation invoice)
  • Add 14 client API tests covering all 7 lightning endpoints (success + error for each)
  • Fix pre-existing no-throw-literal lint issue in drawbridge-client.ts
  • Sync Python SDK with JS client: add 26 missing methods (lightning, nostr, assets, polls, wallet, DID update)

Closes #145

Python SDK methods added

Group Methods
Lightning add_lightning, remove_lightning, get_lightning_balance, create_lightning_invoice, pay_lightning_invoice, check_lightning_payment, decode_lightning_invoice
Nostr add_nostr, remove_nostr, export_nsec, sign_nostr_event
Assets create_asset, list_assets, clone_asset, merge_data, transfer_asset
Polls send_poll, send_ballot, view_ballot, add_poll_voter, remove_poll_voter, list_poll_voters
Wallet change_passphrase, export_encrypted_wallet
DID update_did

Test plan

  • All 29 lightning unit tests pass (tests/keymaster/lightning.test.ts)
  • All 238 client tests pass (tests/keymaster/client.test.ts)
  • keymaster lightning-decode <bolt11> decodes invoices correctly (verified on live invoice)
  • Lint clean
  • OpenAPI spec regenerated with correct paths

🤖 Generated with Claude Code

macterra and others added 4 commits March 1, 2026 22:29
Add BOLT11 invoice decoding so users can inspect Lightning invoices
before paying. Includes Keymaster method, API endpoint, CLI command,
and full test coverage using BOLT11 spec test vectors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 26 methods to bring the Python SDK in sync with the JS client:
- Lightning: add, remove, balance, invoice, pay, check, decode
- Nostr: add, remove, export_nsec, sign_event
- Assets: create, list, clone, merge_data, transfer
- Polls: send_poll, send_ballot, view_ballot, add/remove/list voters
- Wallet: change_passphrase, export_encrypted_wallet
- DID: update_did

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@macterra macterra requested a review from Copilot March 2, 2026 03:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

packages/gatekeeper/src/drawbridge-client.ts:20

  • throwError now throws a generic Error for 404s (and a raw string for non-HTTP errors). This changes the error shape compared to the previous { type, error } object and to the rest of the codebase where callers often rely on structured Archon errors with a .type (e.g. LightningUnavailableError.type). Consider throwing new LightningUnavailableError('Server does not support Lightning') (from @didcid/common/errors) for the 404 case, and throwing error (or new Error(...)) instead of error.message for the non-response case to keep errors consistently Error-like/typed.
function throwError(error: any): never {
    if (error.response) {
        if (error.response.status === 404) {
            throw new Error('Lightning service unavailable: Server does not support Lightning');
        }
        throw error.response.data;
    }
    throw error.message;
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Make decodeLightningInvoice consistently async (Promise<T> interface)
- Fix Swagger path annotation: /api/v1/lightning/decode -> /lightning/decode
- Regenerate OpenAPI spec with corrected path
- Update lightning decode unit tests to await async method

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@macterra macterra merged commit 2ed4139 into main Mar 2, 2026
13 checks passed
@macterra macterra deleted the 145-decode-lightning-invoice branch March 2, 2026 16:34
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.

Add decodeLightningInvoice to Keymaster

2 participants