Documentation ¶
Overview ¶
Package txsender provides a common Sender interface for swapd instances. Each Sender implementation is responsible for signing and submitting transactions to the network. privateKeySender is the implementation using an ethereum private key directly managed by swapd. ExternalSender provides an API for interacting with an external entity like Metamask.
Index ¶
- type ExternalSender
- func (s *ExternalSender) Claim(swap *contracts.SwapCreatorSwap, secret [32]byte) (*ethtypes.Receipt, error)
- func (s *ExternalSender) IncomingCh(_ types.Hash) chan<- ethcommon.Hash
- func (s *ExternalSender) NewSwap(claimCommitment [32]byte, refundCommitment [32]byte, claimer ethcommon.Address, ...) (*ethtypes.Receipt, error)
- func (s *ExternalSender) OngoingCh(_ types.Hash) <-chan *Transaction
- func (s *ExternalSender) Refund(swap *contracts.SwapCreatorSwap, secret [32]byte) (*ethtypes.Receipt, error)
- func (s *ExternalSender) SetReady(swap *contracts.SwapCreatorSwap) (*ethtypes.Receipt, error)
- func (s *ExternalSender) SetSwapCreator(_ *contracts.SwapCreator)
- func (s *ExternalSender) SetSwapCreatorAddr(addr ethcommon.Address)
- type Sender
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExternalSender ¶
ExternalSender represents a transaction signer and sender that is external to the daemon (ie. a front-end)
func NewExternalSender ¶
func NewExternalSender( ctx context.Context, env common.Environment, ec *ethclient.Client, contractAddr ethcommon.Address, erc20Addr ethcommon.Address, ) (*ExternalSender, error)
NewExternalSender returns a new ExternalSender
func (*ExternalSender) Claim ¶
func (s *ExternalSender) Claim( swap *contracts.SwapCreatorSwap, secret [32]byte, ) (*ethtypes.Receipt, error)
Claim prompts the external sender to sign a claim transaction
func (*ExternalSender) IncomingCh ¶
func (s *ExternalSender) IncomingCh(_ types.Hash) chan<- ethcommon.Hash
IncomingCh returns the channel of incoming transaction hashes that have been signed and submitted
func (*ExternalSender) NewSwap ¶
func (s *ExternalSender) NewSwap( claimCommitment [32]byte, refundCommitment [32]byte, claimer ethcommon.Address, timeoutDuration *big.Int, nonce *big.Int, amount coins.EthAssetAmount, saveNewSwapTxCallback func(txHash ethcommon.Hash) error, ) (*ethtypes.Receipt, error)
NewSwap prompts the external sender to sign a new_swap transaction
func (*ExternalSender) OngoingCh ¶
func (s *ExternalSender) OngoingCh(_ types.Hash) <-chan *Transaction
OngoingCh returns the channel of outgoing transactions to be signed and submitted
func (*ExternalSender) Refund ¶
func (s *ExternalSender) Refund( swap *contracts.SwapCreatorSwap, secret [32]byte, ) (*ethtypes.Receipt, error)
Refund prompts the external sender to sign a refund transaction
func (*ExternalSender) SetReady ¶
func (s *ExternalSender) SetReady(swap *contracts.SwapCreatorSwap) (*ethtypes.Receipt, error)
SetReady prompts the external sender to sign a set_ready transaction
func (*ExternalSender) SetSwapCreator ¶
func (s *ExternalSender) SetSwapCreator(_ *contracts.SwapCreator)
SetSwapCreator sets the bound contract for the SwapCreator
func (*ExternalSender) SetSwapCreatorAddr ¶
func (s *ExternalSender) SetSwapCreatorAddr(addr ethcommon.Address)
SetSwapCreatorAddr sets the address of the SwapCreator contract
type Sender ¶
type Sender interface { SetSwapCreator(*contracts.SwapCreator) SetSwapCreatorAddr(ethcommon.Address) NewSwap( claimCommitment [32]byte, refundCommitment [32]byte, claimer ethcommon.Address, timeoutDuration *big.Int, nonce *big.Int, amount coins.EthAssetAmount, saveNewSwapTxCallback func(txHash ethcommon.Hash) error, ) (*ethtypes.Receipt, error) SetReady(swap *contracts.SwapCreatorSwap) (*ethtypes.Receipt, error) Claim(swap *contracts.SwapCreatorSwap, secret [32]byte) (*ethtypes.Receipt, error) Refund(swap *contracts.SwapCreatorSwap, secret [32]byte) (*ethtypes.Receipt, error) }
Sender signs and submits transactions to the chain
func NewSenderWithPrivateKey ¶
func NewSenderWithPrivateKey( ctx context.Context, ethClient extethclient.EthClient, swapCreatorAddr ethcommon.Address, swapCreator *contracts.SwapCreator, erc20Contract *contracts.IERC20, ) Sender
NewSenderWithPrivateKey returns a new *privateKeySender
type Transaction ¶
type Transaction struct { To ethcommon.Address Data []byte Value *apd.Decimal // ETH (or ETH asset), not WEI }
Transaction represents a transaction to be signed by the front-end