Documentation ¶
Overview ¶
Package backend provides the portion of top-level swapd instance management that is shared by both the maker and the taker.
Package backend is a generated GoMock package.
Index ¶
- type Backend
- type Config
- type MockRecoveryDB
- func (m *MockRecoveryDB) DeleteSwap(arg0 common.Hash) error
- func (m *MockRecoveryDB) EXPECT() *MockRecoveryDBMockRecorder
- func (m *MockRecoveryDB) GetContractSwapInfo(arg0 common.Hash) (*db.EthereumSwapInfo, error)
- func (m *MockRecoveryDB) GetCounterpartySwapKeys(arg0 common.Hash) (*mcrypto.PublicKey, *mcrypto.PrivateViewKey, error)
- func (m *MockRecoveryDB) GetCounterpartySwapPrivateKey(arg0 common.Hash) (*mcrypto.PrivateSpendKey, error)
- func (m *MockRecoveryDB) GetNewSwapTxHash(arg0 common.Hash) (common.Hash, error)
- func (m *MockRecoveryDB) GetSwapPrivateKey(arg0 common.Hash) (*mcrypto.PrivateSpendKey, error)
- func (m *MockRecoveryDB) GetSwapRelayerInfo(arg0 common.Hash) (*types.OfferExtra, error)
- func (m *MockRecoveryDB) PutContractSwapInfo(arg0 common.Hash, arg1 *db.EthereumSwapInfo) error
- func (m *MockRecoveryDB) PutCounterpartySwapKeys(arg0 common.Hash, arg1 *mcrypto.PublicKey, arg2 *mcrypto.PrivateViewKey) error
- func (m *MockRecoveryDB) PutCounterpartySwapPrivateKey(arg0 common.Hash, arg1 *mcrypto.PrivateSpendKey) error
- func (m *MockRecoveryDB) PutNewSwapTxHash(arg0, arg1 common.Hash) error
- func (m *MockRecoveryDB) PutSwapPrivateKey(arg0 common.Hash, arg1 *mcrypto.PrivateSpendKey) error
- func (m *MockRecoveryDB) PutSwapRelayerInfo(arg0 common.Hash, arg1 *types.OfferExtra) error
- type MockRecoveryDBMockRecorder
- func (mr *MockRecoveryDBMockRecorder) DeleteSwap(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) GetContractSwapInfo(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) GetCounterpartySwapKeys(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) GetCounterpartySwapPrivateKey(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) GetNewSwapTxHash(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) GetSwapPrivateKey(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) GetSwapRelayerInfo(arg0 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) PutContractSwapInfo(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) PutCounterpartySwapKeys(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) PutCounterpartySwapPrivateKey(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) PutNewSwapTxHash(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) PutSwapPrivateKey(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockRecoveryDBMockRecorder) PutSwapRelayerInfo(arg0, arg1 interface{}) *gomock.Call
- type NetSender
- type RecoveryDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { XMRClient() monero.WalletClient ETHClient() extethclient.EthClient NetSender RecoveryDB() RecoveryDB // NewTxSender creates a new transaction sender, called per-swap NewTxSender(asset ethcommon.Address, erc20Contract *contracts.IERC20) (txsender.Sender, error) // helpers NewSwapCreator(addr ethcommon.Address) (*contracts.SwapCreator, error) HandleRelayClaimRequest(remotePeer peer.ID, request *message.RelayClaimRequest) (*message.RelayClaimResponse, error) GetRelayerAddressHash() (types.Hash, error) HasOngoingSwapAsTaker(peer.ID) error SubmitClaimToRelayer( peer.ID, *types.Hash, *contracts.SwapCreatorRelaySwap, [32]byte, ) (*message.RelayClaimResponse, error) // Only used by Taker // getters Ctx() context.Context Env() common.Environment SwapManager() swap.Manager SwapCreator() *contracts.SwapCreator SwapCreatorAddr() ethcommon.Address SwapTimeout() time.Duration XMRDepositAddress(offerID *types.Hash) *mcrypto.Address // setters SetSwapTimeout(timeout time.Duration) SetXMRDepositAddress(*mcrypto.Address, types.Hash) ClearXMRDepositAddress(types.Hash) // transfer helpers TransferXMR(to *mcrypto.Address, amount *coins.PiconeroAmount) (string, error) SweepXMR(to *mcrypto.Address) ([]string, error) TransferETH(to ethcommon.Address, amount *coins.WeiAmount, gasLimit *uint64) (*ethtypes.Receipt, error) SweepETH(to ethcommon.Address) (*ethtypes.Receipt, error) }
Backend provides an interface for both the XMRTaker and XMRMaker into the Monero/Ethereum chains. It also interfaces with the network layer.
type Config ¶
type Config struct { Ctx context.Context MoneroClient monero.WalletClient EthereumClient extethclient.EthClient Environment common.Environment SwapCreatorAddr ethcommon.Address SwapManager swap.Manager RecoveryDB RecoveryDB Net NetSender }
Config is the config for the Backend
type MockRecoveryDB ¶
type MockRecoveryDB struct {
// contains filtered or unexported fields
}
MockRecoveryDB is a mock of RecoveryDB interface.
func NewMockRecoveryDB ¶
func NewMockRecoveryDB(ctrl *gomock.Controller) *MockRecoveryDB
NewMockRecoveryDB creates a new mock instance.
func (*MockRecoveryDB) DeleteSwap ¶
func (m *MockRecoveryDB) DeleteSwap(arg0 common.Hash) error
DeleteSwap mocks base method.
func (*MockRecoveryDB) EXPECT ¶
func (m *MockRecoveryDB) EXPECT() *MockRecoveryDBMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockRecoveryDB) GetContractSwapInfo ¶
func (m *MockRecoveryDB) GetContractSwapInfo(arg0 common.Hash) (*db.EthereumSwapInfo, error)
GetContractSwapInfo mocks base method.
func (*MockRecoveryDB) GetCounterpartySwapKeys ¶
func (m *MockRecoveryDB) GetCounterpartySwapKeys(arg0 common.Hash) (*mcrypto.PublicKey, *mcrypto.PrivateViewKey, error)
GetCounterpartySwapKeys mocks base method.
func (*MockRecoveryDB) GetCounterpartySwapPrivateKey ¶
func (m *MockRecoveryDB) GetCounterpartySwapPrivateKey(arg0 common.Hash) (*mcrypto.PrivateSpendKey, error)
GetCounterpartySwapPrivateKey mocks base method.
func (*MockRecoveryDB) GetNewSwapTxHash ¶ added in v0.3.0
GetNewSwapTxHash mocks base method.
func (*MockRecoveryDB) GetSwapPrivateKey ¶
func (m *MockRecoveryDB) GetSwapPrivateKey(arg0 common.Hash) (*mcrypto.PrivateSpendKey, error)
GetSwapPrivateKey mocks base method.
func (*MockRecoveryDB) GetSwapRelayerInfo ¶
func (m *MockRecoveryDB) GetSwapRelayerInfo(arg0 common.Hash) (*types.OfferExtra, error)
GetSwapRelayerInfo mocks base method.
func (*MockRecoveryDB) PutContractSwapInfo ¶
func (m *MockRecoveryDB) PutContractSwapInfo(arg0 common.Hash, arg1 *db.EthereumSwapInfo) error
PutContractSwapInfo mocks base method.
func (*MockRecoveryDB) PutCounterpartySwapKeys ¶
func (m *MockRecoveryDB) PutCounterpartySwapKeys(arg0 common.Hash, arg1 *mcrypto.PublicKey, arg2 *mcrypto.PrivateViewKey) error
PutCounterpartySwapKeys mocks base method.
func (*MockRecoveryDB) PutCounterpartySwapPrivateKey ¶
func (m *MockRecoveryDB) PutCounterpartySwapPrivateKey(arg0 common.Hash, arg1 *mcrypto.PrivateSpendKey) error
PutCounterpartySwapPrivateKey mocks base method.
func (*MockRecoveryDB) PutNewSwapTxHash ¶ added in v0.3.0
func (m *MockRecoveryDB) PutNewSwapTxHash(arg0, arg1 common.Hash) error
PutNewSwapTxHash mocks base method.
func (*MockRecoveryDB) PutSwapPrivateKey ¶
func (m *MockRecoveryDB) PutSwapPrivateKey(arg0 common.Hash, arg1 *mcrypto.PrivateSpendKey) error
PutSwapPrivateKey mocks base method.
func (*MockRecoveryDB) PutSwapRelayerInfo ¶
func (m *MockRecoveryDB) PutSwapRelayerInfo(arg0 common.Hash, arg1 *types.OfferExtra) error
PutSwapRelayerInfo mocks base method.
type MockRecoveryDBMockRecorder ¶
type MockRecoveryDBMockRecorder struct {
// contains filtered or unexported fields
}
MockRecoveryDBMockRecorder is the mock recorder for MockRecoveryDB.
func (*MockRecoveryDBMockRecorder) DeleteSwap ¶
func (mr *MockRecoveryDBMockRecorder) DeleteSwap(arg0 interface{}) *gomock.Call
DeleteSwap indicates an expected call of DeleteSwap.
func (*MockRecoveryDBMockRecorder) GetContractSwapInfo ¶
func (mr *MockRecoveryDBMockRecorder) GetContractSwapInfo(arg0 interface{}) *gomock.Call
GetContractSwapInfo indicates an expected call of GetContractSwapInfo.
func (*MockRecoveryDBMockRecorder) GetCounterpartySwapKeys ¶
func (mr *MockRecoveryDBMockRecorder) GetCounterpartySwapKeys(arg0 interface{}) *gomock.Call
GetCounterpartySwapKeys indicates an expected call of GetCounterpartySwapKeys.
func (*MockRecoveryDBMockRecorder) GetCounterpartySwapPrivateKey ¶
func (mr *MockRecoveryDBMockRecorder) GetCounterpartySwapPrivateKey(arg0 interface{}) *gomock.Call
GetCounterpartySwapPrivateKey indicates an expected call of GetCounterpartySwapPrivateKey.
func (*MockRecoveryDBMockRecorder) GetNewSwapTxHash ¶ added in v0.3.0
func (mr *MockRecoveryDBMockRecorder) GetNewSwapTxHash(arg0 interface{}) *gomock.Call
GetNewSwapTxHash indicates an expected call of GetNewSwapTxHash.
func (*MockRecoveryDBMockRecorder) GetSwapPrivateKey ¶
func (mr *MockRecoveryDBMockRecorder) GetSwapPrivateKey(arg0 interface{}) *gomock.Call
GetSwapPrivateKey indicates an expected call of GetSwapPrivateKey.
func (*MockRecoveryDBMockRecorder) GetSwapRelayerInfo ¶
func (mr *MockRecoveryDBMockRecorder) GetSwapRelayerInfo(arg0 interface{}) *gomock.Call
GetSwapRelayerInfo indicates an expected call of GetSwapRelayerInfo.
func (*MockRecoveryDBMockRecorder) PutContractSwapInfo ¶
func (mr *MockRecoveryDBMockRecorder) PutContractSwapInfo(arg0, arg1 interface{}) *gomock.Call
PutContractSwapInfo indicates an expected call of PutContractSwapInfo.
func (*MockRecoveryDBMockRecorder) PutCounterpartySwapKeys ¶
func (mr *MockRecoveryDBMockRecorder) PutCounterpartySwapKeys(arg0, arg1, arg2 interface{}) *gomock.Call
PutCounterpartySwapKeys indicates an expected call of PutCounterpartySwapKeys.
func (*MockRecoveryDBMockRecorder) PutCounterpartySwapPrivateKey ¶
func (mr *MockRecoveryDBMockRecorder) PutCounterpartySwapPrivateKey(arg0, arg1 interface{}) *gomock.Call
PutCounterpartySwapPrivateKey indicates an expected call of PutCounterpartySwapPrivateKey.
func (*MockRecoveryDBMockRecorder) PutNewSwapTxHash ¶ added in v0.3.0
func (mr *MockRecoveryDBMockRecorder) PutNewSwapTxHash(arg0, arg1 interface{}) *gomock.Call
PutNewSwapTxHash indicates an expected call of PutNewSwapTxHash.
func (*MockRecoveryDBMockRecorder) PutSwapPrivateKey ¶
func (mr *MockRecoveryDBMockRecorder) PutSwapPrivateKey(arg0, arg1 interface{}) *gomock.Call
PutSwapPrivateKey indicates an expected call of PutSwapPrivateKey.
func (*MockRecoveryDBMockRecorder) PutSwapRelayerInfo ¶
func (mr *MockRecoveryDBMockRecorder) PutSwapRelayerInfo(arg0, arg1 interface{}) *gomock.Call
PutSwapRelayerInfo indicates an expected call of PutSwapRelayerInfo.
type NetSender ¶
type NetSender interface { SendSwapMessage(common.Message, types.Hash) error DeleteOngoingSwap(offerID types.Hash) CloseProtocolStream(id types.Hash) DiscoverRelayers() ([]peer.ID, error) // Only used by Maker QueryRelayerAddress(peer.ID) (types.Hash, error) // only used by taker SubmitRelayRequest(peer.ID, *message.RelayClaimRequest) (*message.RelayClaimResponse, error) // only used by taker }
NetSender consists of Host methods invoked by the Maker/Taker
type RecoveryDB ¶
type RecoveryDB interface { PutContractSwapInfo(id types.Hash, info *db.EthereumSwapInfo) error GetContractSwapInfo(id types.Hash) (*db.EthereumSwapInfo, error) PutSwapPrivateKey(id types.Hash, keys *mcrypto.PrivateSpendKey) error GetSwapPrivateKey(id types.Hash) (*mcrypto.PrivateSpendKey, error) PutCounterpartySwapPrivateKey(id types.Hash, keys *mcrypto.PrivateSpendKey) error GetCounterpartySwapPrivateKey(id types.Hash) (*mcrypto.PrivateSpendKey, error) PutSwapRelayerInfo(id types.Hash, info *types.OfferExtra) error GetSwapRelayerInfo(id types.Hash) (*types.OfferExtra, error) PutCounterpartySwapKeys(id types.Hash, sk *mcrypto.PublicKey, vk *mcrypto.PrivateViewKey) error GetCounterpartySwapKeys(id types.Hash) (*mcrypto.PublicKey, *mcrypto.PrivateViewKey, error) PutNewSwapTxHash(id types.Hash, txHash types.Hash) error GetNewSwapTxHash(id types.Hash) (types.Hash, error) DeleteSwap(id types.Hash) error }
RecoveryDB is implemented by *db.RecoveryDB