multi: add zero-conf, scid-alias channel-types to rpc

This allows the open channel rpcs to use the zero-conf or scid-alias
channel types.
This commit is contained in:
eugene 2022-04-04 16:59:31 -04:00
parent b9ef26061a
commit 49dd4b9e34
No known key found for this signature in database
GPG Key ID: 118759E83439A9B1
6 changed files with 1966 additions and 1878 deletions

View File

@ -210,6 +210,16 @@ var openChannelCommand = cli.Command{
"propose to the remote peer (%q, %q)",
channelTypeTweakless, channelTypeAnchors),
},
cli.BoolFlag{
Name: "zero_conf",
Usage: "(optional) whether a zero-conf channel open " +
"should be attempted.",
},
cli.BoolFlag{
Name: "scid_alias",
Usage: "(optional) whether a scid-alias channel type" +
" should be negotiated.",
},
},
Action: actionDecorator(openChannel),
}
@ -249,6 +259,8 @@ func openChannel(ctx *cli.Context) error {
CloseAddress: ctx.String("close_address"),
RemoteMaxValueInFlightMsat: ctx.Uint64("remote_max_value_in_flight_msat"),
MaxLocalCsv: uint32(ctx.Uint64("max_local_csv")),
ZeroConf: ctx.Bool("zero_conf"),
ScidAlias: ctx.Bool("scid_alias"),
}
switch {

File diff suppressed because it is too large Load Diff

View File

@ -2121,6 +2121,17 @@ message OpenChannelRequest {
the remote peer supports explicit channel negotiation.
*/
CommitmentType commitment_type = 18;
/*
If this is true, then a zero-conf channel open will be attempted.
*/
bool zero_conf = 19;
/*
If this is true, then an option-scid-alias channel-type open will be
attempted.
*/
bool scid_alias = 20;
}
message OpenStatusUpdate {
oneof update {

View File

@ -5418,6 +5418,14 @@
"commitment_type": {
"$ref": "#/definitions/lnrpcCommitmentType",
"description": "The explicit commitment type to use. Note this field will only be used if\nthe remote peer supports explicit channel negotiation."
},
"zero_conf": {
"type": "boolean",
"description": "If this is true, then a zero-conf channel open will be attempted."
},
"scid_alias": {
"type": "boolean",
"description": "If this is true, then an option-scid-alias channel-type open will be\nattempted."
}
}
},

View File

@ -989,6 +989,15 @@ type OpenChannelParams struct {
// CommitmentType is the commitment type that should be used for the
// channel to be opened.
CommitmentType lnrpc.CommitmentType
// ZeroConf is used to determine if the channel will be a zero-conf
// channel. This only works if the explicit negotiation is used with
// anchors or script enforced leases.
ZeroConf bool
// ScidAlias denotes whether the channel will be an option-scid-alias
// channel type negotiation.
ScidAlias bool
}
// OpenChannel attempts to open a channel between srcNode and destNode with the
@ -1027,6 +1036,8 @@ func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
FundingShim: p.FundingShim,
SatPerByte: int64(p.SatPerVByte),
CommitmentType: p.CommitmentType,
ZeroConf: p.ZeroConf,
ScidAlias: p.ScidAlias,
}
// We need to use n.runCtx here to keep the response stream alive after

View File

@ -2013,7 +2013,9 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
var channelType *lnwire.ChannelType
switch in.CommitmentType {
case lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE:
break
if in.ZeroConf {
return nil, fmt.Errorf("use anchors for zero-conf")
}
case lnrpc.CommitmentType_LEGACY:
channelType = new(lnwire.ChannelType)
@ -2027,18 +2029,38 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
case lnrpc.CommitmentType_ANCHORS:
channelType = new(lnwire.ChannelType)
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
fv := lnwire.NewRawFeatureVector(
lnwire.StaticRemoteKeyRequired,
lnwire.AnchorsZeroFeeHtlcTxRequired,
))
)
if in.ZeroConf {
fv.Set(lnwire.ZeroConfRequired)
}
if in.ScidAlias {
fv.Set(lnwire.ScidAliasRequired)
}
*channelType = lnwire.ChannelType(*fv)
case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE:
channelType = new(lnwire.ChannelType)
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
fv := lnwire.NewRawFeatureVector(
lnwire.StaticRemoteKeyRequired,
lnwire.AnchorsZeroFeeHtlcTxRequired,
lnwire.ScriptEnforcedLeaseRequired,
))
)
if in.ZeroConf {
fv.Set(lnwire.ZeroConfRequired)
}
if in.ScidAlias {
fv.Set(lnwire.ScidAliasRequired)
}
*channelType = lnwire.ChannelType(*fv)
default:
return nil, fmt.Errorf("unhandled request channel type %v",