chanacceptor+lnrpc: update the commitmentTypes, send zero-conf to client
This updates the RPCAcceptor to send the correct commitment type even if the zero-conf or scid-alias channel types are set. This also adds two bools to the ChannelAcceptRequest struct that denotes whether the funder set the zero-conf and scid-alias channel types.
This commit is contained in:
4 files changed
+2676
-2566
No files matched your search
@@ -258,20 +258,73 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error,
|
|||||||
pendingChanID := req.OpenChanMsg.PendingChannelID
|
pendingChanID := req.OpenChanMsg.PendingChannelID
|
||||||
|
|
||||||
// Map the channel commitment type to its RPC
|
// Map the channel commitment type to its RPC
|
||||||
// counterpart.
|
// counterpart. Also determine whether the zero-conf or
|
||||||
var commitmentType lnrpc.CommitmentType
|
// scid-alias channel types are set.
|
||||||
|
var (
|
||||||
|
commitmentType lnrpc.CommitmentType
|
||||||
|
wantsZeroConf bool
|
||||||
|
wantsScidAlias bool
|
||||||
|
)
|
||||||
|
|
||||||
if req.OpenChanMsg.ChannelType != nil {
|
if req.OpenChanMsg.ChannelType != nil {
|
||||||
channelFeatures := lnwire.RawFeatureVector(
|
channelFeatures := lnwire.RawFeatureVector(
|
||||||
*req.OpenChanMsg.ChannelType,
|
*req.OpenChanMsg.ChannelType,
|
||||||
)
|
)
|
||||||
switch {
|
switch {
|
||||||
case channelFeatures.OnlyContains(
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ZeroConfRequired,
|
||||||
|
lnwire.ScidAliasRequired,
|
||||||
lnwire.ScriptEnforcedLeaseRequired,
|
lnwire.ScriptEnforcedLeaseRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
):
|
):
|
||||||
commitmentType = lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE
|
commitmentType = lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE
|
||||||
|
|
||||||
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ZeroConfRequired,
|
||||||
|
lnwire.ScriptEnforcedLeaseRequired,
|
||||||
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
):
|
||||||
|
commitmentType = lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE
|
||||||
|
|
||||||
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ScidAliasRequired,
|
||||||
|
lnwire.ScriptEnforcedLeaseRequired,
|
||||||
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
):
|
||||||
|
commitmentType = lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE
|
||||||
|
|
||||||
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ScriptEnforcedLeaseRequired,
|
||||||
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
):
|
||||||
|
commitmentType = lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE
|
||||||
|
|
||||||
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ZeroConfRequired,
|
||||||
|
lnwire.ScidAliasRequired,
|
||||||
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
):
|
||||||
|
commitmentType = lnrpc.CommitmentType_ANCHORS
|
||||||
|
|
||||||
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ZeroConfRequired,
|
||||||
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
):
|
||||||
|
commitmentType = lnrpc.CommitmentType_ANCHORS
|
||||||
|
|
||||||
|
case channelFeatures.OnlyContains(
|
||||||
|
lnwire.ScidAliasRequired,
|
||||||
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
):
|
||||||
|
commitmentType = lnrpc.CommitmentType_ANCHORS
|
||||||
|
|
||||||
case channelFeatures.OnlyContains(
|
case channelFeatures.OnlyContains(
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
@@ -291,6 +344,20 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error,
|
|||||||
"in channel acceptor request: %v",
|
"in channel acceptor request: %v",
|
||||||
req.OpenChanMsg.ChannelType)
|
req.OpenChanMsg.ChannelType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if channelFeatures.IsSet(
|
||||||
|
lnwire.ZeroConfRequired,
|
||||||
|
) {
|
||||||
|
|
||||||
|
wantsZeroConf = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if channelFeatures.IsSet(
|
||||||
|
lnwire.ScidAliasRequired,
|
||||||
|
) {
|
||||||
|
|
||||||
|
wantsScidAlias = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acceptRequests[pendingChanID] = newRequest
|
acceptRequests[pendingChanID] = newRequest
|
||||||
@@ -311,6 +378,8 @@ func (r *RPCAcceptor) sendAcceptRequests(errChan chan error,
|
|||||||
MaxAcceptedHtlcs: uint32(req.OpenChanMsg.MaxAcceptedHTLCs),
|
MaxAcceptedHtlcs: uint32(req.OpenChanMsg.MaxAcceptedHTLCs),
|
||||||
ChannelFlags: uint32(req.OpenChanMsg.ChannelFlags),
|
ChannelFlags: uint32(req.OpenChanMsg.ChannelFlags),
|
||||||
CommitmentType: commitmentType,
|
CommitmentType: commitmentType,
|
||||||
|
WantsZeroConf: wantsZeroConf,
|
||||||
|
WantsScidAlias: wantsScidAlias,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.send(chanAcceptReq); err != nil {
|
if err := r.send(chanAcceptReq); err != nil {
|
||||||
|
|||||||
+2589
-2564
File diff suppressed because it is too large.
Load diff
@@ -926,6 +926,14 @@ message ChannelAcceptRequest {
|
|||||||
|
|
||||||
// The commitment type the initiator wishes to use for the proposed channel.
|
// The commitment type the initiator wishes to use for the proposed channel.
|
||||||
CommitmentType commitment_type = 14;
|
CommitmentType commitment_type = 14;
|
||||||
|
|
||||||
|
// Whether the initiator wants to open a zero-conf channel via the channel
|
||||||
|
// type.
|
||||||
|
bool wants_zero_conf = 15;
|
||||||
|
|
||||||
|
// Whether the initiator wants to use the scid-alias channel type. This is
|
||||||
|
// separate from the feature bit.
|
||||||
|
bool wants_scid_alias = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ChannelAcceptResponse {
|
message ChannelAcceptResponse {
|
||||||
|
|||||||
@@ -3423,6 +3423,14 @@
|
|||||||
"commitment_type": {
|
"commitment_type": {
|
||||||
"$ref": "#/definitions/lnrpcCommitmentType",
|
"$ref": "#/definitions/lnrpcCommitmentType",
|
||||||
"description": "The commitment type the initiator wishes to use for the proposed channel."
|
"description": "The commitment type the initiator wishes to use for the proposed channel."
|
||||||
|
},
|
||||||
|
"wants_zero_conf": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether the initiator wants to open a zero-conf channel via the channel\ntype."
|
||||||
|
},
|
||||||
|
"wants_scid_alias": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether the initiator wants to use the scid-alias channel type. This is\nseparate from the feature bit."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user