Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use msat for makeInvoice #70

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/webln/NostrWeblnProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {

const requestInvoiceArgs: RequestInvoiceArgs | undefined =
typeof args === "object" ? (args as RequestInvoiceArgs) : undefined;
const amount =
const amount = +(
requestInvoiceArgs?.amount ??
(typeof args === "string" ? parseInt(args) : (args as number));
args as string | number);

if (!amount) {
throw new Error("No amount specified");
Expand All @@ -279,9 +279,11 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
return this.executeNip47Request<MakeInvoiceResponse, { invoice: string }>(
"make_invoice",
{
amount,
amount: amount * 1000, // NIP-47 uses msat
description: requestInvoiceArgs?.defaultMemo,
// TODO: description hash and expiry?
// TODO: support additional fields below
//expiry: 86500,
//description_hash: "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
},
(result) => !!result.invoice,
(result) => ({ paymentRequest: result.invoice }),
Expand Down