Documentation ¶
Index ¶
- Variables
- func NewSwapTx(unspents []explorer.Utxo, inAsset string, inAmount uint64, outAsset string, ...) (string, error)
- type BuyOrSellAndCompleteOpts
- type BuyOrSellOpts
- type NewTradeOpts
- type PreviewOpts
- type PreviewResult
- type Trade
- func (t *Trade) Buy(opts BuyOrSellOpts) ([]byte, error)
- func (t *Trade) BuyAndComplete(opts BuyOrSellAndCompleteOpts) (string, error)
- func (t *Trade) Preview(opts PreviewOpts) (*PreviewResult, error)
- func (t *Trade) Sell(opts BuyOrSellOpts) ([]byte, error)
- func (t *Trade) SellAndComplete(opts BuyOrSellAndCompleteOpts) (string, error)
- type Wallet
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNullAddress ... ErrNullAddress = errors.New("address must not be null") // ErrInvalidAsset ... ErrInvalidAsset = errors.New("asset must be a 32-byte array in hex format") // ErrInvalidAddress ... ErrInvalidAddress = errors.New("address is not valid") // ErrNullPrivateKey ... ErrNullPrivateKey = errors.New("private key must not be null") // ErrNullBlindingKey ... ErrNullBlindingKey = errors.New("blinding key must not be null") )
var ( // ErrInvalidMarket ... ErrInvalidMarket = errors.New( "market must be a pair of valid 32-bytes assets encoded in hex format", ) // ErrInvalidTradeType ... ErrInvalidTradeType = errors.New("trade type must be either BUY or SELL") // ErrInvalidAmount ... ErrInvalidAmount = errors.New("amount must be a positive satoshi amount") )
var ( // ErrInvalidChain ... ErrInvalidChain = fmt.Errorf( "chain must be either '%s' or '%s", network.Liquid.Name, network.Regtest.Name, ) // ErrInvalidProviderURL ... ErrInvalidProviderURL = fmt.Errorf( "provider url must be a valid url in the form 'host:port'", ) // ErrNullExplorer ... ErrNullExplorer = fmt.Errorf("explorer must not be null") // ErrNullClient ... ErrNullClient = fmt.Errorf("client must not be null") )
Functions ¶
Types ¶
type BuyOrSellAndCompleteOpts ¶
type BuyOrSellAndCompleteOpts struct { Market trademarket.Market TradeType int Amount uint64 Asset string PrivateKey []byte BlindingKey []byte }
BuyOrSellAndCompleteOpts is the struct given to Buy method
type BuyOrSellOpts ¶
type BuyOrSellOpts struct { Market trademarket.Market Amount uint64 Asset string Address string BlindingKey []byte }
BuyOrSellOpts is the struct given to Buy/Sell method
type NewTradeOpts ¶
type NewTradeOpts struct { Chain string ExplorerService explorer.Service Client *tradeclient.Client }
NewTradeOpts is the struct given to NewTrade method
type PreviewOpts ¶
type PreviewOpts struct { Market trademarket.Market TradeType int Amount uint64 Asset string }
PreviewOpts is the struct given to Preview method
type PreviewResult ¶
type PreviewResult struct { AssetToSend string AmountToSend uint64 AssetToReceive string AmountToReceive uint64 }
PreviewResult is the struct returned by Preview method
type Trade ¶
type Trade struct {
// contains filtered or unexported fields
}
func NewTrade ¶
func NewTrade(opts NewTradeOpts) (*Trade, error)
NewTrade returns a new trade initialized with the given arguments
func (*Trade) Buy ¶
func (t *Trade) Buy(opts BuyOrSellOpts) ([]byte, error)
Buy creates a new trade proposal with the given arguments and sends it to the server which the inner client is connected to. This method returns the SwapAccept serialized message eventually returned by the counter-party.
func (*Trade) BuyAndComplete ¶
func (t *Trade) BuyAndComplete(opts BuyOrSellAndCompleteOpts) (string, error)
BuyAndComplete creates a new trade proposal with the give arguments. The transaction of the resulting SwapAccept message is then signed with the provided private key, and sent back again to the connected server, which will take care of finalizing and broadcasting it.
func (*Trade) Preview ¶
func (t *Trade) Preview(opts PreviewOpts) (*PreviewResult, error)
Preview queries the gRPC server to get the latest price for the given market, then calculates the amount to send or to receive depending on the given type.
func (*Trade) Sell ¶
func (t *Trade) Sell(opts BuyOrSellOpts) ([]byte, error)
Sell creates a new trade proposal with the given arguments for selling a certain amount of base asset of the provided market pair. This proposal is then sent to the server which the inner client is connected to and, eventually, the resulting SwapAccept serialized message returned by the counter-party is returned to the caller.
func (*Trade) SellAndComplete ¶
func (t *Trade) SellAndComplete(opts BuyOrSellAndCompleteOpts) (string, error)
SellAndComplete creates a new trade proposal with the given arguments for selling a certain amount of base asset of the provided market pair. If the proposal is accepted, it's then counter-signed with the provided private key and sent back again to the server that will take care of finalizing and broadcasting the transaction
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}