Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit 766bf81

Browse files
committed
bolt12
1 parent 57df13a commit 766bf81

File tree

5 files changed

+54
-17
lines changed

5 files changed

+54
-17
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@
4848
"@capacitor/clipboard": "^5.0.6",
4949
"@capacitor/core": "^5.2.2",
5050
"@capacitor/filesystem": "^5.1.4",
51-
"@capacitor/share": "^5.0.6",
5251
"@capacitor/haptics": "^5.0.6",
52+
"@capacitor/share": "^5.0.6",
5353
"@capacitor/toast": "^5.0.6",
5454
"@kobalte/core": "^0.9.8",
5555
"@kobalte/tailwindcss": "^0.5.0",
5656
"@modular-forms/solid": "^0.18.1",
5757
"@mutinywallet/barcode-scanner": "5.0.0-beta.3",
58-
"@mutinywallet/mutiny-wasm": "0.4.25",
59-
"@mutinywallet/waila-wasm": "^0.2.1",
58+
"@mutinywallet/mutiny-wasm": "^0.4.24",
59+
"@mutinywallet/waila-wasm": "0.2.4",
6060
"@nostr-dev-kit/ndk": "^0.8.11",
6161
"@solid-primitives/upload": "^0.0.111",
6262
"@solid-primitives/websocket": "^1.1.0",

pnpm-lock.yaml

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/logic/waila.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import initWaila, { PaymentParams } from "@mutinywallet/waila-wasm";
22

33
import { Result } from "~/utils";
44

5-
// Make sure we've initialzied waila before we try to use it
5+
// Make sure we've initialized waila before we try to use it
66
await initWaila();
77

88
export type ParsedParams = {
99
address?: string;
1010
invoice?: string;
11+
offer?: string;
1112
amount_sats?: bigint;
1213
network?: string;
1314
memo?: string;
@@ -50,6 +51,7 @@ export function toParsedParams(
5051
value: {
5152
address: params.address,
5253
invoice: params.invoice,
54+
offer: params.offer,
5355
amount_sats: params.amount_sats,
5456
network,
5557
memo: params.memo,

src/routes/Send.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ function DestinationShower(props: {
175175
description?: string;
176176
address?: string;
177177
invoice?: MutinyInvoice;
178+
offer?: string;
178179
nodePubkey?: string;
179180
lnurl?: string;
180181
clearAll: () => void;
@@ -187,6 +188,9 @@ function DestinationShower(props: {
187188
<Match when={props.invoice && props.source === "lightning"}>
188189
<StringShower text={props.invoice?.bolt11 || ""} />
189190
</Match>
191+
<Match when={props.offer && props.source === "lightning"}>
192+
<StringShower text={props.offer || ""} />
193+
</Match>
190194
<Match when={props.nodePubkey && props.source === "lightning"}>
191195
<StringShower text={props.nodePubkey || ""} />
192196
</Match>
@@ -213,6 +217,7 @@ export default function Send() {
213217

214218
// These can only be derived from the "destination" signal
215219
const [invoice, setInvoice] = createSignal<MutinyInvoice>();
220+
const [offer, setOffer] = createSignal<string>();
216221
const [nodePubkey, setNodePubkey] = createSignal<string>();
217222
const [lnurlp, setLnurlp] = createSignal<string>();
218223
const [address, setAddress] = createSignal<string>();
@@ -236,6 +241,7 @@ export default function Send() {
236241
setIsAmtEditable(true);
237242
setSource("lightning");
238243
setInvoice(undefined);
244+
setOffer(undefined);
239245
setAddress(undefined);
240246
setDescription(undefined);
241247
setNodePubkey(undefined);
@@ -346,6 +352,13 @@ export default function Send() {
346352
setInvoice(invoice);
347353
setSource("lightning");
348354
});
355+
} else if (source.offer) {
356+
if (source.amount_sats) {
357+
setAmountSats(source.amount_sats)
358+
setIsAmtEditable(false);
359+
}
360+
setOffer(source.offer);
361+
setSource("lightning");
349362
} else if (source.node_pubkey) {
350363
setAmountSats(source.amount_sats || 0n);
351364
setNodePubkey(source.node_pubkey);
@@ -489,6 +502,24 @@ export default function Send() {
489502
sentDetails.amount = amountSats();
490503
sentDetails.fee_estimate = payment?.fees_paid || 0;
491504
}
505+
} else if (source() === "lightning" && offer()) {
506+
const nodes = await state.mutiny_wallet?.list_nodes();
507+
const firstNode = (nodes[0] as string) || "";
508+
const payment = await state.mutiny_wallet?.pay_offer(
509+
firstNode,
510+
offer()!,
511+
amountSats(),
512+
undefined,
513+
undefined, // todo add optional payer message
514+
tags
515+
);
516+
517+
if (!payment?.paid) {
518+
throw new Error(i18n.t("send.error_keysend"));
519+
} else {
520+
sentDetails.amount = amountSats();
521+
sentDetails.fee_estimate = payment?.fees_paid || 0;
522+
}
492523
} else if (source() === "lightning" && nodePubkey()) {
493524
const nodes = await state.mutiny_wallet?.list_nodes();
494525
const firstNode = (nodes[0] as string) || "";
@@ -576,7 +607,7 @@ export default function Send() {
576607
<DefaultMain>
577608
<Show
578609
when={
579-
address() || invoice() || nodePubkey() || lnurlp()
610+
address() || invoice() || offer() || nodePubkey() || lnurlp()
580611
}
581612
fallback={<BackLink />}
582613
>
@@ -657,6 +688,7 @@ export default function Send() {
657688
when={
658689
address() ||
659690
invoice() ||
691+
offer() ||
660692
nodePubkey() ||
661693
lnurlp()
662694
}
@@ -672,6 +704,7 @@ export default function Send() {
672704
source={source()}
673705
description={description()}
674706
invoice={invoice()}
707+
offer={offer()}
675708
address={address()}
676709
nodePubkey={nodePubkey()}
677710
lnurl={lnurlp()}
@@ -720,6 +753,7 @@ export default function Send() {
720753
when={
721754
address() ||
722755
invoice() ||
756+
offer() ||
723757
nodePubkey() ||
724758
lnurlp()
725759
}

src/state/megaStore.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ export const Provider: ParentComponent = (props) => {
347347
if (
348348
result.value?.address ||
349349
result.value?.invoice ||
350+
result.value?.offer ||
350351
result.value?.node_pubkey ||
351352
result.value?.lnurl
352353
) {

0 commit comments

Comments
 (0)