Skip to content

Commit

Permalink
Merge pull request #2414 from kaloudis/zeus-2371
Browse files Browse the repository at this point in the history
ZEUS-2371: LND v0.18.3: blinded paths for BOLT 11
  • Loading branch information
kaloudis authored Sep 18, 2024
2 parents c97804f + 82a7207 commit be25353
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 70 deletions.
1 change: 1 addition & 0 deletions backends/CLNRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export default class CLNRest {
supportsChannelBatching = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsBolt11BlindedRoutes = () => false;
supportsOffers = async () => {
const { configs } = await this.postRequest('/v1/listconfigs');

Expand Down
1 change: 1 addition & 0 deletions backends/CLightningREST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export default class CLightningREST extends LND {
supportsChannelBatching = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsBolt11BlindedRoutes = () => false;
supportsOffers = async () => {
const res = await this.getRequest('/v1/utility/listConfigs');
const supportsOffers: boolean = res['experimental-offers'] || false;
Expand Down
1 change: 1 addition & 0 deletions backends/Eclair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ export default class Eclair {
supportsChannelBatching = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsBolt11BlindedRoutes = () => false;
supportsOffers = () => false;
isLNDBased = () => false;
}
Expand Down
2 changes: 2 additions & 0 deletions backends/EmbeddedLND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default class EmbeddedLND extends LND {
memo: data.memo,
expiry: data.expiry,
is_amp: data.is_amp,
is_blinded: data.is_blinded,
is_private: data.private,
preimage: data.preimage,
route_hints: data.route_hints
Expand Down Expand Up @@ -299,5 +300,6 @@ export default class EmbeddedLND extends LND {
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
supportsOffers = () => false;
supportsBolt11BlindedRoutes = () => this.supports('v0.18.3');
isLNDBased = () => true;
}
2 changes: 2 additions & 0 deletions backends/LND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export default class LND {
value_msat: data.value_msat || Number(data.value) * 1000,
expiry: data.expiry,
is_amp: data.is_amp,
is_blinded: data.is_blinded,
private: data.private,
r_preimage: data.preimage
? Base64Utils.hexToBase64(data.preimage)
Expand Down Expand Up @@ -672,5 +673,6 @@ export default class LND {
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
supportsOffers = (): Promise<boolean> | boolean => false;
supportsBolt11BlindedRoutes = () => this.supports('v0.18.3');
isLNDBased = () => true;
}
2 changes: 2 additions & 0 deletions backends/LightningNodeConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default class LightningNodeConnect {
value_msat: data.value_msat || Number(data.value) * 1000,
expiry: data.expiry,
is_amp: data.is_amp,
is_blinded: data.is_blinded,
private: data.private,
r_preimage: data.preimage
? Base64Utils.hexToBase64(data.preimage)
Expand Down Expand Up @@ -494,5 +495,6 @@ export default class LightningNodeConnect {
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
supportsOffers = () => false;
supportsBolt11BlindedRoutes = () => this.supports('v0.18.3');
isLNDBased = () => true;
}
1 change: 1 addition & 0 deletions backends/LndHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default class LndHub extends LND {
supportsChannelBatching = () => true;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => false;
supportsBolt11BlindedRoutes = () => false;
supportsOffers = () => false;
isLNDBased = () => false;
}
1 change: 1 addition & 0 deletions backends/Spark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export default class Spark {
supportsChannelBatching = () => true;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
supportsBolt11BlindedRoutes = () => false;
supportsOffers = () => false;
isLNDBased = () => false;
}
2 changes: 2 additions & 0 deletions lndmobile/LndMobileInjection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export interface ILndMobileInjections {
memo,
expiry,
is_amp,
is_blinded,
is_private,
preimage,
route_hints
Expand All @@ -142,6 +143,7 @@ export interface ILndMobileInjections {
memo: string;
expiry?: number;
is_amp?: boolean;
is_blinded?: boolean;
is_private?: boolean;
preimage?: string;
route_hints?: lnrpc.IRouteHint[] | null;
Expand Down
3 changes: 3 additions & 0 deletions lndmobile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export const addInvoice = async ({
memo,
expiry = 3600,
is_amp,
is_blinded,
is_private,
preimage,
route_hints
Expand All @@ -577,6 +578,7 @@ export const addInvoice = async ({
memo: string;
expiry: number;
is_amp?: boolean;
is_blinded?: boolean;
is_private?: boolean;
preimage?: string;
route_hints?: lnrpc.IRouteHint[] | null;
Expand All @@ -597,6 +599,7 @@ export const addInvoice = async ({
private: is_private,
min_hop_hints: is_private ? 6 : 0,
is_amp,
is_blinded,
r_preimage: preimage ? Base64Utils.hexToBytes(preimage) : undefined,
route_hints
}
Expand Down
3 changes: 3 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@
"views.Receive.ampSwitchExplainer2": "Please note that AMP invoices are currently only compatible with LND nodes.",
"views.Receive.lspZeroAmt": "The LSP is incompatible with zero amounts. An unwrapped invoice has been generated. Your node's public key will be exposed.",
"views.Receive.createLightningAddress": "Create lightning address",
"views.Receive.blindedPaths": "Blinded paths",
"views.Receive.blindedPathsExplainer1": "Using blinded paths in your invoice is an advanced privacy technique that allows you to hide your node's' public key, which is typically revealed in most lightning invoices.",
"views.Receive.blindedPathsExplainer2": "Note that not all wallets support paying BOLT 11 invoices with blinded paths yet, and that the possiblity of payment success may decrease.",
"views.Send.title": "Send",
"views.Send.rPreimage": "R Preimage",
"views.Send.lnPayment": "Lightning payment request",
Expand Down
1 change: 1 addition & 0 deletions models/Invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class Invoice extends BaseModel {
public cltv_expiry: string;
public htlcs: Array<HTLC>;
public is_amp?: boolean;
public is_blinded?: boolean;
// c-lightning, eclair
public bolt11: string;
public label: string;
Expand Down
78 changes: 53 additions & 25 deletions stores/InvoicesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,45 @@ export default class InvoicesStore {
};

@action
public createUnifiedInvoice = (
memo: string,
value: string,
public createUnifiedInvoice = ({
memo,
value,
expiry = '3600',
lnurl?: LNURLWithdrawParams,
ampInvoice?: boolean,
routeHints?: boolean,
routeHintChannels?: Channel[],
addressType?: string,
customPreimage?: string,
noLsp?: boolean
) => {
lnurl,
ampInvoice,
blindedPaths,
routeHints,
routeHintChannels,
addressType,
customPreimage,
noLsp
}: {
memo: string;
value: string;
expiry: string;
lnurl?: LNURLWithdrawParams;
ampInvoice?: boolean;
blindedPaths?: boolean;
routeHints?: boolean;
routeHintChannels?: Channel[];
addressType?: string;
customPreimage?: string;
noLsp?: boolean;
}) => {
this.creatingInvoice = true;
return this.createInvoice(
return this.createInvoice({
memo,
value,
expiry,
lnurl,
ampInvoice,
blindedPaths,
routeHints,
routeHintChannels,
true,
unified: true,
customPreimage,
noLsp
).then(
}).then(
({
rHash,
paymentRequest
Expand Down Expand Up @@ -179,18 +193,31 @@ export default class InvoicesStore {
};

@action
public createInvoice = async (
memo: string,
value: string,
public createInvoice = async ({
memo,
value,
expiry = '3600',
lnurl?: LNURLWithdrawParams,
ampInvoice?: boolean,
routeHints?: boolean,
routeHintChannels?: Channel[],
unified?: boolean,
customPreimage?: string,
noLsp?: boolean
) => {
lnurl,
ampInvoice,
blindedPaths,
routeHints,
routeHintChannels,
unified,
customPreimage,
noLsp
}: {
memo: string;
value: string;
expiry: string;
lnurl?: LNURLWithdrawParams;
ampInvoice?: boolean;
blindedPaths?: boolean;
routeHints?: boolean;
routeHintChannels?: Channel[];
unified?: boolean;
customPreimage?: string;
noLsp?: boolean;
}) => {
this.lspStore?.resetFee();
this.payment_request = null;
this.payment_request_amt = null;
Expand All @@ -205,6 +232,7 @@ export default class InvoicesStore {
};

if (ampInvoice) req.is_amp = true;
if (blindedPaths) req.is_blinded = true;
if (routeHints) {
if (routeHintChannels?.length) {
const routeHints = [];
Expand Down
2 changes: 2 additions & 0 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface InvoicesSettings {
expirySeconds?: string;
routeHints?: boolean;
ampInvoice?: boolean;
blindedPaths: boolean;
showCustomPreimageField?: boolean;
}

Expand Down Expand Up @@ -1109,6 +1110,7 @@ export default class SettingsStore {
expirySeconds: '3600',
routeHints: false,
ampInvoice: false,
blindedPaths: false,
showCustomPreimageField: false
},
channels: {
Expand Down
2 changes: 2 additions & 0 deletions utils/BackendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class BackendUtils {
supportsOnchainBatching = () => this.call('supportsOnchainBatching');
supportsChannelBatching = () => this.call('supportsChannelBatching');
supportsOffers = () => this.call('supportsOffers');
supportsBolt11BlindedRoutes = () =>
this.call('supportsBolt11BlindedRoutes');
isLNDBased = () => this.call('isLNDBased');

// LNC
Expand Down
Loading

0 comments on commit be25353

Please sign in to comment.