mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-02-07 07:14:27 +01:00
decode node pubkeys
This commit is contained in:
75
pnpm-lock.yaml
generated
75
pnpm-lock.yaml
generated
@@ -10,9 +10,6 @@ dependencies:
|
||||
'@modular-forms/solid':
|
||||
specifier: ^0.12.0
|
||||
version: 0.12.0(solid-js@1.7.3)
|
||||
'@motionone/solid':
|
||||
specifier: ^10.16.0
|
||||
version: 10.16.0(solid-js@1.7.3)
|
||||
'@mutinywallet/mutiny-wasm':
|
||||
specifier: ^0.2.7
|
||||
version: 0.2.7
|
||||
@@ -1586,66 +1583,6 @@ packages:
|
||||
solid-js: 1.7.3
|
||||
dev: false
|
||||
|
||||
/@motionone/animation@10.15.1:
|
||||
resolution: {integrity: sha512-mZcJxLjHor+bhcPuIFErMDNyrdb2vJur8lSfMCsuCB4UyV8ILZLvK+t+pg56erv8ud9xQGK/1OGPt10agPrCyQ==}
|
||||
dependencies:
|
||||
'@motionone/easing': 10.15.1
|
||||
'@motionone/types': 10.15.1
|
||||
'@motionone/utils': 10.15.1
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/@motionone/dom@10.15.5:
|
||||
resolution: {integrity: sha512-Xc5avlgyh3xukU9tydh9+8mB8+2zAq+WlLsC3eEIp7Ax7DnXgY7Bj/iv0a4X2R9z9ZFZiaXK3BO0xMYHKbAAdA==}
|
||||
dependencies:
|
||||
'@motionone/animation': 10.15.1
|
||||
'@motionone/generators': 10.15.1
|
||||
'@motionone/types': 10.15.1
|
||||
'@motionone/utils': 10.15.1
|
||||
hey-listen: 1.0.8
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/@motionone/easing@10.15.1:
|
||||
resolution: {integrity: sha512-6hIHBSV+ZVehf9dcKZLT7p5PEKHGhDwky2k8RKkmOvUoYP3S+dXsKupyZpqx5apjd9f+php4vXk4LuS+ADsrWw==}
|
||||
dependencies:
|
||||
'@motionone/utils': 10.15.1
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/@motionone/generators@10.15.1:
|
||||
resolution: {integrity: sha512-67HLsvHJbw6cIbLA/o+gsm7h+6D4Sn7AUrB/GPxvujse1cGZ38F5H7DzoH7PhX+sjvtDnt2IhFYF2Zp1QTMKWQ==}
|
||||
dependencies:
|
||||
'@motionone/types': 10.15.1
|
||||
'@motionone/utils': 10.15.1
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/@motionone/solid@10.16.0(solid-js@1.7.3):
|
||||
resolution: {integrity: sha512-pxE5qQEtwv42bAllHFVapZevX5T4YTYzFe7vo0+Lljqyx+7+jP1NT0fosBUAOhDNdJNANNMldXwyh+qGBW5BrA==}
|
||||
peerDependencies:
|
||||
solid-js: ^1.5.0
|
||||
dependencies:
|
||||
'@motionone/dom': 10.15.5
|
||||
'@motionone/utils': 10.15.1
|
||||
'@solid-primitives/props': 3.1.4(solid-js@1.7.3)
|
||||
'@solid-primitives/refs': 1.0.2(solid-js@1.7.3)
|
||||
'@solid-primitives/transition-group': 1.0.2(solid-js@1.7.3)
|
||||
solid-js: 1.7.3
|
||||
dev: false
|
||||
|
||||
/@motionone/types@10.15.1:
|
||||
resolution: {integrity: sha512-iIUd/EgUsRZGrvW0jqdst8st7zKTzS9EsKkP+6c6n4MPZoQHwiHuVtTQLD6Kp0bsBLhNzKIBlHXponn/SDT4hA==}
|
||||
dev: false
|
||||
|
||||
/@motionone/utils@10.15.1:
|
||||
resolution: {integrity: sha512-p0YncgU+iklvYr/Dq4NobTRdAPv9PveRDUXabPEeOjBLSO/1FNB2phNTZxOxpi1/GZwYpAoECEa0Wam+nsmhSw==}
|
||||
dependencies:
|
||||
'@motionone/types': 10.15.1
|
||||
hey-listen: 1.0.8
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/@mutinywallet/mutiny-wasm@0.2.7:
|
||||
resolution: {integrity: sha512-AssJjkqDdYLD9kzJWfMJe1lZL+uGDBJbmd5ehUokdLKGbIrSpUzBO8hWDjWxI8dteci4laApZ/WfVRjVW7PQ9Q==}
|
||||
dev: false
|
||||
@@ -1906,14 +1843,6 @@ packages:
|
||||
solid-js: 1.7.3
|
||||
dev: false
|
||||
|
||||
/@solid-primitives/transition-group@1.0.2(solid-js@1.7.3):
|
||||
resolution: {integrity: sha512-+o3J7TnU0/Sok+LKA0z0wvhim88dpd2eFBk8/05adE6wVypVlME8sKqTMO+xRv8HoT4Kq3sczmvwV07FKg2n+g==}
|
||||
peerDependencies:
|
||||
solid-js: ^1.6.12
|
||||
dependencies:
|
||||
solid-js: 1.7.3
|
||||
dev: false
|
||||
|
||||
/@solid-primitives/utils@5.5.2(solid-js@1.7.3):
|
||||
resolution: {integrity: sha512-L52ig3eHKU6CqbPCKJIb4lweBuINHBOERcE1duApyKozEN8+zCqEKwD1Qo9ljKeEzJTBGWClxNpwEiNTUWTGvg==}
|
||||
peerDependencies:
|
||||
@@ -3575,10 +3504,6 @@ packages:
|
||||
dependencies:
|
||||
function-bind: 1.1.1
|
||||
|
||||
/hey-listen@1.0.8:
|
||||
resolution: {integrity: sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==}
|
||||
dev: false
|
||||
|
||||
/html-entities@2.3.3:
|
||||
resolution: {integrity: sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ export type ParsedParams = {
|
||||
amount_sats?: bigint;
|
||||
network?: string;
|
||||
memo?: string;
|
||||
node_pubkey?: string;
|
||||
}
|
||||
|
||||
export function toParsedParams(str: string, ourNetwork: string): Result<ParsedParams> {
|
||||
@@ -24,16 +25,23 @@ export function toParsedParams(str: string, ourNetwork: string): Result<ParsedPa
|
||||
return { ok: false, error: new Error("Invalid payment request") }
|
||||
}
|
||||
|
||||
console.log("params:", params.node_pubkey)
|
||||
console.log("params network:", params.network)
|
||||
console.log("our network:", ourNetwork)
|
||||
|
||||
|
||||
|
||||
// TODO: "testnet" and "signet" are encoded the same I guess?
|
||||
if (params.network === "testnet" || params.network === "signet") {
|
||||
if (ourNetwork === "signet") {
|
||||
// noop
|
||||
}
|
||||
} else if (params.network !== ourNetwork) {
|
||||
return { ok: false, error: new Error(`Destination is for ${params.network} but you're on ${ourNetwork}`) }
|
||||
if (params.node_pubkey) {
|
||||
// noop
|
||||
} else {
|
||||
return { ok: false, error: new Error(`Destination is for ${params.network} but you're on ${ourNetwork}`) }
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -42,7 +50,8 @@ export function toParsedParams(str: string, ourNetwork: string): Result<ParsedPa
|
||||
invoice: params.invoice,
|
||||
amount_sats: params.amount_sats,
|
||||
network: params.network,
|
||||
memo: params.memo
|
||||
memo: params.memo,
|
||||
node_pubkey: params.node_pubkey,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +93,7 @@ export default function Scanner() {
|
||||
showToast(result.error);
|
||||
return;
|
||||
} else {
|
||||
if (result.value?.address || result.value?.invoice) {
|
||||
if (result.value?.address || result.value?.invoice || result.value?.node_pubkey) {
|
||||
actions.setScanResult(result.value);
|
||||
navigate("/send")
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ export default function Send() {
|
||||
|
||||
// These can only be derived from the "destination" signal
|
||||
const [invoice, setInvoice] = createSignal<MutinyInvoice>();
|
||||
const [nodePubkey, setNodePubkey] = createSignal<string>();
|
||||
const [address, setAddress] = createSignal<string>();
|
||||
const [description, setDescription] = createSignal<string>();
|
||||
|
||||
@@ -78,7 +79,11 @@ export default function Send() {
|
||||
if (source.address) setAddress(source.address)
|
||||
if (source.memo) setDescription(source.memo);
|
||||
|
||||
if (source.invoice) {
|
||||
if (source.node_pubkey) {
|
||||
setAmountSats(source.amount_sats || 0n);
|
||||
setNodePubkey(source.node_pubkey);
|
||||
setSource("lightning")
|
||||
} else if (source.invoice) {
|
||||
state.node_manager?.decode_invoice(source.invoice).then(invoice => {
|
||||
if (invoice?.amount_sats) setAmountSats(invoice.amount_sats);
|
||||
setInvoice(invoice)
|
||||
@@ -104,7 +109,7 @@ export default function Send() {
|
||||
showToast(result.error);
|
||||
return;
|
||||
} else {
|
||||
if (result.value?.address || result.value?.invoice) {
|
||||
if (result.value?.address || result.value?.invoice || result.value?.node_pubkey) {
|
||||
setDestination(result.value);
|
||||
// Important! we need to clear the scan result once we've used it
|
||||
actions.setScanResult(undefined);
|
||||
@@ -146,6 +151,12 @@ export default function Send() {
|
||||
await state.node_manager?.pay_invoice(firstNode, bolt11, amountSats());
|
||||
sentDetails.amount = amountSats();
|
||||
}
|
||||
} else if (source() === "lightning" && nodePubkey()) {
|
||||
const nodes = await state.node_manager?.list_nodes();
|
||||
const firstNode = nodes[0] as string || ""
|
||||
const invoice = await state.node_manager?.keysend(firstNode, nodePubkey()!, amountSats());
|
||||
console.log(invoice?.value)
|
||||
sentDetails.amount = amountSats();
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const txid = await state.node_manager?.send_to_address(address()!, amountSats());
|
||||
@@ -165,6 +176,10 @@ export default function Send() {
|
||||
}
|
||||
}
|
||||
|
||||
const sendButtonDisabled = createMemo(() => {
|
||||
return !destination() || sending() || amountSats() === 0n;
|
||||
})
|
||||
|
||||
return (
|
||||
<NodeManagerGuard>
|
||||
<SafeArea>
|
||||
@@ -188,7 +203,7 @@ export default function Send() {
|
||||
</dt>
|
||||
<dd>
|
||||
<Switch>
|
||||
<Match when={address() || invoice()}>
|
||||
<Match when={address() || invoice() || nodePubkey()}>
|
||||
<div class="flex gap-2 items-center">
|
||||
<Show when={address() && source() === "onchain"}>
|
||||
<code class="truncate text-sm break-all">{"Address: "} {address()}
|
||||
@@ -206,6 +221,11 @@ export default function Send() {
|
||||
</Show>
|
||||
</code>
|
||||
</Show>
|
||||
<Show when={nodePubkey() && source() === "lightning"}>
|
||||
<code class="truncate text-sm break-all">{"Node Pubkey: "} {nodePubkey()}
|
||||
|
||||
</code>
|
||||
</Show>
|
||||
<Button class="flex-0" intent="glowy" layout="xs" onClick={clearAll}>Clear</Button>
|
||||
</div>
|
||||
<div class="my-8 flex gap-4 w-full items-center justify-around">
|
||||
@@ -263,7 +283,7 @@ export default function Send() {
|
||||
</Show>
|
||||
</dl>
|
||||
<Show when={destination()}>
|
||||
<Button disabled={!destination() || sending()} intent="blue" onClick={handleSend} loading={sending()}>{sending() ? "Sending..." : "Confirm Send"}</Button>
|
||||
<Button disabled={sendButtonDisabled()} intent="blue" onClick={handleSend} loading={sending()}>{sending() ? "Sending..." : "Confirm Send"}</Button>
|
||||
</Show>
|
||||
</DefaultMain>
|
||||
<NavBar activeTab="send" />
|
||||
|
||||
Reference in New Issue
Block a user