rpc: add new commitment_type field to OpenChannelRequest

This field will be examined later down the stack along with the set of
feature bits to determine if explicit channel commitment type
negotiation is possible or not.
This commit is contained in:
Olaoluwa Osuntokun committed 2021-08-30 19:17:28 -07:00
1 parent d0779e2ec2
commit 5a9f499dd5
5 files changed
+671 -612

No files matched your search

+28
View File
@@ -1912,6 +1912,33 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
err)
}
var channelType *lnwire.ChannelType
switch in.CommitmentType {
case lnrpc.CommitmentType_UNKNOWN_COMMITMENT_TYPE:
break
case lnrpc.CommitmentType_LEGACY:
channelType = new(lnwire.ChannelType)
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector())
case lnrpc.CommitmentType_STATIC_REMOTE_KEY:
channelType = new(lnwire.ChannelType)
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
lnwire.StaticRemoteKeyRequired,
))
case lnrpc.CommitmentType_ANCHORS:
channelType = new(lnwire.ChannelType)
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
lnwire.StaticRemoteKeyRequired,
lnwire.AnchorsZeroFeeHtlcTxRequired,
))
default:
return nil, fmt.Errorf("unhandled request channel type %v",
in.CommitmentType)
}
// Instruct the server to trigger the necessary events to attempt to
// open a new channel. A stream is returned in place, this stream will
// be used to consume updates of the state of the pending channel.
@@ -1929,6 +1956,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
MaxValueInFlight: maxValue,
MaxHtlcs: maxHtlcs,
MaxLocalCsv: uint16(in.MaxLocalCsv),
ChannelType: channelType,
}, nil
}