mock

package
v0.0.0-...-fd9e7ea Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 21 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) (*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) 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

ECDH currently returns dummy values.

func (*SecretKeyRing) SignMessage

func (s *SecretKeyRing) SignMessage(_ keychain.KeyLocator,
	msg []byte, doubleHash bool) (*btcec.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.

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) SignMessage

func (s *SingleSigner) SignMessage(keyLoc keychain.KeyLocator,
	msg []byte, doubleHash bool) (*btcec.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) 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) 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) 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) ListLeasedOutputs

func (w *WalletController) ListLeasedOutputs() ([]*wtxmgr.LockedOutput, 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) 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) 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