lnrpc: add new CommitmentType for script enforced leased channels

This commit is contained in:
Wilmer Paulino
2021-07-14 17:21:04 -07:00
committed by Olaoluwa Osuntokun
parent e1c269c7ed
commit c9f6d788e2
4 changed files with 425 additions and 392 deletions

View File

@ -1990,6 +1990,14 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
lnwire.AnchorsZeroFeeHtlcTxRequired,
))
case lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE:
channelType = new(lnwire.ChannelType)
*channelType = lnwire.ChannelType(*lnwire.NewRawFeatureVector(
lnwire.StaticRemoteKeyRequired,
lnwire.AnchorsZeroFeeHtlcTxRequired,
lnwire.ScriptEnforcedLeaseRequired,
))
default:
return nil, fmt.Errorf("unhandled request channel type %v",
in.CommitmentType)
@ -3737,6 +3745,10 @@ func rpcCommitmentType(chanType channeldb.ChannelType) lnrpc.CommitmentType {
// Extract the commitment type from the channel type flags. We must
// first check whether it has anchors, since in that case it would also
// be tweakless.
if chanType.HasLeaseExpiration() {
return lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE
}
if chanType.HasAnchors() {
return lnrpc.CommitmentType_ANCHORS
}