Skip to content

Commit 0a8282e

Browse files
authored
Merge pull request #170 from getAlby/fix/lookup-invoice
fix: lookup invoice does not return preimage
2 parents 978530f + 832e006 commit 0a8282e

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@getalby/sdk",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"description": "The SDK to integrate with Nostr Wallet Connect and the Alby API",
55
"repository": "https://github.com/getAlby/js-sdk.git",
66
"bugs": "https://github.com/getAlby/js-sdk/issues",
@@ -48,7 +48,7 @@
4848
"@types/node": "^20.8.6",
4949
"@typescript-eslint/eslint-plugin": "^6.3.0",
5050
"@typescript-eslint/parser": "^6.3.0",
51-
"@webbtc/webln-types": "^2.0.1",
51+
"@webbtc/webln-types": "^3.0.0",
5252
"browserify": "^17.0.0",
5353
"eslint": "^8.46.0",
5454
"eslint-config-prettier": "^9.0.0",

src/webln/NostrWeblnProvider.ts

+23-16
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,18 @@ const NWCs: Record<string, NostrWebLNOptions> = {
3636
},
3737
};
3838

39-
// TODO: move to webln-types package
40-
export interface ListTransactionsArgs {
39+
// TODO: review fields (replace with camelCase) and consider move to webln-types package
40+
export type Transaction = Nip47Transaction;
41+
42+
// TODO: consider moving to webln-types package
43+
export type ListTransactionsResponse = {
44+
transactions: Transaction[];
45+
};
46+
47+
// TODO: consider moving to webln-types package
48+
export type ListTransactionsArgs = Nip47ListTransactionsArgs;
49+
50+
interface Nip47ListTransactionsArgs {
4151
from?: number;
4252
until?: number;
4353
limit?: number;
@@ -46,8 +56,11 @@ export interface ListTransactionsArgs {
4656
type?: "incoming" | "outgoing";
4757
}
4858

49-
// TODO: move to webln-types package
50-
export interface Transaction {
59+
type Nip47ListTransactionsResponse = {
60+
transactions: Nip47Transaction[];
61+
};
62+
63+
type Nip47Transaction = {
5164
type: string;
5265
invoice: string;
5366
description: string;
@@ -60,12 +73,7 @@ export interface Transaction {
6073
created_at: number;
6174
expires_at: number;
6275
metadata?: Record<string, unknown>;
63-
}
64-
65-
// TODO: move to webln-types package
66-
export interface ListTransactionsResponse {
67-
transactions: Transaction[];
68-
}
76+
};
6977

7078
interface NostrWebLNOptions {
7179
authorizationUrl?: string; // the URL to the NWC interface for the user to confirm the session
@@ -89,11 +97,6 @@ type Nip47GetInfoResponse = {
8997
methods: string[];
9098
};
9199

92-
type Nip47ListTransactionsResponse = {
93-
transactions: Nip47Transaction[];
94-
};
95-
type Nip47Transaction = Transaction;
96-
97100
type Nip47PayResponse = {
98101
preimage: string;
99102
};
@@ -392,9 +395,13 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
392395

393396
return this.executeNip47Request<LookupInvoiceResponse, Nip47Transaction>(
394397
"lookup_invoice",
395-
args,
398+
{
399+
invoice: args.paymentRequest,
400+
payment_hash: args.paymentHash,
401+
},
396402
(result) => !!result.invoice,
397403
(result) => ({
404+
preimage: result.preimage,
398405
paymentRequest: result.invoice,
399406
paid: !!result.settled_at,
400407
}),

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -2211,10 +2211,10 @@
22112211
"@typescript-eslint/types" "6.4.0"
22122212
eslint-visitor-keys "^3.4.1"
22132213

2214-
"@webbtc/webln-types@^2.0.1":
2215-
version "2.0.1"
2216-
resolved "https://registry.yarnpkg.com/@webbtc/webln-types/-/webln-types-2.0.1.tgz#760756e2a50e63392c8b3d129b59d172cd11d5dc"
2217-
integrity sha512-magyMAiN8u7PsECuj7PfFsStMne30E3QiyNfurL4mTTHse3lmG2Pkh3hDv3jh+D3PTWMfCgv1WFUKVmEgKbBkA==
2214+
"@webbtc/webln-types@^3.0.0":
2215+
version "3.0.0"
2216+
resolved "https://registry.yarnpkg.com/@webbtc/webln-types/-/webln-types-3.0.0.tgz#448b2138423865087ba8859e9e6430fc2463b864"
2217+
integrity sha512-aXfTHLKz5lysd+6xTeWl+qHNh/p3qVYbeLo+yDN5cUDmhie2ZoGvkppfWxzbGkcFBzb6dJyQ2/i2cbmDHas+zQ==
22182218

22192219
JSONStream@^1.0.3, JSONStream@^1.3.5:
22202220
version "1.3.5"

0 commit comments

Comments
 (0)