Documentation ¶
Index ¶
- Variables
- func BuildTapscriptTree(t *testing.T, useHashLock, valid bool, internalKey *btcec.PublicKey) (*txscript.TapLeaf, *waddrmgr.Tapscript, *psbt.TaprootTapLeafScript, []byte, ...)
- func BuildTapscriptTreeNoReveal(t *testing.T, internalKey *btcec.PublicKey) txscript.TapBranch
- func ComputeTaprootScript(t testing.TB, taprootKey *btcec.PublicKey) []byte
- func ComputeTaprootScriptErr(witnessProgram []byte) ([]byte, error)
- func HexPubKey(pk *btcec.PublicKey) string
- func HexSchnorrPubKey(pk *btcec.PublicKey) string
- func HexSignature(sig *schnorr.Signature) string
- func HexTx(t testing.TB, tx *wire.MsgTx) string
- func Parse32Byte(t testing.TB, b string) [32]byte
- func Parse33Byte(t testing.TB, b string) [33]byte
- func ParseChainHash(t testing.TB, hash string) chainhash.Hash
- func ParseHex(t testing.TB, b string) []byte
- func ParseOutPoint(t testing.TB, op string) wire.OutPoint
- func ParsePubKey(t testing.TB, key string) *btcec.PublicKey
- func ParseRPCKeyDescriptor(t testing.TB, rpcDesc *signrpc.KeyDescriptor) keychain.KeyDescriptor
- func ParseSchnorrPubKey(t testing.TB, key string) *btcec.PublicKey
- func ParseSchnorrSig(t testing.TB, sigHex string) *schnorr.Signature
- func ParseTestVectors(t testing.TB, fileName string, target any)
- func ParseTx(t testing.TB, tx string) *wire.MsgTx
- func PubToKeyDesc(p *btcec.PublicKey) keychain.KeyDescriptor
- func RandBool() bool
- func RandBytes(num int) []byte
- func RandCommitmentKeyRing(t *testing.T) lnwallet.CommitmentKeyRing
- func RandFlip[T any](t, f T) T
- func RandHash() chainhash.Hash
- func RandInt[T constraints.Integer]() T
- func RandInt31n(n int32) int32
- func RandIntn(n int) int
- func RandKeyDesc(t testing.TB) (keychain.KeyDescriptor, *btcec.PrivateKey)
- func RandKeyLoc() keychain.KeyLocator
- func RandOp(t testing.TB) wire.OutPoint
- func RandPrivKey() *btcec.PrivateKey
- func RandPubKey(t testing.TB) *btcec.PublicKey
- func RandRead(t testing.TB, b []byte)
- func RandTapLeaf(customScriptLen *int) txscript.TapLeaf
- func RandTxWitnesses(t testing.TB) wire.TxWitness
- func ReadTestDataFile(t *testing.T, fileName string) string
- func RunUnknownOddTypeTest[T any](t *testing.T, knownItem T, unknownTypeErr error, ...)
- func SchnorrKey(t testing.TB, pubKey *btcec.PublicKey) *btcec.PublicKey
- func SchnorrKeysEqual(t testing.TB, a, b *btcec.PublicKey) bool
- func SchnorrPubKey(t testing.TB, privKey *btcec.PrivateKey) *btcec.PublicKey
- func ScriptCltv(t *testing.T, cltv int64) txscript.TapLeaf
- func ScriptCltv0(t *testing.T) txscript.TapLeaf
- func ScriptCsv(t *testing.T, csv int64) txscript.TapLeaf
- func ScriptCsv0(t *testing.T) txscript.TapLeaf
- func ScriptHashLock(t *testing.T, preimage []byte) txscript.TapLeaf
- func ScriptSchnorrSig(t *testing.T, pubKey *btcec.PublicKey) txscript.TapLeaf
- func WriteTestFileHex(t testing.TB, fileName string, content []byte)
- func WriteTestVectors(t testing.TB, fileName string, target any)
Constants ¶
This section is empty.
Variables ¶
var ( HexCompressedPubKeyLen = hex.EncodedLen(btcec.PubKeyBytesLenCompressed) HexTaprootPkScript = hex.EncodedLen(input.P2TRSize) DefaultHashLockWitness = []byte("foobar") )
var ( // TestVectorAllowedUnknownType is a custom odd TLV type that can be // used in test vectors to verify that unknown odd types are allowed. TestVectorAllowedUnknownType tlv.Type = 31337 )
Functions ¶
func BuildTapscriptTree ¶ added in v0.4.0
func BuildTapscriptTree(t *testing.T, useHashLock, valid bool, internalKey *btcec.PublicKey) (*txscript.TapLeaf, *waddrmgr.Tapscript, *psbt.TaprootTapLeafScript, []byte, []byte)
BuildTapscriptTree builds a Tapscript tree with two leaves, a hash lock script and a signature verification script. It also returns the data needed to satisfy one of the two leaves.
func BuildTapscriptTreeNoReveal ¶ added in v0.4.0
BuildTapscriptTreeNoReveal builds a Tapscript tree with two leaves, a hash lock script and a signature verification script.
func ComputeTaprootScript ¶
func ComputeTaprootScriptErr ¶ added in v0.3.0
func HexSchnorrPubKey ¶ added in v0.3.0
func HexSchnorrPubKey(pk *btcec.PublicKey) string
func HexSignature ¶ added in v0.3.0
func ParsePubKey ¶ added in v0.3.0
func ParseRPCKeyDescriptor ¶
func ParseRPCKeyDescriptor(t testing.TB, rpcDesc *signrpc.KeyDescriptor) keychain.KeyDescriptor
func ParseSchnorrPubKey ¶ added in v0.3.0
func ParseSchnorrSig ¶ added in v0.3.0
func ParseTestVectors ¶ added in v0.3.0
func PubToKeyDesc ¶
func PubToKeyDesc(p *btcec.PublicKey) keychain.KeyDescriptor
func RandCommitmentKeyRing ¶ added in v0.5.0
func RandCommitmentKeyRing(t *testing.T) lnwallet.CommitmentKeyRing
func RandFlip ¶ added in v0.4.0
func RandFlip[T any](t, f T) T
RandFlip picks one of two values randomly.
func RandInt ¶
func RandInt[T constraints.Integer]() T
RandInt makes a random integer of the specified type.
func RandInt31n ¶ added in v0.3.0
RandInt31n returns a random 32-bit integer in the range [0, n).
func RandKeyDesc ¶ added in v0.4.0
func RandKeyDesc(t testing.TB) (keychain.KeyDescriptor, *btcec.PrivateKey)
func RandKeyLoc ¶ added in v0.5.0
func RandKeyLoc() keychain.KeyLocator
func RandPrivKey ¶
func RandPrivKey() *btcec.PrivateKey
func RandPubKey ¶
func RandTapLeaf ¶ added in v0.4.0
func ReadTestDataFile ¶ added in v0.4.0
ReadTestDataFile reads a file from the testdata directory and returns its content as a string.
func RunUnknownOddTypeTest ¶ added in v0.5.0
func RunUnknownOddTypeTest[T any](t *testing.T, knownItem T, unknownTypeErr error, encode func(*bytes.Buffer, T) error, decode func(*bytes.Buffer) (T, error), verify func(T, tlv.TypeMap))
RunUnknownOddTypeTest is a generic test that can be used to test the behavior of a TLV decoding function when an unknown odd type is encountered. The test will encode a known item, add an unknown even type to the encoded bytes, and verify that the decoding function returns an error. It will then encode the known item again, add an unknown odd type, and verify that the decoding function returns the expected item and unknown types.
func SchnorrKey ¶
func SchnorrKeysEqual ¶ added in v0.4.0
func SchnorrPubKey ¶
func ScriptCltv ¶ added in v0.4.0
ScriptCltv returns a simple bitcoin script that locks the funds with a CLTV lock until the given block height.
func ScriptCltv0 ¶ added in v0.4.0
ScriptCltv0 returns a simple bitcoin script that locks the funds with a CLTV lock until block height 0. The script is explicitly invalid as it should return a clean stack error on evaluation.
func ScriptCsv ¶ added in v0.4.0
ScriptCsv returns a simple bitcoin script that locks the funds with a CSV lock for the given number of blocks.
func ScriptCsv0 ¶ added in v0.4.0
ScriptCsv0 returns a simple bitcoin script that locks the funds with a CSV lock for the zero blocks. The script is explicitly invalid as it should return a clean stack error on evaluation.
func ScriptHashLock ¶
ScriptHashLock returns a simple bitcoin script that locks the funds to a hash lock of the given preimage.
func ScriptSchnorrSig ¶
ScriptSchnorrSig returns a simple bitcoin script that locks the funds to a Schnorr signature of the given public key.
func WriteTestFileHex ¶ added in v0.3.0
Types ¶
This section is empty.