feat: Add payjoin sends

This commit is contained in:
benalleng
2023-09-30 21:55:53 -04:00
committed by benthecarman
parent c680ab2805
commit 8ff11a2380
4 changed files with 27 additions and 1 deletions

View File

@@ -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.",

View File

@@ -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,

View File

@@ -261,7 +261,9 @@ export function Send() {
const [nodePubkey, setNodePubkey] = createSignal<string>();
const [lnurlp, setLnurlp] = createSignal<string>();
const [lnAddress, setLnAddress] = createSignal<string>();
const [originalScan, setOriginalScan] = createSignal<string>();
const [address, setAddress] = createSignal<string>();
const [payjoinEnabled, setPayjoinEnabled] = createSignal<boolean>();
const [description, setDescription] = createSignal<string>();
const [contactId, setContactId] = createSignal<string>();
const [isHodlInvoice, setIsHodlInvoice] = createSignal<boolean>(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}
/>
</Show>
<Show when={payjoinEnabled()}>
<InfoBox accent="green">
<p>{i18n.t("send.payjoin_send")}</p>
</InfoBox>
</Show>
<Show when={!isAmtEditable()}>
<AmountEditable
initialAmountSats={amountSats()}

View File

@@ -369,6 +369,7 @@ export const Provider: ParentComponent = (props) => {
} else {
if (
result.value?.address ||
result.value?.payjoin_enabled ||
result.value?.invoice ||
result.value?.node_pubkey ||
(result.value?.lnurl && !result.value.is_lnurl_auth)