Documentation ¶
Overview ¶
Package xmrmaker manages the swap state of individual swaps where the local swapd instance is offering Monero and accepting Ethereum assets in return.
Index ¶
- type Config
- type Event
- type EventContractReady
- type EventETHLocked
- type EventETHRefunded
- type EventExit
- type EventType
- type Host
- type Instance
- func (inst *Instance) ClearOffers(offerIDs []types.Hash) error
- func (inst *Instance) GetMoneroBalance() (*mcrypto.Address, *wallet.GetBalanceResponse, error)
- func (inst *Instance) GetOffers() []*types.Offer
- func (inst *Instance) GetOngoingSwapState(id types.Hash) common.SwapState
- func (inst *Instance) HandleInitiateMessage(takerPeerID peer.ID, msg *message.SendKeysMessage) (net.SwapState, error)
- func (inst *Instance) MakeOffer(o *types.Offer, useRelayer bool) (*types.OfferExtra, error)
- func (inst *Instance) Provides() coins.ProvidesCoin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Backend backend.Backend Database offers.Database DataDir string WalletFile, WalletPassword string ExternalSender bool Network Host }
Config contains the configuration values for a new XMRMaker instance.
type EventContractReady ¶
type EventContractReady struct {
// contains filtered or unexported fields
}
EventContractReady is the second expected event. It represents the contract being ready for us to claim the ETH.
type EventETHLocked ¶
type EventETHLocked struct {
// contains filtered or unexported fields
}
EventETHLocked is the first expected event. It represents ETH being locked on-chain.
type EventETHRefunded ¶
type EventETHRefunded struct {
// contains filtered or unexported fields
}
EventETHRefunded is an optional event. It represents the ETH being refunded back to the counterparty, and thus we also must refund.
type EventExit ¶
type EventExit struct {
// contains filtered or unexported fields
}
EventExit is an optional event. It is sent when the protocol should be stopped, for example if the remote peer closes their connection with us before sending all required messages, or we decide to cancel the swap.
type EventType ¶
type EventType byte
EventType represents an event that occurs which moves the swap "state machine" to its next state.
const ( // EventETHLockedType is triggered when the taker notifies us that the ETH // is locked in the smart contract. Upon verification, it causes us to lock // our XMR. After this event, the other possible events are // EventContractReadyType (success), EventETHRefundedType (abort), or // EventExitType (abort). EventETHLockedType EventType = iota // EventContractReadyType is triggered when the taker sets the contract to // "ready" or timeout1 is reached. When this event occurs, we can claim ETH // from the contract. After this event, the other possible events are // EventETHRefundedType (which would only happen if we go offline until // timeout2, causing us to refund), or EventExitType (refund). EventContractReadyType // EventETHRefundedType is triggered when the taker refunds the // contract-locked ETH back to themselves. It causes use to try to refund // our XMR. After this event, the only possible event is EventExitType. EventETHRefundedType // EventExitType is triggered by the protocol "exiting", which may happen // via a swap cancellation via the RPC endpoint, or from the counterparty // disconnecting from us on the p2p network. It causes us to attempt to // gracefully exit from the swap, which leads to an abort, refund, or claim, // depending on the state we're currently in. No other events can occur // after this. EventExitType // EventNoneType is set as the "nextExpectedEvent" once the swap has exited. // It does not trigger any action. No other events can occur after this. EventNoneType )
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance implements the functionality that will be needed by a user who owns XMR and wishes to swap for ETH.
func NewInstance ¶
NewInstance returns a new *xmrmaker.Instance. It accepts an endpoint to a monero-wallet-rpc instance where account 0 contains XMRMaker's XMR.
func (*Instance) ClearOffers ¶
ClearOffers clears all offers.
func (*Instance) GetMoneroBalance ¶
GetMoneroBalance returns the primary wallet address, and current balance of the user's monero wallet.
func (*Instance) GetOngoingSwapState ¶
GetOngoingSwapState ...
func (*Instance) HandleInitiateMessage ¶
func (inst *Instance) HandleInitiateMessage( takerPeerID peer.ID, msg *message.SendKeysMessage, ) (net.SwapState, error)
HandleInitiateMessage is called when we receive a network message from a peer that they wish to initiate a swap.
func (*Instance) Provides ¶
func (inst *Instance) Provides() coins.ProvidesCoin
Provides returns types.ProvidesXMR