diff --git a/src/components/layout/index.tsx b/src/components/layout/index.tsx
index ce71283..f42d570 100644
--- a/src/components/layout/index.tsx
+++ b/src/components/layout/index.tsx
@@ -96,6 +96,10 @@ const VStack: ParentComponent<{ biggap?: boolean }> = (props) => {
return (
{props.children}
)
}
+const HStack: ParentComponent<{ biggap?: boolean }> = (props) => {
+ return ({props.children}
)
+}
+
const SmallAmount: ParentComponent<{ amount: number | bigint }> = (props) => {
return ({props.amount.toLocaleString()} SATS
)
}
@@ -116,5 +120,6 @@ export {
DefaultMain,
LargeHeader,
VStack,
+ HStack,
SmallAmount
}
diff --git a/src/logic/nodeManagerSetup.ts b/src/logic/nodeManagerSetup.ts
index b003bd3..68a0abb 100644
--- a/src/logic/nodeManagerSetup.ts
+++ b/src/logic/nodeManagerSetup.ts
@@ -1,5 +1,6 @@
-import init, { NodeManager } from '@mutinywallet/mutiny-wasm';
+import initNodeManager, { NodeManager } from '@mutinywallet/mutiny-wasm';
+import initWaila from '@mutinywallet/waila-wasm'
// export type NodeManagerSettingStrings = {
// network?: string, proxy?: string, esplora?: string, rgs?: string, lsp?: string,
@@ -70,7 +71,9 @@ export async function checkForWasm() {
}
export async function setupNodeManager(settings?: NodeManagerSettingStrings): Promise {
- const _ = await init();
+ await initNodeManager();
+ // Might as well init waila while we're at it
+ await initWaila();
console.time("Setup");
console.log("Starting setup...")
diff --git a/src/routes/Scanner.tsx b/src/routes/Scanner.tsx
index 789f467..0e39964 100644
--- a/src/routes/Scanner.tsx
+++ b/src/routes/Scanner.tsx
@@ -16,7 +16,13 @@ export type ParsedParams = {
}
export function toParsedParams(str: string, ourNetwork: string): Result {
- const params = new PaymentParams(str || "")
+ let params;
+ try {
+ params = new PaymentParams(str || "")
+ } catch (e) {
+ console.error(e)
+ return { ok: false, error: new Error("Invalid payment request") }
+ }
console.log("params network:", params.network)
console.log("our network:", ourNetwork)
diff --git a/src/routes/Send.tsx b/src/routes/Send.tsx
index 94af1fe..3ab40fb 100644
--- a/src/routes/Send.tsx
+++ b/src/routes/Send.tsx
@@ -1,8 +1,7 @@
-import { TextField } from "@kobalte/core";
import { Match, Show, Switch, createEffect, createMemo, createResource, createSignal, onCleanup, onMount } from "solid-js";
import { Amount } from "~/components/Amount";
import NavBar from "~/components/NavBar";
-import { Button, ButtonLink, DefaultMain, LargeHeader, NodeManagerGuard, SafeArea, SmallHeader } from "~/components/layout";
+import { Button, ButtonLink, DefaultMain, HStack, LargeHeader, NodeManagerGuard, SafeArea, SmallHeader, VStack } from "~/components/layout";
import { Paste } from "~/assets/svg/Paste";
import { Scan } from "~/assets/svg/Scan";
import { useMegaStore } from "~/state/megaStore";
@@ -10,7 +9,6 @@ import { MutinyInvoice } from "@mutinywallet/mutiny-wasm";
import { AmountEditable } from "~/components/AmountEditable";
import { StyledRadioGroup } from "~/components/layout/Radio";
import { ParsedParams, toParsedParams } from "./Scanner";
-import init from "@mutinywallet/waila-wasm";
import { showToast } from "~/components/Toaster";
import eify from "~/utils/eify";
import { FullscreenModal } from "~/components/layout/FullscreenModal";
@@ -28,23 +26,10 @@ const PAYMENT_METHODS = [{ value: "lightning", label: "Lightning", caption: "Fas
type SentDetails = { amount: bigint, destination: string, txid?: string }
export default function Send() {
- let waila;
-
- onMount(() => {
- init().then((w) => {
- waila = w;
- });
-
- })
-
- // TODO: Is this just implied?
- onCleanup(() => {
- waila = undefined;
- })
-
const [state, actions] = useMegaStore();
// These can only be set by the user
+ const [fieldDestination, setFieldDestination] = createSignal("");
const [destination, setDestination] = createSignal();
const [privateLabel, setPrivateLabel] = createSignal("");
@@ -69,6 +54,7 @@ export default function Send() {
setInvoice(undefined);
setAddress(undefined);
setDescription(undefined);
+ setFieldDestination("");
}
const fakeFee = createMemo(() => {
@@ -110,22 +96,36 @@ export default function Send() {
}
})
- function handlePaste() {
- navigator.clipboard.readText().then(text => {
- if (text) {
- const network = state.node_manager?.get_network() || "signet";
- const result = toParsedParams(text || "", network);
- if (!result.ok) {
- showToast(result.error);
- return;
- } else {
- if (result.value?.address || result.value?.invoice) {
- setDestination(result.value);
- // Important! we need to clear the scan result once we've used it
- actions.setScanResult(undefined);
- }
+ function parsePaste(text: string) {
+ if (text) {
+ const network = state.node_manager?.get_network() || "signet";
+ const result = toParsedParams(text || "", network);
+ if (!result.ok) {
+ showToast(result.error);
+ return;
+ } else {
+ if (result.value?.address || result.value?.invoice) {
+ setDestination(result.value);
+ // Important! we need to clear the scan result once we've used it
+ actions.setScanResult(undefined);
}
}
+ }
+ }
+
+ function handleDecode() {
+ const text = fieldDestination();
+ parsePaste(text);
+ }
+
+ function handlePaste() {
+ if (!navigator.clipboard.readText) return showToast(new Error("Clipboard not supported"));
+
+ navigator.clipboard.readText().then(text => {
+ setFieldDestination(text);
+ parsePaste(text);
+ }).catch((e) => {
+ showToast(new Error("Failed to read clipboard: " + e.message))
});
}
@@ -171,7 +171,6 @@ export default function Send() {
Send Bitcoin
- {/* */}
{ if (!open) setSentDetails(undefined) }} onConfirm={() => setSentDetails(undefined)}>

@@ -231,20 +230,26 @@ export default function Send() {
-
-
-
-
-
- Scan QR
-
-
-
+
+
@@ -258,31 +263,13 @@ export default function Send() {
-
-
-
-
- Label (private)
-
-
-
-
-
-
-
-
+
+
+
-
+
)
}
\ No newline at end of file