Skip to content

Commit 57a5e49

Browse files
authored
Merge pull request #8994 from ellemouton/rbMicroFixes
Rb micro fixes
2 parents bbd313d + ab28cde commit 57a5e49

File tree

10 files changed

+1227
-1176
lines changed

10 files changed

+1227
-1176
lines changed

cmd/lncli/cmd_invoice.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func addInvoice(ctx *cli.Context) error {
183183
CltvExpiry: ctx.Uint64("cltv_expiry_delta"),
184184
Private: ctx.Bool("private"),
185185
IsAmp: ctx.Bool("amp"),
186+
IsBlinded: ctx.Bool("blind"),
186187
BlindedPathConfig: blindedPathCfg,
187188
}
188189

invoices/invoices.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ func (i *Invoice) IsAMP() bool {
489489
)
490490
}
491491

492+
// IsBlinded returns true if the invoice contains blinded paths.
493+
func (i *Invoice) IsBlinded() bool {
494+
if i.Terms.Features == nil {
495+
return false
496+
}
497+
498+
return i.Terms.Features.IsSet(lnwire.Bolt11BlindedPathsRequired)
499+
}
500+
492501
// HtlcState defines the states an htlc paying to an invoice can be in.
493502
type HtlcState uint8
494503

itest/lnd_route_blinding_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
382382
RPreimage: b.preimage[:],
383383
Memo: "test",
384384
ValueMsat: 10_000_000,
385+
IsBlinded: true,
385386
BlindedPathConfig: &lnrpc.BlindedPathConfig{
386387
MinNumRealHops: &minNumRealHops,
387388
NumHops: &numHops,
@@ -625,6 +626,7 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
625626
invoice := testCase.dave.RPC.AddInvoice(&lnrpc.Invoice{
626627
Memo: "test",
627628
ValueMsat: 10_000_000,
629+
IsBlinded: true,
628630
BlindedPathConfig: &lnrpc.BlindedPathConfig{
629631
MinNumRealHops: &minNumRealHops,
630632
NumHops: &numHops,
@@ -643,6 +645,7 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
643645
invoice = testCase.dave.RPC.AddInvoice(&lnrpc.Invoice{
644646
Memo: "test",
645647
ValueMsat: 10_000_000,
648+
IsBlinded: true,
646649
BlindedPathConfig: &lnrpc.BlindedPathConfig{
647650
MinNumRealHops: &minNumRealHops,
648651
NumHops: &numHops,
@@ -997,8 +1000,9 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
9971000
minNumRealHops uint32 = 1
9981001
)
9991002
invoice := &lnrpc.Invoice{
1000-
Memo: "test",
1001-
Value: int64(paymentAmt),
1003+
Memo: "test",
1004+
Value: int64(paymentAmt),
1005+
IsBlinded: true,
10021006
BlindedPathConfig: &lnrpc.BlindedPathConfig{
10031007
NumHops: &numHops,
10041008
MinNumRealHops: &minNumRealHops,
@@ -1167,8 +1171,9 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
11671171
numHops uint32 = 2
11681172
)
11691173
invoice := &lnrpc.Invoice{
1170-
Memo: "test",
1171-
Value: int64(paymentAmt),
1174+
Memo: "test",
1175+
Value: int64(paymentAmt),
1176+
IsBlinded: true,
11721177
BlindedPathConfig: &lnrpc.BlindedPathConfig{
11731178
MinNumRealHops: &minNumRealHops,
11741179
NumHops: &numHops,
@@ -1208,8 +1213,9 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
12081213
// that one dummy hop should be added.
12091214
minNumRealHops = 1
12101215
invoice = &lnrpc.Invoice{
1211-
Memo: "test",
1212-
Value: int64(paymentAmt),
1216+
Memo: "test",
1217+
Value: int64(paymentAmt),
1218+
IsBlinded: true,
12131219
BlindedPathConfig: &lnrpc.BlindedPathConfig{
12141220
MinNumRealHops: &minNumRealHops,
12151221
NumHops: &numHops,
@@ -1334,8 +1340,9 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
13341340
numHops uint32 = 1
13351341
)
13361342
invoice := &lnrpc.Invoice{
1337-
Memo: "test",
1338-
Value: int64(paymentAmt),
1343+
Memo: "test",
1344+
Value: int64(paymentAmt),
1345+
IsBlinded: true,
13391346
BlindedPathConfig: &lnrpc.BlindedPathConfig{
13401347
MinNumRealHops: &minNumRealHops,
13411348
NumHops: &numHops,

lnrpc/invoicesrpc/invoices.swagger.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,13 @@
607607
"description": "Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the\ngiven set ID. This field is always populated for AMP invoices, and can be\nused along side LookupInvoice to obtain the HTLC information related to a\ngiven sub-invoice.\nNote: Output only, don't specify for creating an invoice.",
608608
"title": "[EXPERIMENTAL]:"
609609
},
610+
"is_blinded": {
611+
"type": "boolean",
612+
"description": "Signals that the invoice should include blinded paths to hide the true\nidentity of the recipient."
613+
},
610614
"blinded_path_config": {
611615
"$ref": "#/definitions/lnrpcBlindedPathConfig",
612-
"description": "Signals that the invoice should include blinded paths to hide the true\nidentity of the recipient."
616+
"description": "Config values to use when creating blinded paths for this invoice. These\ncan be used to override the defaults config values provided in by the\nglobal config. This field is only used if is_blinded is true."
613617
}
614618
}
615619
},

lnrpc/invoicesrpc/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func CreateRPCInvoice(invoice *invoices.Invoice,
176176
IsKeysend: invoice.IsKeysend(),
177177
PaymentAddr: invoice.Terms.PaymentAddr[:],
178178
IsAmp: invoice.IsAMP(),
179+
IsBlinded: invoice.IsBlinded(),
179180
}
180181

181182
rpcInvoice.AmpInvoiceState = make(map[string]*lnrpc.AMPInvoiceState)

0 commit comments

Comments
 (0)