mock

package
v0.15.10001 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CoinPkScript, _ = hex.DecodeString("001431df1bde03c074d0cf21ea2529427e1499b8f1de")
)

Functions

This section is empty.

Types

type ChainIO

type ChainIO struct {
	BestHeight int32
}

ChainIO is a mock implementation of the BlockChainIO interface.

func (*ChainIO) GetBestBlock

func (c *ChainIO) GetBestBlock() (*chainhash.Hash, int32, error)

GetBestBlock currently returns dummy values.

func (*ChainIO) GetBlock

func (c *ChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error)

GetBlock currently returns dummy values.

func (*ChainIO) GetBlockHash

func (c *ChainIO) GetBlockHash(blockHeight int64) (*chainhash.Hash, error)

GetBlockHash currently returns dummy values.

func (*ChainIO) GetUtxo

func (c *ChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
	heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error)

GetUtxo currently returns dummy values.

type ChainNotifier

type ChainNotifier struct {
	SpendChan chan *chainntnfs.SpendDetail
	EpochChan chan *chainntnfs.BlockEpoch
	ConfChan  chan *chainntnfs.TxConfirmation
}

ChainNotifier is a mock implementation of the ChainNotifier interface.

func (*ChainNotifier) RegisterBlockEpochNtfn

func (c *ChainNotifier) RegisterBlockEpochNtfn(blockEpoch *chainntnfs.BlockEpoch) (
	*chainntnfs.BlockEpochEvent, error)

RegisterBlockEpochNtfn returns a BlockEpochEvent that contains a channel that block epochs will go over.

func (*ChainNotifier) RegisterConfirmationsNtfn

func (c *ChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
	pkScript []byte, numConfs, heightHint uint32,
	opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error)

RegisterConfirmationsNtfn returns a ConfirmationEvent that contains a channel that the tx confirmation will go over.

func (*ChainNotifier) RegisterSpendNtfn

func (c *ChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
	pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)

RegisterSpendNtfn returns a SpendEvent that contains a channel that the spend details will go over.

func (*ChainNotifier) Start

func (c *ChainNotifier) Start() error

Start currently returns a dummy value.

func (*ChainNotifier) Started

func (c *ChainNotifier) Started() bool

Started currently returns a dummy value.

func (*ChainNotifier) Stop

func (c *ChainNotifier) Stop() error

Stop currently returns a dummy value.

type DummySignature

type DummySignature struct{}

DummySignature is a dummy Signature implementation.

func (*DummySignature) Serialize

func (d *DummySignature) Serialize() []byte

Serialize returns an empty byte slice.

func (*DummySignature) Verify

func (d *DummySignature) Verify(_ []byte, _ *btcec.PublicKey) bool

Verify always returns true.

type DummySigner

type DummySigner struct{}

DummySigner is an implementation of the Signer interface that returns dummy values when called.

func (*DummySigner) ComputeInputScript

