From 8045595947d0fbe6aafaeec43fe9338ba2b96733 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 25 Jun 2024 15:32:05 -0700 Subject: [PATCH] rpc+funding: add taproot overlay as RPC chan type --- funding/manager_test.go | 5 +++-- rpcserver.go | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/funding/manager_test.go b/funding/manager_test.go index ca598cec75..dbe6353770 100644 --- a/funding/manager_test.go +++ b/funding/manager_test.go @@ -4653,8 +4653,8 @@ func testZeroConf(t *testing.T, chanType *lnwire.ChannelType) { // opening behavior with a specified fundmax flag. To give a hypothetical // example, if ANCHOR types had been introduced after the fundmax flag had been // activated, the developer would have had to code for the anchor reserve in the -// funding manager in the context of public and private channels. Otherwise -// inconsistent bahvior would have resulted when specifying fundmax for +// funding manager in the context of public and private channels. Otherwise, +// inconsistent behavior would have resulted when specifying fundmax for // different types of channel openings. // To ensure consistency this test compares a map of locally defined channel // commitment types to the list of channel types that are defined in the proto @@ -4670,6 +4670,7 @@ func TestCommitmentTypeFundmaxSanityCheck(t *testing.T) { "ANCHORS": 3, "SCRIPT_ENFORCED_LEASE": 4, "SIMPLE_TAPROOT": 5, + "SIMPLE_TAPROOT_OVERLAY": 6, } for commitmentType := range lnrpc.CommitmentType_value { diff --git a/rpcserver.go b/rpcserver.go index 5a1569a281..dbd8424fba 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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) @@ -4536,6 +4559,9 @@ func rpcCommitmentType(chanType channeldb.ChannelType) lnrpc.CommitmentType { case chanType.IsTaproot(): return lnrpc.CommitmentType_SIMPLE_TAPROOT + case chanType.HasTapscriptRoot(): + return lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY + case chanType.HasLeaseExpiration(): return lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE