Skip to content

Commit

Permalink
feat: Add payjoin sends
Browse files Browse the repository at this point in the history
  • Loading branch information
benalleng committed Dec 2, 2023
1 parent 9f7c489 commit b9a089c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/i18n/en/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export default {
error_clipboard: "Clipboard not supported",
error_keysend: "Keysend failed",
error_LNURL: "LNURL Pay failed",
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.",
Expand Down
4 changes: 4 additions & 0 deletions src/logic/waila.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,7 +51,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,
Expand Down
19 changes: 19 additions & 0 deletions src/routes/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export function Send() {
const [lnurlp, setLnurlp] = createSignal<string>();
const [lnAddress, setLnAddress] = createSignal<string>();
const [address, setAddress] = createSignal<string>();
const [payjoinEnabled, setPayjoinEnabled] = createSignal<boolean>();
const [description, setDescription] = createSignal<string>();

const [isHodlInvoice, setIsHodlInvoice] = createSignal<boolean>(false);
Expand Down Expand Up @@ -298,6 +299,7 @@ export function Send() {
setSource("lightning");
setInvoice(undefined);
setAddress(undefined);
setPayjoinEnabled(undefined);
setDescription(undefined);
setNodePubkey(undefined);
setLnurlp(undefined);
Expand Down Expand Up @@ -418,6 +420,8 @@ export function Send() {
if (!source) return;
try {
if (source.address) setAddress(source.address);
if (source.payjoin_enabled)
setPayjoinEnabled(source.payjoin_enabled);
if (source.memo) setDescription(source.memo);

if (source.invoice) {
Expand Down Expand Up @@ -636,6 +640,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(
destination()!.original,
amountSats(),
tags
);
sentDetails.amount = amountSats();
sentDetails.destination = address();
sentDetails.txid = txid;
Expand Down Expand Up @@ -804,6 +818,11 @@ export function Send() {
/>
</VStack>
</Card>
<Show when={payjoinEnabled()}>
<InfoBox accent="green">
<p>{i18n.t("send.payjoin_send")}</p>
</InfoBox>
</Show>
<AmountCard
amountSats={amountSats().toString()}
setAmountSats={setAmountSats}
Expand Down
1 change: 1 addition & 0 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,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
Expand Down

0 comments on commit b9a089c

Please sign in to comment.