mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
commit
57a5e4912b
@ -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,
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
@ -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."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -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)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3843,7 +3843,14 @@ message Invoice {
|
||||
Signals that the invoice should include blinded paths to hide the true
|
||||
identity of the recipient.
|
||||
*/
|
||||
BlindedPathConfig blinded_path_config = 29;
|
||||
bool is_blinded = 29;
|
||||
|
||||
/*
|
||||
Config values to use when creating blinded paths for this invoice. These
|
||||
can be used to override the defaults config values provided in by the
|
||||
global config. This field is only used if is_blinded is true.
|
||||
*/
|
||||
BlindedPathConfig blinded_path_config = 30;
|
||||
}
|
||||
|
||||
message BlindedPathConfig {
|
||||
|
@ -5519,9 +5519,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."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -896,7 +896,7 @@ func padHopInfo(hopInfo []*hopData, prePad bool, minSize int) (
|
||||
|
||||
var (
|
||||
paymentPath = make([]*sphinx.HopInfo, len(hopInfo))
|
||||
stats padStats
|
||||
stats = padStats{finalPaddedSize: minSize}
|
||||
)
|
||||
|
||||
// Pre-pad each payload with zero byte padding (if it does not yet have
|
||||
|
@ -5781,7 +5781,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||
var (
|
||||
defaultDelta = r.cfg.Bitcoin.TimeLockDelta
|
||||
blindCfg = invoice.BlindedPathConfig
|
||||
blind = blindCfg != nil
|
||||
blind = invoice.IsBlinded
|
||||
)
|
||||
|
||||
globalBlindCfg := r.server.cfg.Routing.BlindedPaths
|
||||
@ -5792,7 +5792,12 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||
NodeOmissionSet: fn.NewSet[route.Vertex](),
|
||||
}
|
||||
|
||||
if blind {
|
||||
if blindCfg != nil && !blind {
|
||||
return nil, fmt.Errorf("blinded path config provided but " +
|
||||
"IsBlinded not set")
|
||||
}
|
||||
|
||||
if blind && blindCfg != nil {
|
||||
if blindCfg.MinNumRealHops != nil {
|
||||
blindingRestrictions.MinDistanceFromIntroNode =
|
||||
uint8(*blindCfg.MinNumRealHops)
|
||||
|
Loading…
Reference in New Issue
Block a user