input: create new ScriptDesciptor interface
In this commit, we add a new interface, the `ScriptDesciptor` to abstract over details of a given output script. The purpose of this interface, and the taproot superset, is to be able to paper over the differences of a p2wsh vs a p2tr output. With this new interface, we can treat them as the same, but then use a type assertion to get at any control block related methods if needed.
This commit is contained in:
2 files changed
+126
-1
No files matched your search
+14
-1
@@ -1,8 +1,21 @@
|
||||
package lnutils
|
||||
|
||||
// PTr returns the pointer of the given value. This is useful in instances
|
||||
// Ptr returns the pointer of the given value. This is useful in instances
|
||||
// where a function returns the value, but a pointer is wanted. Without this,
|
||||
// then an intermediate variable is needed.
|
||||
func Ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
// ByteArray is a type constraint for type that reduces down to a fixed sized
|
||||
// array.
|
||||
type ByteArray interface {
|
||||
~[32]byte
|
||||
}
|
||||
|
||||
// ByteSlice takes a byte array, and returns a slice. This is useful when a
|
||||
// function returns an array, but a slice is wanted. Without this, then an
|
||||
// intermediate variable is needed.
|
||||
func ByteSlice[T ByteArray](v T) []byte {
|
||||
return v[:]
|
||||
}
|
||||
Reference in new issue
Block a user