diff --git a/zetaclient/chains/bitcoin/client/client.go b/zetaclient/chains/bitcoin/client/client.go index 626bd88a24..73f258badb 100644 --- a/zetaclient/chains/bitcoin/client/client.go +++ b/zetaclient/chains/bitcoin/client/client.go @@ -11,11 +11,10 @@ import ( "strings" "time" - "cosmossdk.io/errors" types "github.com/btcsuite/btcd/btcjson" chains "github.com/btcsuite/btcd/chaincfg" + "github.com/pkg/errors" "github.com/rs/zerolog" - "github.com/tendermint/btcd/btcjson" "github.com/tendermint/btcd/chaincfg" "github.com/zeta-chain/node/zetaclient/config" @@ -23,6 +22,7 @@ import ( "github.com/zeta-chain/node/zetaclient/metrics" ) +// Client Bitcoin RPC client type Client struct { hostURL string client *http.Client @@ -35,8 +35,8 @@ type Client struct { type Opt func(c *Client) type rawResponse struct { - Result json.RawMessage `json:"result"` - Error *btcjson.RPCError `json:"error"` + Result json.RawMessage `json:"result"` + Error *types.RPCError `json:"error"` } const ( @@ -47,6 +47,8 @@ const ( commandID = uint64(1) ) +var _ client = (*Client)(nil) + func WithHTTP(httpClient *http.Client) Opt { return func(c *Client) { c.client = httpClient } } diff --git a/zetaclient/chains/bitcoin/client/helpers.go b/zetaclient/chains/bitcoin/client/helpers.go index 14c2f9e951..d33050337b 100644 --- a/zetaclient/chains/bitcoin/client/helpers.go +++ b/zetaclient/chains/bitcoin/client/helpers.go @@ -9,7 +9,6 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/pkg/errors" - "github.com/tendermint/btcd/btcjson" ) // GetBlockVerboseByStr alias for GetBlockVerbose @@ -38,13 +37,18 @@ func (c *Client) GetBlockHeightByStr(ctx context.Context, blockHash string) (int } // GetTransactionByStr alias for GetTransaction -func (c *Client) GetTransactionByStr(ctx context.Context, hash string) (*types.GetTransactionResult, error) { +func (c *Client) GetTransactionByStr( + ctx context.Context, + hash string, +) (*chainhash.Hash, *types.GetTransactionResult, error) { h, err := strToHash(hash) if err != nil { - return nil, err + return nil, nil, err } - return c.GetTransaction(ctx, h) + tx, err := c.GetTransaction(ctx, h) + + return h, tx, err } // GetRawTransactionByStr alias for GetRawTransaction @@ -60,7 +64,7 @@ func (c *Client) GetRawTransactionByStr(ctx context.Context, hash string) (*btcu // GetRawTransactionResult gets the raw tx result func (c *Client) GetRawTransactionResult(ctx context.Context, hash *chainhash.Hash, - res *btcjson.GetTransactionResult, + res *types.GetTransactionResult, ) (types.TxRawResult, error) { switch { case res.Confirmations == 0: diff --git a/zetaclient/chains/bitcoin/client/mockgen.go b/zetaclient/chains/bitcoin/client/mockgen.go new file mode 100644 index 0000000000..60e6f0f31c --- /dev/null +++ b/zetaclient/chains/bitcoin/client/mockgen.go @@ -0,0 +1,68 @@ +package client + +import ( + "context" + "time" + + types "github.com/btcsuite/btcd/btcjson" + "github.com/btcsuite/btcd/btcutil" + hash "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/rpcclient" + "github.com/btcsuite/btcd/wire" +) + +// client represents interface version of Client. +// It's unexported on purpose ONLY for mock generation. +// +//go:generate mockery --name client --structname BitcoinClient --filename bitcoin_client.go --output ../../../testutils/mocks +type client interface { + Ping(ctx context.Context) error + Healthcheck(ctx context.Context, tssAddress btcutil.Address) (time.Time, error) + GetNetworkInfo(ctx context.Context) (*types.GetNetworkInfoResult, error) + + GetBlockCount(ctx context.Context) (int64, error) + GetBlockHash(ctx context.Context, blockHeight int64) (*hash.Hash, error) + GetBlockHeader(ctx context.Context, hash *hash.Hash) (*wire.BlockHeader, error) + GetBlockVerbose(ctx context.Context, hash *hash.Hash) (*types.GetBlockVerboseTxResult, error) + + GetTransaction(ctx context.Context, hash *hash.Hash) (*types.GetTransactionResult, error) + GetRawTransaction(ctx context.Context, hash *hash.Hash) (*btcutil.Tx, error) + GetRawTransactionVerbose(ctx context.Context, hash *hash.Hash) (*types.TxRawResult, error) + GetRawTransactionResult( + ctx context.Context, + hash *hash.Hash, + res *types.GetTransactionResult, + ) (types.TxRawResult, error) + + GetTransactionFeeAndRate(ctx context.Context, tx *types.TxRawResult) (int64, int64, error) + + SendRawTransaction(ctx context.Context, tx *wire.MsgTx, allowHighFees bool) (*hash.Hash, error) + + EstimateSmartFee( + ctx context.Context, + confTarget int64, + mode *types.EstimateSmartFeeMode, + ) (*types.EstimateSmartFeeResult, error) + + ListUnspent(ctx context.Context) ([]types.ListUnspentResult, error) + ListUnspentMinMaxAddresses( + ctx context.Context, + minConf, maxConf int, + addresses []btcutil.Address, + ) ([]types.ListUnspentResult, error) + + CreateWallet(ctx context.Context, name string, opts ...rpcclient.CreateWalletOpt) (*types.CreateWalletResult, error) + GetBalance(ctx context.Context, account string) (btcutil.Amount, error) + GetNewAddress(ctx context.Context, account string) (btcutil.Address, error) + GenerateToAddress( + ctx context.Context, + numBlocks int64, + address btcutil.Address, + maxTries *int64, + ) ([]*hash.Hash, error) + + GetBlockVerboseByStr(ctx context.Context, blockHash string) (*types.GetBlockVerboseTxResult, error) + GetBlockHeightByStr(ctx context.Context, blockHash string) (int64, error) + GetTransactionByStr(ctx context.Context, hash string) (*hash.Hash, *types.GetTransactionResult, error) + GetRawTransactionByStr(ctx context.Context, hash string) (*btcutil.Tx, error) +} diff --git a/zetaclient/chains/interfaces/interfaces.go b/zetaclient/chains/interfaces/interfaces.go index a8fe9c71fc..98976054ba 100644 --- a/zetaclient/chains/interfaces/interfaces.go +++ b/zetaclient/chains/interfaces/interfaces.go @@ -6,11 +6,6 @@ import ( "math/big" sdkmath "cosmossdk.io/math" - "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/wire" cometbfttypes "github.com/cometbft/cometbft/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -148,29 +143,6 @@ type ZetacoreClient interface { NewBlockSubscriber(ctx context.Context) (chan cometbfttypes.EventDataNewBlock, error) } -// BTCRPCClient is the interface for BTC RPC client -// -// WARN: you must add any RPCs used on mainnet/testnet to the whitelist in https://github.com/zeta-chain/bitcoin-core-docker -type BTCRPCClient interface { - GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) - CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) - GetNewAddress(account string) (btcutil.Address, error) - GenerateToAddress(numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error) - GetBalance(account string) (btcutil.Amount, error) - SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) - ListUnspent() ([]btcjson.ListUnspentResult, error) - ListUnspentMinMaxAddresses(minConf int, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error) - EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error) - GetTransaction(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, error) - GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error) - GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error) - GetBlockCount() (int64, error) - GetBlockHash(blockHeight int64) (*chainhash.Hash, error) - GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) - GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error) - GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) -} - // EVMRPCClient is the interface for EVM RPC client type EVMRPCClient interface { bind.ContractBackend diff --git a/zetaclient/testutils/mocks/bitcoin_client.go b/zetaclient/testutils/mocks/bitcoin_client.go new file mode 100644 index 0000000000..88b3962574 --- /dev/null +++ b/zetaclient/testutils/mocks/bitcoin_client.go @@ -0,0 +1,758 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package mocks + +import ( + btcjson "github.com/btcsuite/btcd/btcjson" + btcutil "github.com/btcsuite/btcd/btcutil" + + chainhash "github.com/btcsuite/btcd/chaincfg/chainhash" + + context "context" + + mock "github.com/stretchr/testify/mock" + + rpcclient "github.com/btcsuite/btcd/rpcclient" + + time "time" + + wire "github.com/btcsuite/btcd/wire" +) + +// BitcoinClient is an autogenerated mock type for the client type +type BitcoinClient struct { + mock.Mock +} + +// CreateWallet provides a mock function with given fields: ctx, name, opts +func (_m *BitcoinClient) CreateWallet(ctx context.Context, name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, name) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateWallet") + } + + var r0 *btcjson.CreateWalletResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error)); ok { + return rf(ctx, name, opts...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...rpcclient.CreateWalletOpt) *btcjson.CreateWalletResult); ok { + r0 = rf(ctx, name, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.CreateWalletResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...rpcclient.CreateWalletOpt) error); ok { + r1 = rf(ctx, name, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EstimateSmartFee provides a mock function with given fields: ctx, confTarget, mode +func (_m *BitcoinClient) EstimateSmartFee(ctx context.Context, confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error) { + ret := _m.Called(ctx, confTarget, mode) + + if len(ret) == 0 { + panic("no return value specified for EstimateSmartFee") + } + + var r0 *btcjson.EstimateSmartFeeResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64, *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error)); ok { + return rf(ctx, confTarget, mode) + } + if rf, ok := ret.Get(0).(func(context.Context, int64, *btcjson.EstimateSmartFeeMode) *btcjson.EstimateSmartFeeResult); ok { + r0 = rf(ctx, confTarget, mode) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.EstimateSmartFeeResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64, *btcjson.EstimateSmartFeeMode) error); ok { + r1 = rf(ctx, confTarget, mode) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GenerateToAddress provides a mock function with given fields: ctx, numBlocks, address, maxTries +func (_m *BitcoinClient) GenerateToAddress(ctx context.Context, numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error) { + ret := _m.Called(ctx, numBlocks, address, maxTries) + + if len(ret) == 0 { + panic("no return value specified for GenerateToAddress") + } + + var r0 []*chainhash.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64, btcutil.Address, *int64) ([]*chainhash.Hash, error)); ok { + return rf(ctx, numBlocks, address, maxTries) + } + if rf, ok := ret.Get(0).(func(context.Context, int64, btcutil.Address, *int64) []*chainhash.Hash); ok { + r0 = rf(ctx, numBlocks, address, maxTries) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64, btcutil.Address, *int64) error); ok { + r1 = rf(ctx, numBlocks, address, maxTries) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBalance provides a mock function with given fields: ctx, account +func (_m *BitcoinClient) GetBalance(ctx context.Context, account string) (btcutil.Amount, error) { + ret := _m.Called(ctx, account) + + if len(ret) == 0 { + panic("no return value specified for GetBalance") + } + + var r0 btcutil.Amount + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (btcutil.Amount, error)); ok { + return rf(ctx, account) + } + if rf, ok := ret.Get(0).(func(context.Context, string) btcutil.Amount); ok { + r0 = rf(ctx, account) + } else { + r0 = ret.Get(0).(btcutil.Amount) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, account) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockCount provides a mock function with given fields: ctx +func (_m *BitcoinClient) GetBlockCount(ctx context.Context) (int64, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetBlockCount") + } + + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (int64, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) int64); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(int64) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockHash provides a mock function with given fields: ctx, blockHeight +func (_m *BitcoinClient) GetBlockHash(ctx context.Context, blockHeight int64) (*chainhash.Hash, error) { + ret := _m.Called(ctx, blockHeight) + + if len(ret) == 0 { + panic("no return value specified for GetBlockHash") + } + + var r0 *chainhash.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*chainhash.Hash, error)); ok { + return rf(ctx, blockHeight) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *chainhash.Hash); ok { + r0 = rf(ctx, blockHeight) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = rf(ctx, blockHeight) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockHeader provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetBlockHeader(ctx context.Context, hash *chainhash.Hash) (*wire.BlockHeader, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockHeader") + } + + var r0 *wire.BlockHeader + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) (*wire.BlockHeader, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) *wire.BlockHeader); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*wire.BlockHeader) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *chainhash.Hash) error); ok { + r1 = rf(ctx, hash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockHeightByStr provides a mock function with given fields: ctx, blockHash +func (_m *BitcoinClient) GetBlockHeightByStr(ctx context.Context, blockHash string) (int64, error) { + ret := _m.Called(ctx, blockHash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockHeightByStr") + } + + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (int64, error)); ok { + return rf(ctx, blockHash) + } + if rf, ok := ret.Get(0).(func(context.Context, string) int64); ok { + r0 = rf(ctx, blockHash) + } else { + r0 = ret.Get(0).(int64) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, blockHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockVerbose provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetBlockVerbose(ctx context.Context, hash *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockVerbose") + } + + var r0 *btcjson.GetBlockVerboseTxResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) *btcjson.GetBlockVerboseTxResult); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetBlockVerboseTxResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *chainhash.Hash) error); ok { + r1 = rf(ctx, hash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockVerboseByStr provides a mock function with given fields: ctx, blockHash +func (_m *BitcoinClient) GetBlockVerboseByStr(ctx context.Context, blockHash string) (*btcjson.GetBlockVerboseTxResult, error) { + ret := _m.Called(ctx, blockHash) + + if len(ret) == 0 { + panic("no return value specified for GetBlockVerboseByStr") + } + + var r0 *btcjson.GetBlockVerboseTxResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*btcjson.GetBlockVerboseTxResult, error)); ok { + return rf(ctx, blockHash) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *btcjson.GetBlockVerboseTxResult); ok { + r0 = rf(ctx, blockHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetBlockVerboseTxResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, blockHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetNetworkInfo provides a mock function with given fields: ctx +func (_m *BitcoinClient) GetNetworkInfo(ctx context.Context) (*btcjson.GetNetworkInfoResult, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetNetworkInfo") + } + + var r0 *btcjson.GetNetworkInfoResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*btcjson.GetNetworkInfoResult, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *btcjson.GetNetworkInfoResult); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetNetworkInfoResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetNewAddress provides a mock function with given fields: ctx, account +func (_m *BitcoinClient) GetNewAddress(ctx context.Context, account string) (btcutil.Address, error) { + ret := _m.Called(ctx, account) + + if len(ret) == 0 { + panic("no return value specified for GetNewAddress") + } + + var r0 btcutil.Address + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (btcutil.Address, error)); ok { + return rf(ctx, account) + } + if rf, ok := ret.Get(0).(func(context.Context, string) btcutil.Address); ok { + r0 = rf(ctx, account) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(btcutil.Address) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, account) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetRawTransaction provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetRawTransaction(ctx context.Context, hash *chainhash.Hash) (*btcutil.Tx, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetRawTransaction") + } + + var r0 *btcutil.Tx + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) (*btcutil.Tx, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) *btcutil.Tx); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcutil.Tx) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *chainhash.Hash) error); ok { + r1 = rf(ctx, hash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetRawTransactionByStr provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetRawTransactionByStr(ctx context.Context, hash string) (*btcutil.Tx, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetRawTransactionByStr") + } + + var r0 *btcutil.Tx + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*btcutil.Tx, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *btcutil.Tx); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcutil.Tx) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, hash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetRawTransactionResult provides a mock function with given fields: ctx, hash, res +func (_m *BitcoinClient) GetRawTransactionResult(ctx context.Context, hash *chainhash.Hash, res *btcjson.GetTransactionResult) (btcjson.TxRawResult, error) { + ret := _m.Called(ctx, hash, res) + + if len(ret) == 0 { + panic("no return value specified for GetRawTransactionResult") + } + + var r0 btcjson.TxRawResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash, *btcjson.GetTransactionResult) (btcjson.TxRawResult, error)); ok { + return rf(ctx, hash, res) + } + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash, *btcjson.GetTransactionResult) btcjson.TxRawResult); ok { + r0 = rf(ctx, hash, res) + } else { + r0 = ret.Get(0).(btcjson.TxRawResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, *chainhash.Hash, *btcjson.GetTransactionResult) error); ok { + r1 = rf(ctx, hash, res) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetRawTransactionVerbose provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetRawTransactionVerbose(ctx context.Context, hash *chainhash.Hash) (*btcjson.TxRawResult, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetRawTransactionVerbose") + } + + var r0 *btcjson.TxRawResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) (*btcjson.TxRawResult, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) *btcjson.TxRawResult); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.TxRawResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *chainhash.Hash) error); ok { + r1 = rf(ctx, hash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetTransaction provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetTransaction(ctx context.Context, hash *chainhash.Hash) (*btcjson.GetTransactionResult, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetTransaction") + } + + var r0 *btcjson.GetTransactionResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) (*btcjson.GetTransactionResult, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, *chainhash.Hash) *btcjson.GetTransactionResult); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*btcjson.GetTransactionResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *chainhash.Hash) error); ok { + r1 = rf(ctx, hash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetTransactionByStr provides a mock function with given fields: ctx, hash +func (_m *BitcoinClient) GetTransactionByStr(ctx context.Context, hash string) (*chainhash.Hash, *btcjson.GetTransactionResult, error) { + ret := _m.Called(ctx, hash) + + if len(ret) == 0 { + panic("no return value specified for GetTransactionByStr") + } + + var r0 *chainhash.Hash + var r1 *btcjson.GetTransactionResult + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*chainhash.Hash, *btcjson.GetTransactionResult, error)); ok { + return rf(ctx, hash) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *chainhash.Hash); ok { + r0 = rf(ctx, hash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) *btcjson.GetTransactionResult); ok { + r1 = rf(ctx, hash) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*btcjson.GetTransactionResult) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, hash) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// GetTransactionFeeAndRate provides a mock function with given fields: ctx, tx +func (_m *BitcoinClient) GetTransactionFeeAndRate(ctx context.Context, tx *btcjson.TxRawResult) (int64, int64, error) { + ret := _m.Called(ctx, tx) + + if len(ret) == 0 { + panic("no return value specified for GetTransactionFeeAndRate") + } + + var r0 int64 + var r1 int64 + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, *btcjson.TxRawResult) (int64, int64, error)); ok { + return rf(ctx, tx) + } + if rf, ok := ret.Get(0).(func(context.Context, *btcjson.TxRawResult) int64); ok { + r0 = rf(ctx, tx) + } else { + r0 = ret.Get(0).(int64) + } + + if rf, ok := ret.Get(1).(func(context.Context, *btcjson.TxRawResult) int64); ok { + r1 = rf(ctx, tx) + } else { + r1 = ret.Get(1).(int64) + } + + if rf, ok := ret.Get(2).(func(context.Context, *btcjson.TxRawResult) error); ok { + r2 = rf(ctx, tx) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// Healthcheck provides a mock function with given fields: ctx, tssAddress +func (_m *BitcoinClient) Healthcheck(ctx context.Context, tssAddress btcutil.Address) (time.Time, error) { + ret := _m.Called(ctx, tssAddress) + + if len(ret) == 0 { + panic("no return value specified for Healthcheck") + } + + var r0 time.Time + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, btcutil.Address) (time.Time, error)); ok { + return rf(ctx, tssAddress) + } + if rf, ok := ret.Get(0).(func(context.Context, btcutil.Address) time.Time); ok { + r0 = rf(ctx, tssAddress) + } else { + r0 = ret.Get(0).(time.Time) + } + + if rf, ok := ret.Get(1).(func(context.Context, btcutil.Address) error); ok { + r1 = rf(ctx, tssAddress) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListUnspent provides a mock function with given fields: ctx +func (_m *BitcoinClient) ListUnspent(ctx context.Context) ([]btcjson.ListUnspentResult, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for ListUnspent") + } + + var r0 []btcjson.ListUnspentResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]btcjson.ListUnspentResult, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []btcjson.ListUnspentResult); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]btcjson.ListUnspentResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListUnspentMinMaxAddresses provides a mock function with given fields: ctx, minConf, maxConf, addresses +func (_m *BitcoinClient) ListUnspentMinMaxAddresses(ctx context.Context, minConf int, maxConf int, addresses []btcutil.Address) ([]btcjson.ListUnspentResult, error) { + ret := _m.Called(ctx, minConf, maxConf, addresses) + + if len(ret) == 0 { + panic("no return value specified for ListUnspentMinMaxAddresses") + } + + var r0 []btcjson.ListUnspentResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int, int, []btcutil.Address) ([]btcjson.ListUnspentResult, error)); ok { + return rf(ctx, minConf, maxConf, addresses) + } + if rf, ok := ret.Get(0).(func(context.Context, int, int, []btcutil.Address) []btcjson.ListUnspentResult); ok { + r0 = rf(ctx, minConf, maxConf, addresses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]btcjson.ListUnspentResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int, int, []btcutil.Address) error); ok { + r1 = rf(ctx, minConf, maxConf, addresses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Ping provides a mock function with given fields: ctx +func (_m *BitcoinClient) Ping(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Ping") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendRawTransaction provides a mock function with given fields: ctx, tx, allowHighFees +func (_m *BitcoinClient) SendRawTransaction(ctx context.Context, tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) { + ret := _m.Called(ctx, tx, allowHighFees) + + if len(ret) == 0 { + panic("no return value specified for SendRawTransaction") + } + + var r0 *chainhash.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *wire.MsgTx, bool) (*chainhash.Hash, error)); ok { + return rf(ctx, tx, allowHighFees) + } + if rf, ok := ret.Get(0).(func(context.Context, *wire.MsgTx, bool) *chainhash.Hash); ok { + r0 = rf(ctx, tx, allowHighFees) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*chainhash.Hash) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *wire.MsgTx, bool) error); ok { + r1 = rf(ctx, tx, allowHighFees) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewBitcoinClient creates a new instance of BitcoinClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewBitcoinClient(t interface { + mock.TestingT + Cleanup(func()) +}) *BitcoinClient { + mock := &BitcoinClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/zetaclient/testutils/mocks/btc_rpc.go b/zetaclient/testutils/mocks/btc_rpc.go deleted file mode 100644 index 487f4b0632..0000000000 --- a/zetaclient/testutils/mocks/btc_rpc.go +++ /dev/null @@ -1,548 +0,0 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. - -package mocks - -import ( - btcjson "github.com/btcsuite/btcd/btcjson" - btcutil "github.com/btcsuite/btcd/btcutil" - - chainhash "github.com/btcsuite/btcd/chaincfg/chainhash" - - mock "github.com/stretchr/testify/mock" - - rpcclient "github.com/btcsuite/btcd/rpcclient" - - wire "github.com/btcsuite/btcd/wire" -) - -// BTCRPCClient is an autogenerated mock type for the BTCRPCClient type -type BTCRPCClient struct { - mock.Mock -} - -// CreateWallet provides a mock function with given fields: name, opts -func (_m *BTCRPCClient) CreateWallet(name string, opts ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, name) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateWallet") - } - - var r0 *btcjson.CreateWalletResult - var r1 error - if rf, ok := ret.Get(0).(func(string, ...rpcclient.CreateWalletOpt) (*btcjson.CreateWalletResult, error)); ok { - return rf(name, opts...) - } - if rf, ok := ret.Get(0).(func(string, ...rpcclient.CreateWalletOpt) *btcjson.CreateWalletResult); ok { - r0 = rf(name, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.CreateWalletResult) - } - } - - if rf, ok := ret.Get(1).(func(string, ...rpcclient.CreateWalletOpt) error); ok { - r1 = rf(name, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// EstimateSmartFee provides a mock function with given fields: confTarget, mode -func (_m *BTCRPCClient) EstimateSmartFee(confTarget int64, mode *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error) { - ret := _m.Called(confTarget, mode) - - if len(ret) == 0 { - panic("no return value specified for EstimateSmartFee") - } - - var r0 *btcjson.EstimateSmartFeeResult - var r1 error - if rf, ok := ret.Get(0).(func(int64, *btcjson.EstimateSmartFeeMode) (*btcjson.EstimateSmartFeeResult, error)); ok { - return rf(confTarget, mode) - } - if rf, ok := ret.Get(0).(func(int64, *btcjson.EstimateSmartFeeMode) *btcjson.EstimateSmartFeeResult); ok { - r0 = rf(confTarget, mode) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.EstimateSmartFeeResult) - } - } - - if rf, ok := ret.Get(1).(func(int64, *btcjson.EstimateSmartFeeMode) error); ok { - r1 = rf(confTarget, mode) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GenerateToAddress provides a mock function with given fields: numBlocks, address, maxTries -func (_m *BTCRPCClient) GenerateToAddress(numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error) { - ret := _m.Called(numBlocks, address, maxTries) - - if len(ret) == 0 { - panic("no return value specified for GenerateToAddress") - } - - var r0 []*chainhash.Hash - var r1 error - if rf, ok := ret.Get(0).(func(int64, btcutil.Address, *int64) ([]*chainhash.Hash, error)); ok { - return rf(numBlocks, address, maxTries) - } - if rf, ok := ret.Get(0).(func(int64, btcutil.Address, *int64) []*chainhash.Hash); ok { - r0 = rf(numBlocks, address, maxTries) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*chainhash.Hash) - } - } - - if rf, ok := ret.Get(1).(func(int64, btcutil.Address, *int64) error); ok { - r1 = rf(numBlocks, address, maxTries) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBalance provides a mock function with given fields: account -func (_m *BTCRPCClient) GetBalance(account string) (btcutil.Amount, error) { - ret := _m.Called(account) - - if len(ret) == 0 { - panic("no return value specified for GetBalance") - } - - var r0 btcutil.Amount - var r1 error - if rf, ok := ret.Get(0).(func(string) (btcutil.Amount, error)); ok { - return rf(account) - } - if rf, ok := ret.Get(0).(func(string) btcutil.Amount); ok { - r0 = rf(account) - } else { - r0 = ret.Get(0).(btcutil.Amount) - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(account) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockCount provides a mock function with given fields: -func (_m *BTCRPCClient) GetBlockCount() (int64, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetBlockCount") - } - - var r0 int64 - var r1 error - if rf, ok := ret.Get(0).(func() (int64, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() int64); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int64) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockHash provides a mock function with given fields: blockHeight -func (_m *BTCRPCClient) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) { - ret := _m.Called(blockHeight) - - if len(ret) == 0 { - panic("no return value specified for GetBlockHash") - } - - var r0 *chainhash.Hash - var r1 error - if rf, ok := ret.Get(0).(func(int64) (*chainhash.Hash, error)); ok { - return rf(blockHeight) - } - if rf, ok := ret.Get(0).(func(int64) *chainhash.Hash); ok { - r0 = rf(blockHeight) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*chainhash.Hash) - } - } - - if rf, ok := ret.Get(1).(func(int64) error); ok { - r1 = rf(blockHeight) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockHeader provides a mock function with given fields: blockHash -func (_m *BTCRPCClient) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) { - ret := _m.Called(blockHash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockHeader") - } - - var r0 *wire.BlockHeader - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*wire.BlockHeader, error)); ok { - return rf(blockHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *wire.BlockHeader); ok { - r0 = rf(blockHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*wire.BlockHeader) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(blockHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockVerbose provides a mock function with given fields: blockHash -func (_m *BTCRPCClient) GetBlockVerbose(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseResult, error) { - ret := _m.Called(blockHash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockVerbose") - } - - var r0 *btcjson.GetBlockVerboseResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetBlockVerboseResult, error)); ok { - return rf(blockHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetBlockVerboseResult); ok { - r0 = rf(blockHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetBlockVerboseResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(blockHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetBlockVerboseTx provides a mock function with given fields: blockHash -func (_m *BTCRPCClient) GetBlockVerboseTx(blockHash *chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error) { - ret := _m.Called(blockHash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockVerboseTx") - } - - var r0 *btcjson.GetBlockVerboseTxResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetBlockVerboseTxResult, error)); ok { - return rf(blockHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetBlockVerboseTxResult); ok { - r0 = rf(blockHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetBlockVerboseTxResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(blockHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetNetworkInfo provides a mock function with given fields: -func (_m *BTCRPCClient) GetNetworkInfo() (*btcjson.GetNetworkInfoResult, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetNetworkInfo") - } - - var r0 *btcjson.GetNetworkInfoResult - var r1 error - if rf, ok := ret.Get(0).(func() (*btcjson.GetNetworkInfoResult, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() *btcjson.GetNetworkInfoResult); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetNetworkInfoResult) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetNewAddress provides a mock function with given fields: account -func (_m *BTCRPCClient) GetNewAddress(account string) (btcutil.Address, error) { - ret := _m.Called(account) - - if len(ret) == 0 { - panic("no return value specified for GetNewAddress") - } - - var r0 btcutil.Address - var r1 error - if rf, ok := ret.Get(0).(func(string) (btcutil.Address, error)); ok { - return rf(account) - } - if rf, ok := ret.Get(0).(func(string) btcutil.Address); ok { - r0 = rf(account) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(btcutil.Address) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(account) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRawTransaction provides a mock function with given fields: txHash -func (_m *BTCRPCClient) GetRawTransaction(txHash *chainhash.Hash) (*btcutil.Tx, error) { - ret := _m.Called(txHash) - - if len(ret) == 0 { - panic("no return value specified for GetRawTransaction") - } - - var r0 *btcutil.Tx - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcutil.Tx, error)); ok { - return rf(txHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcutil.Tx); ok { - r0 = rf(txHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcutil.Tx) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(txHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRawTransactionVerbose provides a mock function with given fields: txHash -func (_m *BTCRPCClient) GetRawTransactionVerbose(txHash *chainhash.Hash) (*btcjson.TxRawResult, error) { - ret := _m.Called(txHash) - - if len(ret) == 0 { - panic("no return value specified for GetRawTransactionVerbose") - } - - var r0 *btcjson.TxRawResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.TxRawResult, error)); ok { - return rf(txHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.TxRawResult); ok { - r0 = rf(txHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.TxRawResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(txHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetTransaction provides a mock function with given fields: txHash -func (_m *BTCRPCClient) GetTransaction(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, error) { - ret := _m.Called(txHash) - - if len(ret) == 0 { - panic("no return value specified for GetTransaction") - } - - var r0 *btcjson.GetTransactionResult - var r1 error - if rf, ok := ret.Get(0).(func(*chainhash.Hash) (*btcjson.GetTransactionResult, error)); ok { - return rf(txHash) - } - if rf, ok := ret.Get(0).(func(*chainhash.Hash) *btcjson.GetTransactionResult); ok { - r0 = rf(txHash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*btcjson.GetTransactionResult) - } - } - - if rf, ok := ret.Get(1).(func(*chainhash.Hash) error); ok { - r1 = rf(txHash) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ListUnspent provides a mock function with given fields: -func (_m *BTCRPCClient) ListUnspent() ([]btcjson.ListUnspentResult, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for ListUnspent") - } - - var r0 []btcjson.ListUnspentResult - var r1 error - if rf, ok := ret.Get(0).(func() ([]btcjson.ListUnspentResult, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() []btcjson.ListUnspentResult); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]btcjson.ListUnspentResult) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ListUnspentMinMaxAddresses provides a mock function with given fields: minConf, maxConf, addrs -func (_m *BTCRPCClient) ListUnspentMinMaxAddresses(minConf int, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error) { - ret := _m.Called(minConf, maxConf, addrs) - - if len(ret) == 0 { - panic("no return value specified for ListUnspentMinMaxAddresses") - } - - var r0 []btcjson.ListUnspentResult - var r1 error - if rf, ok := ret.Get(0).(func(int, int, []btcutil.Address) ([]btcjson.ListUnspentResult, error)); ok { - return rf(minConf, maxConf, addrs) - } - if rf, ok := ret.Get(0).(func(int, int, []btcutil.Address) []btcjson.ListUnspentResult); ok { - r0 = rf(minConf, maxConf, addrs) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]btcjson.ListUnspentResult) - } - } - - if rf, ok := ret.Get(1).(func(int, int, []btcutil.Address) error); ok { - r1 = rf(minConf, maxConf, addrs) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendRawTransaction provides a mock function with given fields: tx, allowHighFees -func (_m *BTCRPCClient) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) { - ret := _m.Called(tx, allowHighFees) - - if len(ret) == 0 { - panic("no return value specified for SendRawTransaction") - } - - var r0 *chainhash.Hash - var r1 error - if rf, ok := ret.Get(0).(func(*wire.MsgTx, bool) (*chainhash.Hash, error)); ok { - return rf(tx, allowHighFees) - } - if rf, ok := ret.Get(0).(func(*wire.MsgTx, bool) *chainhash.Hash); ok { - r0 = rf(tx, allowHighFees) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*chainhash.Hash) - } - } - - if rf, ok := ret.Get(1).(func(*wire.MsgTx, bool) error); ok { - r1 = rf(tx, allowHighFees) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewBTCRPCClient creates a new instance of BTCRPCClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewBTCRPCClient(t interface { - mock.TestingT - Cleanup(func()) -}) *BTCRPCClient { - mock := &BTCRPCClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}