func (d *DummySigner) ComputeInputScript(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (*input.Script, error)

ComputeInputScript returns nil for both values.

func (*DummySigner) MuSig2Cleanup

func (d *DummySigner) MuSig2Cleanup(input.MuSig2SessionID) error

MuSig2Cleanup removes a session from memory to free up resources.

func (*DummySigner) 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 (*DummySigner) MuSig2CreateSession

func (d *DummySigner) MuSig2CreateSession(keychain.KeyLocator,
	[]*btcec.PublicKey, *input.MuSig2Tweaks,
	[][musig2.PubNonceSize]byte) (*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 (*DummySigner) MuSig2RegisterNonces

func (d *DummySigner) MuSig2RegisterNonces(input.MuSig2SessionID,
	[][musig2.PubNonceSize]byte) (bool, error)

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 (*DummySigner) 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 (*DummySigner) SignOutputRaw

func (d *DummySigner) SignOutputRaw(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (input.Signature, error)

SignOutputRaw returns a dummy signature.

type SecretKeyRing

type SecretKeyRing struct {
	RootKey *btcec.PrivateKey
}

SecretKeyRing is a mock implementation of the SecretKeyRing interface.

func (*SecretKeyRing) DeriveKey

DeriveKey currently returns dummy values.

func (*SecretKeyRing) DeriveNextKey

func (s *SecretKeyRing) DeriveNextKey(
	_ keychain.KeyFamily) (keychain.KeyDescriptor, error)

DeriveNextKey currently returns dummy values.

func (*SecretKeyRing) DerivePrivKey

func (s *SecretKeyRing) DerivePrivKey(
	_ keychain.KeyDescriptor) (*btcec.PrivateKey, error)

DerivePrivKey currently returns dummy values.

func (*SecretKeyRing) ECDH

func (s *SecretKeyRing) ECDH(_ keychain.KeyDescriptor,
	_ *btcec.PublicKey) ([32]byte, error)

ECDH currently returns dummy values.

func (*SecretKeyRing) SignMessage

func (s *SecretKeyRing) SignMessage(_ keychain.KeyLocator,
	msg []byte, doubleHash bool) (*ecdsa.Signature, error)

SignMessage signs the passed message and ignores the KeyDescriptor.

func (*SecretKeyRing) SignMessageCompact

func (s *SecretKeyRing) SignMessageCompact(_ keychain.KeyLocator,
	msg []byte, doubleHash bool) ([]byte, error)

SignMessageCompact signs the passed message.

func (*SecretKeyRing) SignMessageSchnorr

func (s *SecretKeyRing) SignMessageSchnorr(_ keychain.KeyLocator,
	msg []byte, doubleHash bool, taprootTweak []byte) (*schnorr.Signature,
	error)

SignMessageSchnorr signs the passed message and ignores the KeyDescriptor.

type SingleSigner

type SingleSigner struct {
	Privkey *btcec.PrivateKey
	KeyLoc  keychain.KeyLocator
}

SingleSigner is an implementation of the Signer interface that signs everything with a single private key.

func (*SingleSigner) ComputeInputScript

func (s *SingleSigner) ComputeInputScript(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (*input.Script, error)

ComputeInputScript computes an input script with the stored private key given a transaction and a SignDescriptor.

func (*SingleSigner) MuSig2Cleanup

func (s *SingleSigner) MuSig2Cleanup(input.MuSig2SessionID) error

MuSig2Cleanup removes a session from memory to free up resources.

func (*SingleSigner) 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 (*SingleSigner) MuSig2CreateSession

func (s *SingleSigner) MuSig2CreateSession(keychain.KeyLocator,
	[]*btcec.PublicKey, *input.MuSig2Tweaks,
	[][musig2.PubNonceSize]byte) (*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 (*SingleSigner) MuSig2RegisterNonces

func (s *SingleSigner) MuSig2RegisterNonces(input.MuSig2SessionID,
	[][musig2.PubNonceSize]byte) (bool, error)

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 (*SingleSigner) 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 (*SingleSigner) SignMessage

func (s *SingleSigner) SignMessage(keyLoc keychain.KeyLocator,
	msg []byte, doubleHash bool) (*ecdsa.Signature, error)

SignMessage takes a public key and a message and only signs the message with the stored private key if the public key matches the private key.

func (*SingleSigner) SignOutputRaw

func (s *SingleSigner) SignOutputRaw(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (input.Signature, error)

SignOutputRaw generates a signature for the passed transaction using the stored private key.

type SpendNotifier

type SpendNotifier struct {
	*ChainNotifier
	// contains filtered or unexported fields
}

SpendNotifier extends the mock.ChainNotifier so that spend notifications can be triggered and delivered to subscribers.

func MakeMockSpendNotifier

func MakeMockSpendNotifier() *SpendNotifier

MakeMockSpendNotifier creates a SpendNotifier.

func (*SpendNotifier) RegisterSpendNtfn

func (s *SpendNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
	_ []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)

RegisterSpendNtfn registers a spend notification for a specified outpoint.

func (*SpendNotifier) Spend

func (s *SpendNotifier) Spend(outpoint *wire.OutPoint, height int32,
	txn *wire.MsgTx)

Spend dispatches SpendDetails to all subscribers of the outpoint. The details will includethe transaction and height provided by the caller.

type WalletController

type WalletController struct {
	RootKey               *btcec.PrivateKey
	PublishedTransactions chan *wire.MsgTx

	Utxos []*lnwallet.Utxo
	// contains filtered or unexported fields
}

WalletController is a mock implementation of the WalletController interface. It let's us mock the interaction with the bitcoin network.

func (*WalletController) AddressInfo

AddressInfo currently returns a dummy value.

func (*WalletController) BackEnd

func (w *WalletController) BackEnd() string

BackEnd returns "mock" to signify a mock wallet controller.

func (*WalletController) ConfirmedBalance

func (w *WalletController) ConfirmedBalance(int32, string) (btcutil.Amount,
	error)

ConfirmedBalance currently returns dummy values.

func (*WalletController) CreateSimpleTx

CreateSimpleTx currently returns dummy values.

func (*WalletController) FetchInputInfo

func (w *WalletController) FetchInputInfo(
	prevOut *wire.OutPoint) (*lnwallet.Utxo, error)

FetchInputInfo will be called to get info about the inputs to the funding transaction.

func (*WalletController) FetchTx

func (w *WalletController) FetchTx(chainhash.Hash) (*wire.MsgTx, error)

func (*WalletController) FinalizePsbt

func (w *WalletController) FinalizePsbt(_ *psbt.Packet, _ string) error

FinalizePsbt currently does nothing.

func (*WalletController) FundPsbt

FundPsbt currently does nothing.

func (*WalletController) GetRecoveryInfo

func (w *WalletController) GetRecoveryInfo() (bool, float64, error)

GetRecoveryInfo currently returns dummy values.

func (*WalletController) ImportAccount

ImportAccount currently returns a dummy value.

func (*WalletController) ImportPublicKey

func (w *WalletController) ImportPublicKey(*btcec.PublicKey,
	waddrmgr.AddressType) error

ImportPublicKey currently returns a dummy value.

func (*WalletController) ImportTaprootScript

ImportTaprootScript currently returns a dummy value.

func (*WalletController) IsOurAddress

func (w *WalletController) IsOurAddress(btcutil.Address) bool

IsOurAddress currently returns a dummy value.

func (*WalletController) IsSynced

func (w *WalletController) IsSynced() (bool, int64, error)

IsSynced currently returns dummy values.

func (*WalletController) LabelTransaction

func (w *WalletController) LabelTransaction(chainhash.Hash, string,
	bool) error

LabelTransaction currently does nothing.

func (*WalletController) LastUnusedAddress

func (w *WalletController) LastUnusedAddress(lnwallet.AddressType,
	string) (btcutil.Address, error)

LastUnusedAddress currently returns dummy values.

func (*WalletController) LeaseOutput

LeaseOutput returns the current time and a nil error.

func (*WalletController) ListAccounts

ListAccounts currently returns a dummy value.

func (*WalletController) ListAddresses

ListAddresses currently returns a dummy value.

func (*WalletController) ListLeasedOutputs

func (w *WalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult,
	error)

func (*WalletController) ListTransactionDetails

func (w *WalletController) ListTransactionDetails(int32, int32,
	string) ([]*lnwallet.TransactionDetail, error)

ListTransactionDetails currently returns dummy values.

func (*WalletController) ListUnspentWitness

func (w *WalletController) ListUnspentWitness(int32, int32,
	string) ([]*lnwallet.Utxo, error)

ListUnspentWitness is called by the wallet when doing coin selection. We just need one unspent for the funding transaction.

func (*WalletController) LockOutpoint

func (w *WalletController) LockOutpoint(o wire.OutPoint)

LockOutpoint currently does nothing.

func (*WalletController) NewAddress

NewAddress is called to get new addresses for delivery, change etc.

func (*WalletController) PublishTransaction

func (w *WalletController) PublishTransaction(tx *wire.MsgTx, _ string) error

PublishTransaction sends a transaction to the PublishedTransactions chan.

func (*WalletController) ReleaseOutput

func (w *WalletController) ReleaseOutput(wtxmgr.LockID, wire.OutPoint) error

ReleaseOutput currently does nothing.

func (*WalletController) RemoveDescendants

func (w *WalletController) RemoveDescendants(*wire.MsgTx) error

func (*WalletController) RequiredReserve

func (w *WalletController) RequiredReserve(uint32) btcutil.Amount

RequiredReserve currently returns a dummy value.

func (*WalletController) ScriptForOutput

func (w *WalletController) ScriptForOutput(*wire.TxOut) (
	waddrmgr.ManagedPubKeyAddress, []byte, []byte, error)

ScriptForOutput returns the address, witness program and redeem script for a given UTXO. An error is returned if the UTXO does not belong to our wallet or it is not a managed pubKey address.

func (*WalletController) SendOutputs

SendOutputs currently returns dummy values.

func (*WalletController) SignPsbt

func (w *WalletController) SignPsbt(*psbt.Packet) ([]uint32, error)

SignPsbt currently does nothing.

func (*WalletController) Start

func (w *WalletController) Start() error

Start currently does nothing.

func (*WalletController) Stop

func (w *WalletController) Stop() error

Stop currently does nothing.

func (*WalletController) SubscribeTransactions

func (w *WalletController) SubscribeTransactions() (lnwallet.TransactionSubscription,
	error)

SubscribeTransactions currently does nothing.

func (*WalletController) UnlockOutpoint

func (w *WalletController) UnlockOutpoint(o wire.OutPoint)

UnlockOutpoint currently does nothing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL