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/keysend-webln #729

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
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
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