Documentation
¶
Index ¶
- Variables
- func AssertCopyEqual[T fn.Copyable[T]](t *testing.T, debug, strict bool, original T)
- 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 FillFakeData[T any](t *testing.T, debug bool, maxDepth int, v T)
- 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 StartMockGRPCServer(t *testing.T, grpcServer *grpc.Server, withTLS bool) (string, func(), error)
- func StartMockGRPCServerWithAddr(t *testing.T, grpcServer *grpc.Server, withTLS bool, listenAddr string) (func(), error)
- func WriteTestFileHex(t testing.TB, fileName string, content []byte)
- func WriteTestVectors(t testing.TB, fileName string, target any)
- type MockSigner
- func (s *MockSigner) DeriveSharedKey(context.Context, *btcec.PublicKey, *keychain.KeyLocator) ([32]byte, error)
- func (s *MockSigner) MuSig2Cleanup(context.Context, [32]byte) error
- func (s *MockSigner) MuSig2CombineSig(context.Context, [32]byte, [][]byte) (bool, []byte, error)
- func (s *MockSigner) MuSig2CreateSession(context.Context, input.MuSig2Version, *keychain.KeyLocator, [][]byte, ...) (*input.MuSig2SessionInfo, error)
- func (s *MockSigner) MuSig2RegisterNonces(context.Context, [32]byte, [][66]byte) (bool, error)
- func (s *MockSigner) MuSig2Sign(context.Context, [32]byte, [32]byte, bool) ([]byte, error)
- func (s *MockSigner) RawClientWithMacAuth(ctx context.Context) (context.Context, time.Duration, signrpc.SignerClient)
- func (s *MockSigner) SignMessage(_ context.Context, _ []byte, _ keychain.KeyLocator, ...) ([]byte, error)
- func (s *MockSigner) SignOutputRaw(_ context.Context, tx *wire.MsgTx, signDescriptors []*lndclient.SignDescriptor, ...) ([][]byte, error)
- func (s *MockSigner) VerifyMessage(_ context.Context, msg, sig []byte, _ [33]byte, ...) (bool, error)
- type SignOutputRawRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ListenAddrTemplate is the template for the address the mock server // listens on. ListenAddrTemplate = "127.0.0.1:%d" // StartupWaitTime is the time we wait for the server to start up. StartupWaitTime = 50 * time.Millisecond )
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 AssertCopyEqual ¶ added in v0.6.0
AssertCopyEqual checks that the Copy method returns a value that: 1) is deeply equal 2) does not alias mutable fields (pointers, slices, maps)
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 FillFakeData ¶ added in v0.6.0
FillFakeData recursively fills a struct with dummy values.
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 StartMockGRPCServer ¶ added in v0.6.0
func StartMockGRPCServer(t *testing.T, grpcServer *grpc.Server, withTLS bool) (string, func(), error)
StartMockGRPCServer starts a mock gRPC server on a free port and returns the address it's listening on. The caller should clean up the server by calling the cleanup function.
func StartMockGRPCServerWithAddr ¶
func StartMockGRPCServerWithAddr(t *testing.T, grpcServer *grpc.Server, withTLS bool, listenAddr string) (func(), error)
StartMockGRPCServerWithAddr starts a mock gRPC server on the given address and returns the address it's listening on. The caller should clean up the server by calling the cleanup function.
func WriteTestFileHex ¶ added in v0.3.0
Types ¶
type MockSigner ¶
type MockSigner struct {
lndclient.SignerClient
SignOutputRawChannel chan SignOutputRawRequest
Signature []byte
// SignMessageErr holds the error returned by SignMessage, if any.
SignMessageErr error
SignatureMsg string
}
func NewMockSigner ¶
func NewMockSigner() *MockSigner
func (*MockSigner) DeriveSharedKey ¶
func (s *MockSigner) DeriveSharedKey(context.Context, *btcec.PublicKey, *keychain.KeyLocator) ([32]byte, error)
func (*MockSigner) MuSig2Cleanup ¶
func (s *MockSigner) MuSig2Cleanup(context.Context, [32]byte) error
MuSig2Cleanup removes a session from memory to free up resources.
func (*MockSigner) MuSig2CombineSig ¶
MuSig2CombineSig combines the given partial signature(s) with the local one, if it already exists. Once a partial signature of all participants is registered, the final signature will be combined and returned.
func (*MockSigner) MuSig2CreateSession ¶
func (s *MockSigner) MuSig2CreateSession(context.Context, input.MuSig2Version, *keychain.KeyLocator, [][]byte, ...lndclient.MuSig2SessionOpts) ( *input.MuSig2SessionInfo, error)
MuSig2CreateSession creates a new MuSig2 signing session using the local key identified by the key locator. The complete list of all public keys of all signing parties must be provided, including the public key of the local signing key. If nonces of other parties are already known, they can be submitted as well to reduce the number of method calls necessary later on.
func (*MockSigner) MuSig2RegisterNonces ¶
MuSig2RegisterNonces registers one or more public nonces of other signing participants for a session identified by its ID. This method returns true once we have all nonces for all other signing participants.
func (*MockSigner) MuSig2Sign ¶
MuSig2Sign creates a partial signature using the local signing key that was specified when the session was created. This can only be called when all public nonces of all participants are known and have been registered with the session. If this node isn't responsible for combining all the partial signatures, then the cleanup parameter should be set, indicating that the session can be removed from memory once the signature was produced.
func (*MockSigner) RawClientWithMacAuth ¶
func (s *MockSigner) RawClientWithMacAuth( ctx context.Context) (context.Context, time.Duration, signrpc.SignerClient)
func (*MockSigner) SignMessage ¶
func (s *MockSigner) SignMessage(_ context.Context, _ []byte, _ keychain.KeyLocator, _ ...lndclient.SignMessageOption) ([]byte, error)
func (*MockSigner) SignOutputRaw ¶
func (*MockSigner) VerifyMessage ¶
func (s *MockSigner) VerifyMessage(_ context.Context, msg, sig []byte, _ [33]byte, _ ...lndclient.VerifyMessageOption) (bool, error)
type SignOutputRawRequest ¶
type SignOutputRawRequest struct {
Tx *wire.MsgTx
SignDescriptors []*lndclient.SignDescriptor
}
SignOutputRawRequest contains input data for a tx signing request.