lncli: add channel type flag to openchannel command

This commit is contained in:
Wilmer Paulino 2021-07-30 14:49:57 -07:00 committed by Olaoluwa Osuntokun
parent 523eef5cf4
commit 3299af7919
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306

View File

@ -57,6 +57,9 @@ Signed base64 encoded PSBT or hex encoded raw wire TX (or path to text file): `
// the user from choosing a large file by accident and running into out
// of memory issues or other weird errors.
psbtMaxFileSize = 1024 * 1024
channelTypeTweakless = "tweakless"
channelTypeAnchors = "anchors"
)
// TODO(roasbeef): change default number of confirmations
@ -200,6 +203,12 @@ var openChannelCommand = cli.Command{
Usage: "(optional) the maximum value in msat that " +
"can be pending within the channel at any given time",
},
cli.StringFlag{
Name: "channel_type",
Usage: fmt.Sprintf("(optional) the type of channel to "+
"propose to the remote peer (%q, %q)",
channelTypeTweakless, channelTypeAnchors),
},
},
Action: actionDecorator(openChannel),
}
@ -307,6 +316,19 @@ func openChannel(ctx *cli.Context) error {
req.Private = ctx.Bool("private")
// Parse the channel type and map it to its RPC representation.
channelType := ctx.String("channel_type")
switch channelType {
case "":
break
case channelTypeTweakless:
req.CommitmentType = lnrpc.CommitmentType_STATIC_REMOTE_KEY
case channelTypeAnchors:
req.CommitmentType = lnrpc.CommitmentType_ANCHORS
default:
return fmt.Errorf("unsupported channel type %v", channelType)
}
// PSBT funding is a more involved, interactive process that is too
// large to also fit into this already long function.
if ctx.Bool("psbt") {