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:
6 files changed
+1966
-1878
No files matched your search
@@ -210,6 +210,16 @@ var openChannelCommand = cli.Command{
|
|||||||
"propose to the remote peer (%q, %q)",
|
"propose to the remote peer (%q, %q)",
|
||||||
channelTypeTweakless, channelTypeAnchors),
|
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),
|
Action: actionDecorator(openChannel),
|
||||||
}
|
}
|
||||||
@@ -249,6 +259,8 @@ func openChannel(ctx *cli.Context) error {
|
|||||||
CloseAddress: ctx.String("close_address"),
|
CloseAddress: ctx.String("close_address"),
|
||||||
RemoteMaxValueInFlightMsat: ctx.Uint64("remote_max_value_in_flight_msat"),
|
RemoteMaxValueInFlightMsat: ctx.Uint64("remote_max_value_in_flight_msat"),
|
||||||
MaxLocalCsv: uint32(ctx.Uint64("max_local_csv")),
|
MaxLocalCsv: uint32(ctx.Uint64("max_local_csv")),
|
||||||
|
ZeroConf: ctx.Bool("zero_conf"),
|
||||||
|
ScidAlias: ctx.Bool("scid_alias"),
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
+1897
-1873
File diff suppressed because it is too large.
Load diff
@@ -2121,6 +2121,17 @@ message OpenChannelRequest {
|
|||||||
the remote peer supports explicit channel negotiation.
|
the remote peer supports explicit channel negotiation.
|
||||||
*/
|
*/
|
||||||
CommitmentType commitment_type = 18;
|
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 {
|
message OpenStatusUpdate {
|
||||||
oneof update {
|
oneof update {
|
||||||
|
|||||||
@@ -5418,6 +5418,14 @@
|
|||||||
"commitment_type": {
|
"commitment_type": {
|
||||||
"$ref": "#/definitions/lnrpcCommitmentType",
|
"$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."
|
"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."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -989,6 +989,15 @@ type OpenChannelParams struct {
|
|||||||
// CommitmentType is the commitment type that should be used for the
|
// CommitmentType is the commitment type that should be used for the
|
||||||
// channel to be opened.
|
// channel to be opened.
|
||||||
CommitmentType lnrpc.CommitmentType
|
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
|
// 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,
|
FundingShim: p.FundingShim,
|
||||||
SatPerByte: int64(p.SatPerVByte),
|
SatPerByte: int64(p.SatPerVByte),
|
||||||
CommitmentType: p.CommitmentType,
|
CommitmentType: p.CommitmentType,
|
||||||
|
ZeroConf: p.ZeroConf,
|
||||||
|
ScidAlias: p.ScidAlias,
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to use n.runCtx here to keep the response stream alive after
|
// We need to use n.runCtx here to keep the response stream alive after
|
||||||
|
|||||||
+27
-5
@@ -2013,7 +2013,9 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
var channelType *lnwire.ChannelType
|
var channelType *lnwire.ChannelType
|
||||||
switch in.CommitmentType {
|
switch in.CommitmentType {
|
||||||
case lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE:
|
case lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE:
|
||||||
break
|
if in.ZeroConf {
|
||||||
|
return nil, fmt.Errorf("use anchors for zero-conf")
|
||||||
|
}
|
||||||
|
|
||||||
case lnrpc.CommitmentType_LEGACY:
|
case lnrpc.CommitmentType_LEGACY:
|
||||||
channelType = new(lnwire.ChannelType)
|
channelType = new(lnwire.ChannelType)
|
||||||
@@ -2027,18 +2029,38 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
|
|
||||||
case lnrpc.CommitmentType_ANCHORS:
|
case lnrpc.CommitmentType_ANCHORS:
|
||||||
channelType = new(lnwire.ChannelType)
|
channelType = new(lnwire.ChannelType)
|
||||||
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
fv := lnwire.NewRawFeatureVector(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
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:
|
case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE:
|
||||||
channelType = new(lnwire.ChannelType)
|
channelType = new(lnwire.ChannelType)
|
||||||
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
fv := lnwire.NewRawFeatureVector(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
lnwire.ScriptEnforcedLeaseRequired,
|
lnwire.ScriptEnforcedLeaseRequired,
|
||||||
))
|
)
|
||||||
|
|
||||||
|
if in.ZeroConf {
|
||||||
|
fv.Set(lnwire.ZeroConfRequired)
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.ScidAlias {
|
||||||
|
fv.Set(lnwire.ScidAliasRequired)
|
||||||
|
}
|
||||||
|
|
||||||
|
*channelType = lnwire.ChannelType(*fv)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unhandled request channel type %v",
|
return nil, fmt.Errorf("unhandled request channel type %v",
|
||||||
|
|||||||
Reference in new issue
Block a user