mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
watchtower: add new TaprootCommit Type and flag
This commit adds a new FlagTaprootChannel Flag which is then used to construct a new blob Type: TypeAltruistTaprootCommit. New watchtower feature bits are also added (4/5).
This commit is contained in:
@@ -125,6 +125,12 @@ func (p Policy) IsAnchorChannel() bool {
|
||||
return p.TxPolicy.BlobType.IsAnchorChannel()
|
||||
}
|
||||
|
||||
// IsTaprootChannel returns true if the session policy requires taproot
|
||||
// channels.
|
||||
func (p Policy) IsTaprootChannel() bool {
|
||||
return p.TxPolicy.BlobType.IsTaprootChannel()
|
||||
}
|
||||
|
||||
// Validate ensures that the policy satisfies some minimal correctness
|
||||
// constraints.
|
||||
func (p Policy) Validate() error {
|
||||
|
||||
@@ -93,20 +93,32 @@ func TestPolicyValidate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestPolicyIsAnchorChannel asserts that the IsAnchorChannel helper properly
|
||||
// reflects the anchor bit of the policy's blob type.
|
||||
func TestPolicyIsAnchorChannel(t *testing.T) {
|
||||
policyNoAnchor := wtpolicy.Policy{
|
||||
// TestPolicyIsChannelType asserts that the IsAnchorChannel and IsTaprootChannel
|
||||
// helpers properly reflect the anchor bit of the policy's blob type.
|
||||
func TestPolicyIsChannelType(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
policyLegacy := wtpolicy.Policy{
|
||||
TxPolicy: wtpolicy.TxPolicy{
|
||||
BlobType: blob.TypeAltruistCommit,
|
||||
},
|
||||
}
|
||||
require.Equal(t, false, policyNoAnchor.IsAnchorChannel())
|
||||
require.False(t, policyLegacy.IsAnchorChannel())
|
||||
require.False(t, policyLegacy.IsTaprootChannel())
|
||||
|
||||
policyAnchor := wtpolicy.Policy{
|
||||
TxPolicy: wtpolicy.TxPolicy{
|
||||
BlobType: blob.TypeAltruistAnchorCommit,
|
||||
},
|
||||
}
|
||||
require.Equal(t, true, policyAnchor.IsAnchorChannel())
|
||||
require.True(t, policyAnchor.IsAnchorChannel())
|
||||
require.False(t, policyAnchor.IsTaprootChannel())
|
||||
|
||||
policyTaproot := wtpolicy.Policy{
|
||||
TxPolicy: wtpolicy.TxPolicy{
|
||||
BlobType: blob.TypeAltruistTaprootCommit,
|
||||
},
|
||||
}
|
||||
require.True(t, policyTaproot.IsTaprootChannel())
|
||||
require.False(t, policyTaproot.IsAnchorChannel())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user