Skip to content

Commit

Permalink
Merge pull request #729 from getAlby/fix/keysend-webln
Browse files Browse the repository at this point in the history
Fix/keysend-webln
  • Loading branch information
bumi authored Mar 23, 2022
2 parents 0081fbe + 0e89a17 commit 93c9cbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/extension/background-script/actions/ln/keysend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import utils from "../../../../common/lib/utils";
export default async function keysend(message: Message) {
PubSub.publish(`ln.keysend.start`, message);
const { destination, amount, customRecords } = message.args;
if (typeof destination !== "string" || typeof amount !== "string") {
if (
typeof destination !== "string" ||
(typeof amount !== "string" && typeof amount !== "number")
) {
return {
error: "destination or amount missing.",
};
Expand All @@ -19,7 +22,7 @@ export default async function keysend(message: Message) {
try {
response = await connector.keysend({
pubkey: destination,
amount: parseInt(amount),
amount: parseInt(amount as string),
customRecords: customRecords as Record<string, string>,
});
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { checkAllowance } from "./sendPaymentOrPrompt";
const keysendOrPrompt = async (message: Message) => {
const destination = message.args.destination;
const amount = message.args.amount;
if (typeof destination !== "string" || typeof amount !== "string") {
if (
typeof destination !== "string" ||
(typeof amount !== "string" && typeof amount !== "number")
) {
return {
error: "Destination or amount missing.",
};
}

if (await checkAllowance(message.origin.host, parseInt(amount))) {
if (await checkAllowance(message.origin.host, parseInt(amount as string))) {
return keysendWithAllowance(message);
} else {
return keysendWithPrompt(message);
Expand Down
4 changes: 2 additions & 2 deletions src/extension/ln/webln/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ type RequestInvoiceArgs = {

type KeysendArgs = {
destination: string;
customRecords: Record<string, string>;
amount: string;
customRecords?: Record<string, string>;
amount: string | number;
};

export default class WebLNProvider {
Expand Down

0 comments on commit 93c9cbe

Please sign in to comment.