Skip to content

Commit 8fbb4dd

Browse files
committed
commands: add option to set the income node or channel on blinded path
1 parent 7632da5 commit 8fbb4dd

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

cmd/commands/cmd_invoice.go

+47-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ var AddInvoiceCommand = cli.Command{
116116
"use on a blinded path. The flag may be " +
117117
"specified multiple times.",
118118
},
119+
cli.StringSliceFlag{
120+
Name: "blinded_path_income_node",
121+
Usage: "The pub key (in hex) of a node to be " +
122+
"used in a blinded path as the income " +
123+
"node. The flag may be specified multiple " +
124+
"times.",
125+
},
126+
cli.StringSliceFlag{
127+
Name: "blinded_path_income_channel",
128+
Usage: "The channel id to be used in a blinded path " +
129+
"as the income channel. The flag may be " +
130+
"specified multiple times.",
131+
},
119132
},
120133
Action: actionDecorator(addInvoice),
121134
}
@@ -202,7 +215,9 @@ func parseBlindedPathCfg(ctx *cli.Context) (*lnrpc.BlindedPathConfig, error) {
202215
if ctx.IsSet("min_real_blinded_hops") ||
203216
ctx.IsSet("num_blinded_hops") ||
204217
ctx.IsSet("max_blinded_paths") ||
205-
ctx.IsSet("blinded_path_omit_node") {
218+
ctx.IsSet("blinded_path_omit_node") ||
219+
ctx.IsSet("blinded_path_income_node") ||
220+
ctx.IsSet("blinded_path_income_channel") {
206221

207222
return nil, fmt.Errorf("blinded path options are " +
208223
"only used if the `--blind` options is set")
@@ -211,6 +226,16 @@ func parseBlindedPathCfg(ctx *cli.Context) (*lnrpc.BlindedPathConfig, error) {
211226
return nil, nil
212227
}
213228

229+
if ctx.IsSet("blinded_path_income_channel") {
230+
if ctx.IsSet("blinded_path_income_node") {
231+
232+
return nil, fmt.Errorf("`--blinded_path_income_node`" +
233+
"is used only if the " +
234+
"`--blinded_path_income_channel` is not")
235+
236+
}
237+
}
238+
214239
var blindCfg lnrpc.BlindedPathConfig
215240

216241
if ctx.IsSet("min_real_blinded_hops") {
@@ -239,6 +264,27 @@ func parseBlindedPathCfg(ctx *cli.Context) (*lnrpc.BlindedPathConfig, error) {
239264
)
240265
}
241266

267+
for _, pK := range ctx.StringSlice("blinded_path_income_node") {
268+
pKBytes, err := hex.DecodeString(pK)
269+
if err != nil {
270+
return nil, err
271+
}
272+
273+
blindCfg.NodeIncomeList = append(
274+
blindCfg.NodeIncomeList, pKBytes,
275+
)
276+
}
277+
278+
for _, chanId := range ctx.StringSlice("blinded_path_income_channel") {
279+
channelId, err := strconv.ParseUint(chanId, 10, 64)
280+
if err != nil {
281+
panic(err) // Handle this better in production code
282+
}
283+
blindCfg.ChannelIncomeList = append(
284+
blindCfg.ChannelIncomeList, channelId,
285+
)
286+
}
287+
242288
return &blindCfg, nil
243289
}
244290

0 commit comments

Comments
 (0)