rpc+funding: add taproot overlay as RPC chan type

This commit is contained in:
Olaoluwa Osuntokun
2024-06-25 15:32:05 -07:00
parent d72de4cdbc
commit 2395c4d0a1
3 changed files with 80 additions and 2 deletions

View File

@@ -2309,6 +2309,29 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
*channelType = lnwire.ChannelType(*fv)
case lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY:
// If the taproot overlay channel type is being set, then the
// channel MUST be private.
if !in.Private {
return nil, fmt.Errorf("taproot overlay channels " +
"must be private")
}
channelType = new(lnwire.ChannelType)
fv := lnwire.NewRawFeatureVector(
lnwire.SimpleTaprootOverlayChansRequired,
)
if in.ZeroConf {
fv.Set(lnwire.ZeroConfRequired)
}
if in.ScidAlias {
fv.Set(lnwire.ScidAliasRequired)
}
*channelType = lnwire.ChannelType(*fv)
default:
return nil, fmt.Errorf("unhandled request channel type %v",
in.CommitmentType)
@@ -4533,6 +4556,9 @@ func rpcCommitmentType(chanType channeldb.ChannelType) lnrpc.CommitmentType {
// first check whether it has anchors, since in that case it would also
// be tweakless.
switch {
case chanType.HasTapscriptRoot():
return lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
case chanType.IsTaproot():
return lnrpc.CommitmentType_SIMPLE_TAPROOT
@@ -4544,6 +4570,7 @@ func rpcCommitmentType(chanType channeldb.ChannelType) lnrpc.CommitmentType {
case chanType.IsTweakless():
return lnrpc.CommitmentType_STATIC_REMOTE_KEY
default:
return lnrpc.CommitmentType_LEGACY