Skip to content

Commit

Permalink
fix: map keysend custom records
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Dec 13, 2023
1 parent 03a2503 commit bc37f18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions examples/nwc/keysend.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ const rl = readline.createInterface({ input, output });
const nwcUrl =
process.env.NWC_URL ||
(await rl.question("Nostr Wallet Connect URL (nostr+walletconnect://...): "));
const destination = await rl.question("Enter destination pubkey: ");
const destination =
(await rl.question("Enter destination pubkey: ")) ||
"030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3";
const amount = await rl.question("Enter amount: ");
rl.close();

const webln = new providers.NostrWebLNProvider({
nostrWalletConnectUrl: nwcUrl,
});
await webln.enable();
const response = await webln.keysend({ amount, destination });
const response = await webln.keysend({
amount,
destination,
customRecords: {
696969: "1KOZHzhLs2U7JIx3BmEY",
},
});

console.info(response);

Expand Down
7 changes: 6 additions & 1 deletion src/webln/NostrWeblnProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
{
amount: +args.amount * 1000, // NIP-47 uses msat
pubkey: args.destination,
tlv_records: args.customRecords,
tlv_records: args.customRecords
? Object.entries(args.customRecords).map((v) => ({
type: parseInt(v[0]),
value: v[1],
}))
: [],
// TODO: support optional preimage
// preimage?: "123",
},
Expand Down

0 comments on commit bc37f18

Please sign in to comment.