From 8ff11a2380cfd8038384bd4e5028f336ce408aec Mon Sep 17 00:00:00 2001 From: benalleng Date: Sat, 30 Sep 2023 21:55:53 -0400 Subject: [PATCH] feat: Add payjoin sends --- src/i18n/en/translations.ts | 2 ++ src/logic/waila.ts | 4 ++++ src/routes/Send.tsx | 21 ++++++++++++++++++++- src/state/megaStore.tsx | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/i18n/en/translations.ts b/src/i18n/en/translations.ts index e42fa0b5..120f9e8f 100644 --- a/src/i18n/en/translations.ts +++ b/src/i18n/en/translations.ts @@ -138,6 +138,8 @@ export default { error_keysend: "Keysend failed", error_LNURL: "LNURL Pay failed", error_expired: "Invoice is expired", + payjoin_send: + "This is a payjoin! The Mutiny will continue until privacy improves", payment_pending: "Payment pending", payment_pending_description: "It's taking a while, but it's possible this payment may still go through. Please check 'Activity' for the current status.", diff --git a/src/logic/waila.ts b/src/logic/waila.ts index 20b1a407..d2a29b72 100644 --- a/src/logic/waila.ts +++ b/src/logic/waila.ts @@ -6,7 +6,9 @@ import { Result } from "~/utils"; await initWaila(); export type ParsedParams = { + original: string; address?: string; + payjoin_enabled?: boolean; invoice?: string; amount_sats?: bigint; network?: string; @@ -53,7 +55,9 @@ export function toParsedParams( return { ok: true, value: { + original: str, address: params.address, + payjoin_enabled: params.payjoin_supported, invoice: params.invoice, amount_sats: params.amount_sats, network, diff --git a/src/routes/Send.tsx b/src/routes/Send.tsx index 76ed6117..cedac967 100644 --- a/src/routes/Send.tsx +++ b/src/routes/Send.tsx @@ -261,7 +261,9 @@ export function Send() { const [nodePubkey, setNodePubkey] = createSignal(); const [lnurlp, setLnurlp] = createSignal(); const [lnAddress, setLnAddress] = createSignal(); + const [originalScan, setOriginalScan] = createSignal(); const [address, setAddress] = createSignal(); + const [payjoinEnabled, setPayjoinEnabled] = createSignal(); const [description, setDescription] = createSignal(); const [contactId, setContactId] = createSignal(); const [isHodlInvoice, setIsHodlInvoice] = createSignal(false); @@ -414,9 +416,11 @@ export function Send() { function handleDestination(source: ParsedParams | undefined) { if (!source) return; setParsingDestination(true); - + setOriginalScan(source.original); try { if (source.address) setAddress(source.address); + if (source.payjoin_enabled) + setPayjoinEnabled(source.payjoin_enabled); if (source.memo) setDescription(source.memo); if (source.contact_id) setContactId(source.contact_id); @@ -594,6 +598,16 @@ export function Send() { tags ); + sentDetails.amount = amountSats(); + sentDetails.destination = address(); + sentDetails.txid = txid; + sentDetails.fee_estimate = feeEstimate() ?? 0; + } else if (payjoinEnabled()) { + const txid = await state.mutiny_wallet?.send_payjoin( + originalScan()!, + amountSats(), + tags + ); sentDetails.amount = amountSats(); sentDetails.destination = address(); sentDetails.txid = txid; @@ -789,6 +803,11 @@ export function Send() { setChosenMethod={setSourceFromMethod} /> + + +

{i18n.t("send.payjoin_send")}

+
+
{ } else { if ( result.value?.address || + result.value?.payjoin_enabled || result.value?.invoice || result.value?.node_pubkey || (result.value?.lnurl && !result.value.is_lnurl_auth)