Documentation
¶
Index ¶
- Constants
- Variables
- type AddressAndBlindingKey
- type Balance
- type BalanceInfo
- type BalanceWithFee
- type Blinder
- type BlindingData
- type BlockchainListener
- type Fee
- type FeeInfo
- type FillProposalOpts
- type FillProposalResult
- type InitWalletReply
- type Market
- type MarketInfo
- type MarketStrategy
- type MarketWithFee
- type MarketWithPrice
- type OperatorService
- type Price
- type PriceWithFee
- type ReportMarketFee
- type SendToManyRequest
- type SwapInfo
- type TradeHandler
- type TradeService
- type TxOut
- type TxOutpoint
- type UnblindedResult
- type Unspents
- type UtxoInfo
- type UtxoInfoList
- type WalletService
- type WithdrawMarketReq
Constants ¶
View Source
const ( TradeBuy = iota TradeSell )
View Source
const ( Processing = iota Done )
Variables ¶
View Source
var ( // ErrFeeAccountNotFunded ... ErrFeeAccountNotFunded = errors.New("fee account not funded") // ErrUnknownStrategy ... ErrUnknownStrategy = errors.New("strategy not supported") // ErrTxNotConfirmed ... ErrTxNotConfirmed = errors.New("transaction not confirmed") // ErrMarketNotExist ... ErrMarketNotExist = errors.New("market does not exists") // ErrMarketNotFunded ... ErrMarketNotFunded = errors.New("market account not funded") // ErrMissingNonFundedMarkets ... ErrMissingNonFundedMarkets = errors.New("no non-funded markets found") // ErrInvalidOutpoint ... ErrInvalidOutpoint = errors.New("outpoint refers to inexistent tx output") // ErrInvalidOutpoints ... ErrInvalidOutpoints = errors.New("all outpoints must be funded for the same account") )
View Source
var ( BlinderManager Blinder TradeManager TradeHandler )
View Source
var ( // ErrWalletNotFunded ... ErrWalletNotFunded = fmt.Errorf("wallet not funded") // ErrWalletIsSyncing ... ErrWalletIsSyncing = fmt.Errorf( "wallet is syncing data from blockchain. All functionalities are " + "disabled until this operation is completed", ) // ErrWalletNotInitialized ... ErrWalletNotInitialized = fmt.Errorf("wallet not initialized") )
Functions ¶
This section is empty.
Types ¶
type AddressAndBlindingKey ¶ added in v0.1.2
type BalanceInfo ¶ added in v0.3.0
type BalanceWithFee ¶
type Blinder ¶ added in v0.3.1
type Blinder interface {
UnblindOutput(txout *transaction.TxOutput, key []byte) (UnblindedResult, bool)
}
type BlindingData ¶ added in v0.3.2
type BlindingData wallet.BlindingData
type BlockchainListener ¶
type BlockchainListener interface {
StartObservation()
StopObservation()
StartObserveAddress(accountIndex int, addr string, blindKey []byte)
StopObserveAddress(addr string)
StartObserveTx(txid string)
StopObserveTx(txid string)
}
BlockchainListener defines the needed method sto start and stop a blockchain listener
func NewBlockchainListener ¶
func NewBlockchainListener( crawlerSvc crawler.Service, repoManager ports.RepoManager, marketBaseAsset string, net *network.Network, ) BlockchainListener
NewBlockchainListener returns a BlockchainListener with all the needed services
type Fee ¶
type Fee struct {
BasisPoint int64
}
Fee is the market fee percentage in basis point:
- 0,01% -> 1 bp
- 1,00% -> 100 bp
- 99,99% -> 9999 bp
type FillProposalOpts ¶ added in v0.3.2
type FillProposalOpts struct {
Mnemonic []string
SwapRequest domain.SwapRequest
MarketUtxos []explorer.Utxo
FeeUtxos []explorer.Utxo
MarketInfo domain.AddressesInfo
FeeInfo domain.AddressesInfo
OutputInfo domain.AddressInfo
ChangeInfo domain.AddressInfo
FeeChangeInfo domain.AddressInfo
Network *network.Network
}
type FillProposalResult ¶ added in v0.3.2
type InitWalletReply ¶ added in v0.3.0
type MarketInfo ¶
type MarketInfo struct {
AccountIndex uint64
Market Market
Fee Fee
Tradable bool
StrategyType int
Price domain.Prices
}
MarketInfo is the data struct returned by ListMarket RPC.
type MarketStrategy ¶
type MarketStrategy struct {
Market
Strategy domain.StrategyType
}
type MarketWithFee ¶
type MarketWithPrice ¶
type OperatorService ¶
type OperatorService interface {
DepositMarket(
ctx context.Context,
baseAsset string,
quoteAsset string,
numOfAddresses int,
) ([]AddressAndBlindingKey, error)
DepositFeeAccount(
ctx context.Context,
numOfAddresses int,
) ([]AddressAndBlindingKey, error)
OpenMarket(
ctx context.Context,
baseAsset string,
quoteAsset string,
) error
CloseMarket(
ctx context.Context,
baseAsset string,
quoteAsset string,
) error
UpdateMarketFee(
ctx context.Context,
req MarketWithFee,
) (*MarketWithFee, error)
UpdateMarketPrice(
ctx context.Context,
req MarketWithPrice,
) error
UpdateMarketStrategy(
ctx context.Context,
req MarketStrategy,
) error
ListSwaps(
ctx context.Context,
) ([]SwapInfo, error)
ListMarketExternalAddresses(
ctx context.Context,
req Market,
) ([]string, error)
WithdrawMarketFunds(
ctx context.Context,
req WithdrawMarketReq,
) (
[]byte,
error,
)
FeeAccountBalance(ctx context.Context) (
int64,
error,
)
ClaimMarketDeposit(
ctx context.Context,
market Market,
outpoints []TxOutpoint,
) error
ClaimFeeDeposit(
ctx context.Context,
outpoints []TxOutpoint,
) error
ListMarket(
ctx context.Context,
) ([]MarketInfo, error)
GetCollectedMarketFee(
ctx context.Context,
market Market,
) (*ReportMarketFee, error)
ListUtxos(ctx context.Context) (map[uint64]UtxoInfoList, error)
ReloadUtxos(ctx context.Context) error
DropMarket(ctx context.Context, accountIndex int) error
}
OperatorService defines the methods of the application layer for the operator service.
func NewOperatorService ¶
func NewOperatorService( repoManager ports.RepoManager, explorerSvc explorer.Service, bcListener BlockchainListener, marketBaseAsset string, marketFee int64, net *network.Network, feeAccountBalanceThreshold uint64, ) OperatorService
NewOperatorService is a constructor function for OperatorService.
type ReportMarketFee ¶
type SendToManyRequest ¶
type SwapInfo ¶
type SwapInfo struct {
Status int32
AmountP uint64
AssetP string
AmountR uint64
AssetR string
MarketFee Fee
RequestTimeUnix uint64
AcceptTimeUnix uint64
CompleteTimeUnix uint64
ExpiryTimeUnix uint64
}
SwapInfo is the data struct returned by ListSwap RPC.
type TradeHandler ¶ added in v0.3.2
type TradeHandler interface {
FillProposal(FillProposalOpts) (*FillProposalResult, error)
}
type TradeService ¶
type TradeService interface {
GetTradableMarkets(ctx context.Context) ([]MarketWithFee, error)
GetMarketPrice(
ctx context.Context,
market Market,
tradeType int,
amount uint64,
asset string,
) (*PriceWithFee, error)
TradePropose(
ctx context.Context,
market Market,
tradeType int,
swapRequest domain.SwapRequest,
) (domain.SwapAccept, domain.SwapFail, uint64, error)
TradeComplete(
ctx context.Context,
swapComplete *domain.SwapComplete,
swapFail *domain.SwapFail,
) (string, domain.SwapFail, error)
GetMarketBalance(
ctx context.Context,
market Market,
) (*BalanceWithFee, error)
}
func NewTradeService ¶
func NewTradeService( repoManager ports.RepoManager, explorerSvc explorer.Service, bcListener BlockchainListener, marketBaseAsset string, expiryDuration time.Duration, priceSlippage decimal.Decimal, net *network.Network, ) TradeService
type TxOutpoint ¶ added in v0.3.0
type UnblindedResult ¶ added in v0.3.1
type UnblindedResult *transactionutil.UnblindedResult
type UtxoInfo ¶ added in v0.3.0
type UtxoInfo struct {
Outpoint *TxOutpoint
Value uint64
Asset string
}
type UtxoInfoList ¶ added in v0.3.0
type WalletService ¶
type WalletService interface {
GenSeed(ctx context.Context) ([]string, error)
InitWallet(
ctx context.Context,
mnemonic []string,
passphrase string,
restore bool,
chRes chan *InitWalletReply,
chErr chan error,
)
UnlockWallet(
ctx context.Context,
passphrase string,
) error
ChangePassword(
ctx context.Context,
currentPassphrase string,
newPassphrase string) error
GenerateAddressAndBlindingKey(
ctx context.Context,
) (address string, blindingKey string, err error)
GetWalletBalance(
ctx context.Context,
) (map[string]BalanceInfo, error)
SendToMany(
ctx context.Context,
req SendToManyRequest,
) ([]byte, error)
}
func NewWalletService ¶
func NewWalletService( repoManager ports.RepoManager, explorerService explorer.Service, blockchainListener BlockchainListener, withElements bool, net *network.Network, marketFee int64, marketBaseAsset string, ) (WalletService, error)
Click to show internal directories.
Click to hide internal directories.