Skip to content

Commit

Permalink
fix: convert transaction amount from millisats to sats
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Dec 15, 2023
1 parent d5d05e3 commit e638a1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/nwc/make-invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { webln as providers } from "../../dist/index.module.js";

const rl = readline.createInterface({ input, output });

const nwcUrl = await rl.question(
"Nostr Wallet Connect URL (nostr+walletconnect://...): ",
);
const nwcUrl =
process.env.NWC_URL ||
(await rl.question("Nostr Wallet Connect URL (nostr+walletconnect://...): "));
rl.close();

const webln = new providers.NostrWebLNProvider({
Expand Down
9 changes: 7 additions & 2 deletions src/webln/NostrWeblnProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,13 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
"list_transactions",
args,
(response) => !!response.transactions,
// TODO: consider mapping NWC response
(response) => response,
(response) => ({
transactions: response.transactions.map((transaction) => ({
...transaction,
// NWC uses msats - convert to sats for webln
amount: Math.floor(transaction.amount / 1000),
})),
}),
);
}

Expand Down

0 comments on commit e638a1c

Please sign in to comment.