When using bolt11 show how much the user is paying
This commit is contained in:
parent
566e0f5a3d
commit
be7a1f919f
1 changed files with 7 additions and 2 deletions
|
@ -10,11 +10,13 @@
|
||||||
|
|
||||||
let amountSat = $state<number | "">("");
|
let amountSat = $state<number | "">("");
|
||||||
let status = $state("");
|
let status = $state("");
|
||||||
|
let isBolt11 = $state(false);
|
||||||
|
|
||||||
let requireAmount = $state(false);
|
let requireAmount = $state(false);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
|
isBolt11 = false;
|
||||||
if (!destination.trim()) {
|
if (!destination.trim()) {
|
||||||
requireAmount = false;
|
requireAmount = false;
|
||||||
return;
|
return;
|
||||||
|
@ -29,7 +31,8 @@
|
||||||
parsed.invoice.amountMsat > 0
|
parsed.invoice.amountMsat > 0
|
||||||
) {
|
) {
|
||||||
requireAmount = false;
|
requireAmount = false;
|
||||||
amountSat = "";
|
amountSat = Math.floor(parsed.invoice.amountMsat / 1000);
|
||||||
|
isBolt11 = true;
|
||||||
} else {
|
} else {
|
||||||
requireAmount = true;
|
requireAmount = true;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +48,7 @@
|
||||||
if (!$walletState.open) throw new Error("Wallet not open");
|
if (!$walletState.open) throw new Error("Wallet not open");
|
||||||
const sendGenerator = $walletState.wallet.pay(
|
const sendGenerator = $walletState.wallet.pay(
|
||||||
destination,
|
destination,
|
||||||
Number(amountSat) || 0
|
Number(amountSat) || 0,
|
||||||
);
|
);
|
||||||
for await (const {
|
for await (const {
|
||||||
status: sendStatus,
|
status: sendStatus,
|
||||||
|
@ -130,6 +133,8 @@
|
||||||
placeholder="amount in sats"
|
placeholder="amount in sats"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
{:else if isBolt11}
|
||||||
|
<p>Paying {amountSat} sats</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if status}
|
{#if status}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue