Skip to content

feat(gl-sdk): add parse_input() for BOLT11 invoices and node IDs#692

Open
angelix wants to merge 2 commits intomainfrom
ave-check-input
Open

feat(gl-sdk): add parse_input() for BOLT11 invoices and node IDs#692
angelix wants to merge 2 commits intomainfrom
ave-check-input

Conversation

@angelix
Copy link
Copy Markdown
Contributor

@angelix angelix commented Apr 4, 2026

Summary

  • Add parse_input() free function that identifies and parses BOLT11 invoices or Lightning node public keys from arbitrary string input
  • Works offline — no node connection needed
  • Strips lightning: / LIGHTNING: prefixes automatically
  • Returns InputType::Bolt11 { invoice: ParsedInvoice } with payee pubkey, payment hash, description, amount, expiry, timestamp
  • Returns InputType::NodeId for valid 33-byte compressed pubkeys (02/03 prefix)
  • No new dependencies — uses existing lightning-invoice and hex crates

Test plan

  • Parse valid BOLT11 invoice → returns Bolt11 variant with correct fields
  • Parse BOLT11 with lightning: prefix → same result
  • Parse valid 66-char hex node ID → returns NodeId variant
  • Parse garbage / empty string → returns error
  • Parse wrong-prefix pubkey (04) → returns error
  • cargo build -p gl-sdk and cargo build -p gl-sdk-node compile clean

angelix added 2 commits April 4, 2026 13:22
Free function that identifies and parses BOLT11 invoices or node
public keys from arbitrary string input. Works offline, no node
connection needed. Strips lightning: prefix automatically.

Returns InputType::Bolt11 { invoice: ParsedInvoice } with payee
pubkey, payment hash, description, amount, expiry, and timestamp.
Returns InputType::NodeId for valid 33-byte compressed pubkeys.

Includes Python and Kotlin tests.
Documents parameters (destination, amount_or_all formats), return
types, and address formats. Notes that onchain_send broadcasts
immediately.
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.

1 participant