mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02:00
rpc+funding: add taproot overlay as RPC chan type
This commit is contained in:
@@ -4653,8 +4653,8 @@ func testZeroConf(t *testing.T, chanType *lnwire.ChannelType) {
|
|||||||
// opening behavior with a specified fundmax flag. To give a hypothetical
|
// opening behavior with a specified fundmax flag. To give a hypothetical
|
||||||
// example, if ANCHOR types had been introduced after the fundmax flag had been
|
// 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
|
// 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
|
// funding manager in the context of public and private channels. Otherwise,
|
||||||
// inconsistent bahvior would have resulted when specifying fundmax for
|
// inconsistent behavior would have resulted when specifying fundmax for
|
||||||
// different types of channel openings.
|
// different types of channel openings.
|
||||||
// To ensure consistency this test compares a map of locally defined channel
|
// 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
|
// 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,
|
"ANCHORS": 3,
|
||||||
"SCRIPT_ENFORCED_LEASE": 4,
|
"SCRIPT_ENFORCED_LEASE": 4,
|
||||||
"SIMPLE_TAPROOT": 5,
|
"SIMPLE_TAPROOT": 5,
|
||||||
|
"SIMPLE_TAPROOT_OVERLAY": 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
for commitmentType := range lnrpc.CommitmentType_value {
|
for commitmentType := range lnrpc.CommitmentType_value {
|
||||||
|
27
rpcserver.go
27
rpcserver.go
@@ -2309,6 +2309,29 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
|||||||
|
|
||||||
*channelType = lnwire.ChannelType(*fv)
|
*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:
|
default:
|
||||||
return nil, fmt.Errorf("unhandled request channel type %v",
|
return nil, fmt.Errorf("unhandled request channel type %v",
|
||||||
in.CommitmentType)
|
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
|
// first check whether it has anchors, since in that case it would also
|
||||||
// be tweakless.
|
// be tweakless.
|
||||||
switch {
|
switch {
|
||||||
|
case chanType.HasTapscriptRoot():
|
||||||
|
return lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
|
||||||
|
|
||||||
case chanType.IsTaproot():
|
case chanType.IsTaproot():
|
||||||
return lnrpc.CommitmentType_SIMPLE_TAPROOT
|
return lnrpc.CommitmentType_SIMPLE_TAPROOT
|
||||||
|
|
||||||
@@ -4544,6 +4570,7 @@ func rpcCommitmentType(chanType channeldb.ChannelType) lnrpc.CommitmentType {
|
|||||||
|
|
||||||
case chanType.IsTweakless():
|
case chanType.IsTweakless():
|
||||||
return lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
return lnrpc.CommitmentType_STATIC_REMOTE_KEY
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
return lnrpc.CommitmentType_LEGACY
|
return lnrpc.CommitmentType_LEGACY
|
||||||
|
@@ -77,3 +77,53 @@ func TestAuxDataParser(t *testing.T) {
|
|||||||
require.NotNil(t, resp)
|
require.NotNil(t, resp)
|
||||||
require.Equal(t, []byte{0x00, 0x00}, resp.CustomChannelData)
|
require.Equal(t, []byte{0x00, 0x00}, resp.CustomChannelData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestRpcCommitmentType tests the rpcCommitmentType returns the corect
|
||||||
|
// commitment type given a channel type.
|
||||||
|
func TestRpcCommitmentType(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
chanType channeldb.ChannelType
|
||||||
|
want lnrpc.CommitmentType
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "tapscript overlay",
|
||||||
|
chanType: channeldb.SimpleTaprootFeatureBit |
|
||||||
|
channeldb.TapscriptRootBit,
|
||||||
|
want: lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "simple taproot",
|
||||||
|
chanType: channeldb.SimpleTaprootFeatureBit,
|
||||||
|
want: lnrpc.CommitmentType_SIMPLE_TAPROOT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "lease expiration",
|
||||||
|
chanType: channeldb.LeaseExpirationBit,
|
||||||
|
want: lnrpc.CommitmentType_SCRIPT_ENFORCED_LEASE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "anchors",
|
||||||
|
chanType: channeldb.AnchorOutputsBit,
|
||||||
|
want: lnrpc.CommitmentType_ANCHORS,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "tweakless",
|
||||||
|
chanType: channeldb.SingleFunderTweaklessBit,
|
||||||
|
want: lnrpc.CommitmentType_STATIC_REMOTE_KEY,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "legacy",
|
||||||
|
chanType: channeldb.SingleFunderBit,
|
||||||
|
want: lnrpc.CommitmentType_LEGACY,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
require.Equal(
|
||||||
|
t, tt.want, rpcCommitmentType(tt.chanType),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user