Skip to content

Commit

Permalink
Don't copy lightning: prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jun 3, 2024
1 parent 46262d8 commit cf54215
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/IntegratedQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async function share(receiveString: string) {

export function IntegratedQr(props: {
value: string;
copyString?: string;
kind: ReceiveFlavor | "gift" | "lnAddress";
amountSats?: string;
}) {
Expand All @@ -71,7 +72,7 @@ export function IntegratedQr(props: {
<div
id="qr"
class="relative flex w-full flex-col items-center rounded-xl bg-white px-4 text-black"
onClick={() => copy(props.value)}
onClick={() => copy(props.copyString ?? props.value)}
>
<Show when={copied()}>
<div class="absolute z-50 flex h-full w-full flex-col items-center justify-center rounded-xl bg-neutral-900/60 text-white transition-all">
Expand Down
13 changes: 13 additions & 0 deletions src/routes/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ export function Receive() {
}
});

// Only copy the raw invoice string for lightning because the lightning prefix is not needed
// for the onchain address we share the whole bip21 uri because it has more information
const copyString = createMemo(() => {
if (receiveState() === "show") {
if (flavor() === "lightning") {
return rawReceiveStrings()?.bolt11;
} else if (flavor() === "onchain") {
return receiveStrings()?.onchain;
}
}
});

async function checkIfPaid(receiveStrings?: {
bolt11?: string;
address?: string;
Expand Down Expand Up @@ -468,6 +480,7 @@ export function Receive() {
</Show>
<IntegratedQr
value={qrString() ?? ""}
copyString={copyString()}
amountSats={amount() ? amount().toString() : "0"}
kind={flavor()}
/>
Expand Down

0 comments on commit cf54215

Please sign in to comment.