Skip to content

Commit

Permalink
commands: add option to set the income channel on blinded path
Browse files Browse the repository at this point in the history
It was made general enough to specify chained channels hops.
  • Loading branch information
MPins committed Oct 21, 2024
1 parent 9da14ba commit 39688b8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/commands/cmd_invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"fmt"
"strconv"
"strings"

"github.com/lightningnetwork/lnd/lnrpc"
"github.com/urfave/cli"
Expand Down Expand Up @@ -116,6 +117,11 @@ var AddInvoiceCommand = cli.Command{
"use on a blinded path. The flag may be " +
"specified multiple times.",
},
cli.StringSliceFlag{
Name: "blinded_path_income_channel",
Usage: "The chained channels ids to be used in a " +
"blinded path as the income hops.",
},
},
Action: actionDecorator(addInvoice),
}
Expand Down Expand Up @@ -202,7 +208,8 @@ func parseBlindedPathCfg(ctx *cli.Context) (*lnrpc.BlindedPathConfig, error) {
if ctx.IsSet("min_real_blinded_hops") ||
ctx.IsSet("num_blinded_hops") ||
ctx.IsSet("max_blinded_paths") ||
ctx.IsSet("blinded_path_omit_node") {
ctx.IsSet("blinded_path_omit_node") ||
ctx.IsSet("blinded_path_income_channel") {

return nil, fmt.Errorf("blinded path options are " +
"only used if the `--blind` options is set")
Expand Down Expand Up @@ -238,6 +245,16 @@ func parseBlindedPathCfg(ctx *cli.Context) (*lnrpc.BlindedPathConfig, error) {
blindCfg.NodeOmissionList, pubKeyBytes,
)
}
channels := strings.Split(ctx.String("blinded_path_income_channel"), ",")
for _, chanId := range channels {
channelId, err := strconv.ParseUint(chanId, 10, 64)
if err != nil {
panic(err) // Handle this better in production code
}
blindCfg.ChannelIncomeList = append(
blindCfg.ChannelIncomeList, channelId,
)
}

return &blindCfg, nil
}
Expand Down

0 comments on commit 39688b8

Please sign in to comment.