Skip to content

Commit bc37f18

Browse files
committed
fix: map keysend custom records
1 parent 03a2503 commit bc37f18

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

examples/nwc/keysend.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@ const rl = readline.createInterface({ input, output });
1212
const nwcUrl =
1313
process.env.NWC_URL ||
1414
(await rl.question("Nostr Wallet Connect URL (nostr+walletconnect://...): "));
15-
const destination = await rl.question("Enter destination pubkey: ");
15+
const destination =
16+
(await rl.question("Enter destination pubkey: ")) ||
17+
"030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3";
1618
const amount = await rl.question("Enter amount: ");
1719
rl.close();
1820

1921
const webln = new providers.NostrWebLNProvider({
2022
nostrWalletConnectUrl: nwcUrl,
2123
});
2224
await webln.enable();
23-
const response = await webln.keysend({ amount, destination });
25+
const response = await webln.keysend({
26+
amount,
27+
destination,
28+
customRecords: {
29+
696969: "1KOZHzhLs2U7JIx3BmEY",
30+
},
31+
});
2432

2533
console.info(response);
2634

src/webln/NostrWeblnProvider.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,12 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
304304
{
305305
amount: +args.amount * 1000, // NIP-47 uses msat
306306
pubkey: args.destination,
307-
tlv_records: args.customRecords,
307+
tlv_records: args.customRecords
308+
? Object.entries(args.customRecords).map((v) => ({
309+
type: parseInt(v[0]),
310+
value: v[1],
311+
}))
312+
: [],
308313
// TODO: support optional preimage
309314
// preimage?: "123",
310315
},

0 commit comments

Comments
 (0)