Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/app/screens/ReceiveInvoice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function ReceiveInvoice() {
amount: "0",
description: "",
expiration: "",
includePrivateChannels: false,
});
const [loadingInvoice, setLoadingInvoice] = useState(false);
const [invoice, setInvoice] = useState<{
Expand Down Expand Up @@ -78,7 +79,11 @@ function ReceiveInvoice() {
) {
setFormData({
...formData,
[event.target.name]: event.target.value.trim(),
...formData,
[event.target.name]:
event.target.type === "checkbox"
? (event.target as HTMLInputElement).checked
: event.target.value.trim(),
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

Expand Down Expand Up @@ -109,6 +114,7 @@ function ReceiveInvoice() {
amount: "0",
description: "",
expiration: "",
includePrivateChannels: false,
});
setPaid(false);
setPollingForPayment(false);
Expand All @@ -121,6 +127,7 @@ function ReceiveInvoice() {
const response = await api.makeInvoice({
amount: formData.amount,
memo: formData.description,
includePrivateChannels: formData.includePrivateChannels,
});
setInvoice(response);
checkPayment(response.rHash);
Expand Down Expand Up @@ -294,6 +301,27 @@ function ReceiveInvoice() {
onChange={handleChange}
/>
</div>
<div className="mb-4">
<div className="flex items-center">
<input
id="includePrivateChannels"
name="includePrivateChannels"
type="checkbox"
className="w-4 h-4 text-orange-bitcoin border-gray-300 rounded focus:ring-orange-bitcoin dark:focus:ring-orange-bitcoin dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
checked={formData.includePrivateChannels}
onChange={handleChange}
/>
<label
htmlFor="includePrivateChannels"
className="ml-2 block text-sm font-medium text-gray-900 dark:text-gray-300"
>
{t(
"include_private_channels",
"Include private channels"
)}
</label>
</div>
</div>
</div>
<Button
type="submit"
Expand Down
12 changes: 10 additions & 2 deletions src/common/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ export const getPaymentsByAccount = (options: {
export const getSettings = () => msg.request<SettingsStorage>("getSettings");
export const getStatus = () => msg.request<StatusRes>("status");
export const getInfo = () => msg.request<NodeInfo>("getInfo");
export const makeInvoice = ({ amount, memo }: MakeInvoiceArgs) =>
msg.request<MakeInvoiceResponse["data"]>("makeInvoice", { amount, memo });
export const makeInvoice = ({
amount,
memo,
includePrivateChannels,
}: MakeInvoiceArgs) =>
msg.request<MakeInvoiceResponse["data"]>("makeInvoice", {
amount,
memo,
includePrivateChannels,
});
export const connectPeer = ({ host, pubkey }: ConnectPeerArgs) =>
msg.request<ConnectPeerResponse["data"]>("connectPeer", { host, pubkey });
export const setSetting = (setting: MessageSettingsSet["args"]["setting"]) =>
Expand Down
1 change: 1 addition & 0 deletions src/extension/background-script/actions/ln/makeInvoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const makeInvoice = async (message: MessageMakeInvoice) => {
const response = await connector.makeInvoice({
amount,
memo,
includePrivateChannels: message.args.includePrivateChannels,
});

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface ConnectorTransaction {
export interface MakeInvoiceArgs {
amount: string | number;
memo: string;
includePrivateChannels?: boolean;
}

export type MakeInvoiceResponse = {
Expand Down
1 change: 1 addition & 0 deletions src/extension/background-script/connectors/lnc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ class Lnc implements Connector {
const data = await this.lnc.lnd.lightning.addInvoice({
memo: args.memo,
value: args.amount.toString(),
private: args.includePrivateChannels,
});

return {
Expand Down
1 change: 1 addition & 0 deletions src/extension/background-script/connectors/lnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ class Lnd implements Connector {
{
memo: args.memo,
value: args.amount,
private: args.includePrivateChannels,
}
).then((data) => {
return {
Expand Down
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,12 @@ export interface MessageGetInfo extends MessageDefault {
}

export interface MessageMakeInvoice extends MessageDefault {
args: { memo?: string; defaultMemo?: string; amount?: string };
args: {
memo?: string;
defaultMemo?: string;
amount?: string;
includePrivateChannels?: boolean;
};
action: "makeInvoice";
}

Expand Down