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
2021-03-03 19:39:53 -08:00
parent d0779e2ec2
commit 5a9f499dd5
5 changed files with 671 additions and 612 deletions

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
}