getAlby / js-sdk

JavaScript SDK for the Alby OAuth2 Wallet API and the Nostr Wallet Connect API.
https://npmjs.com/package/@getalby/sdk
63 stars 16 forks source link

feat: subscribe to NIP-47 notifications #217

Closed rolznz closed 6 months ago

rolznz commented 7 months ago

For https://github.com/getAlby/nostr-wallet-connect-next/pull/183

Also removes some unnecessary kind checks in other methods since they already use a filter which specifies the kind

Example output:

$ node examples/nwc/client/subscribe.js 
Waiting for notifications...
Got notification {
  result: {
    type: 'incoming',
    invoice: 'lnbc10n1pnqn99ydqafet5xgzrd35k2mn5ypjhsctdwpkx2np4qtuqfrmmrt9nf5fg4ahkraszktyl98u4zj54mp427kcztlyjdyts7pp5gkhls9e6aj8yjcjvsdylp03kl0g6rlewxyk2yv3gl6ktk9uhascssp5ndqrw7spngrgg5fnf4dud639ez5lkhxyuepzk6e5m2f4879jeexs9qyysgqcqpcxqyz5vqrzjq2w2zkkjagc80a0s2fxyex7zv6z5c99eljqmnnpaddywy3s27ylk2zkga9t8zhj93uqqqqlgqqqqqzsqygrzjqwh05slmksqfkgdyz2wst9fewjmah2amldg3jg2pqzqgvr723mslp4pgjtsk665zd5qqqqlgqqqqqzsqygrzjqvdnqyc82a9maxu6c7mee0shqr33u4z9z04wpdwhf96gxzpln8jcrapyqqqqqqqesuqqqqqqqqqqqqqq2qc7s06vhsry9rqpn5p9wfucgcv2cgy7vappy7hclnesekg45yfm3pwqslw7vs6zkedhu9n9kpqvpweykx270qy5ks7rnfm32kk84j8ngp4gvttg',
    description: 'NWC Client example',
    description_hash: '',
    preimage: 'be5c93a61acbc7b00a5e97d5445a8bbfc878c8d93ca0a19adea7b8ca1bb7060b',
    payment_hash: '45aff8173aec8e49624c8349f0be36fbd1a1ff2e312ca23228feacbb1797ec31',
    amount: 1000,
    fees_paid: 0,
    created_at: 1711903908,
    expires_at: 1711990308,
    settled_at: 1711903929
  },
  result_type: 'payment_received'
}

TODOs