Skip to content

Commit

Permalink
Merge pull request #8994 from ellemouton/rbMicroFixes
Browse files Browse the repository at this point in the history
Rb micro fixes
  • Loading branch information
Roasbeef committed Aug 8, 2024
2 parents bbd313d + ab28cde commit 57a5e49
Show file tree
Hide file tree
Showing 10 changed files with 1,227 additions and 1,176 deletions.
1 change: 1 addition & 0 deletions cmd/lncli/cmd_invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func addInvoice(ctx *cli.Context) error {
CltvExpiry: ctx.Uint64("cltv_expiry_delta"),
Private: ctx.Bool("private"),
IsAmp: ctx.Bool("amp"),
IsBlinded: ctx.Bool("blind"),
BlindedPathConfig: blindedPathCfg,
}

Expand Down
9 changes: 9 additions & 0 deletions invoices/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,15 @@ func (i *Invoice) IsAMP() bool {
)
}

// IsBlinded returns true if the invoice contains blinded paths.
func (i *Invoice) IsBlinded() bool {
if i.Terms.Features == nil {
return false
}

return i.Terms.Features.IsSet(lnwire.Bolt11BlindedPathsRequired)
}

// HtlcState defines the states an htlc paying to an invoice can be in.
type HtlcState uint8

Expand Down
23 changes: 15 additions & 8 deletions itest/lnd_route_blinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
RPreimage: b.preimage[:],
Memo: "test",
ValueMsat: 10_000_000,
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
MinNumRealHops: &minNumRealHops,
NumHops: &numHops,
Expand Down Expand Up @@ -625,6 +626,7 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
invoice := testCase.dave.RPC.AddInvoice(&lnrpc.Invoice{
Memo: "test",
ValueMsat: 10_000_000,
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
MinNumRealHops: &minNumRealHops,
NumHops: &numHops,
Expand All @@ -643,6 +645,7 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
invoice = testCase.dave.RPC.AddInvoice(&lnrpc.Invoice{
Memo: "test",
ValueMsat: 10_000_000,
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
MinNumRealHops: &minNumRealHops,
NumHops: &numHops,
Expand Down Expand Up @@ -997,8 +1000,9 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
minNumRealHops uint32 = 1
)
invoice := &lnrpc.Invoice{
Memo: "test",
Value: int64(paymentAmt),
Memo: "test",
Value: int64(paymentAmt),
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
NumHops: &numHops,
MinNumRealHops: &minNumRealHops,
Expand Down Expand Up @@ -1167,8 +1171,9 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
numHops uint32 = 2
)
invoice := &lnrpc.Invoice{
Memo: "test",
Value: int64(paymentAmt),
Memo: "test",
Value: int64(paymentAmt),
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
MinNumRealHops: &minNumRealHops,
NumHops: &numHops,
Expand Down Expand Up @@ -1208,8 +1213,9 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
// that one dummy hop should be added.
minNumRealHops = 1
invoice = &lnrpc.Invoice{
Memo: "test",
Value: int64(paymentAmt),
Memo: "test",
Value: int64(paymentAmt),
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
MinNumRealHops: &minNumRealHops,
NumHops: &numHops,
Expand Down Expand Up @@ -1334,8 +1340,9 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
numHops uint32 = 1
)
invoice := &lnrpc.Invoice{
Memo: "test",
Value: int64(paymentAmt),
Memo: "test",
Value: int64(paymentAmt),
IsBlinded: true,
BlindedPathConfig: &lnrpc.BlindedPathConfig{
MinNumRealHops: &minNumRealHops,
NumHops: &numHops,
Expand Down
6 changes: 5 additions & 1 deletion lnrpc/invoicesrpc/invoices.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,13 @@
"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.",
"title": "[EXPERIMENTAL]:"
},
"is_blinded": {
"type": "boolean",
"description": "Signals that the invoice should include blinded paths to hide the true\nidentity of the recipient."
},
"blinded_path_config": {
"$ref": "#/definitions/lnrpcBlindedPathConfig",
"description": "Signals that the invoice should include blinded paths to hide the true\nidentity of the recipient."
"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."
}
}
},
Expand Down
1 change: 1 addition & 0 deletions lnrpc/invoicesrpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func CreateRPCInvoice(invoice *invoices.Invoice,
IsKeysend: invoice.IsKeysend(),
PaymentAddr: invoice.Terms.PaymentAddr[:],
IsAmp: invoice.IsAMP(),
IsBlinded: invoice.IsBlinded(),
}

rpcInvoice.AmpInvoiceState = make(map[string]*lnrpc.AMPInvoiceState)
Expand Down
Loading

0 comments on commit 57a5e49

Please sign in to comment.