ports

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const AnyTopic = "*"
View Source
const UnspecifiedTopic = ""

Variables

This section is empty.

Functions

This section is empty.

Types

type Account added in v1.0.0

type Account interface {
	CreateAccount(
		ctx context.Context, accountName string, isMarket bool,
	) (WalletAccount, error)
	DeriveAddresses(
		ctx context.Context, accountName string, num int,
	) ([]string, error)
	DeriveChangeAddresses(
		ctx context.Context, accountName string, num int,
	) ([]string, error)
	ListAddresses(ctx context.Context, accountName string) ([]string, error)
	GetBalance(
		ctx context.Context, accountName string,
	) (map[string]Balance, error)
	ListUtxos(
		ctx context.Context, accountName string,
	) ([]Utxo, []Utxo, error)
	DeleteAccount(ctx context.Context, accountName string) error
}

type Balance added in v1.0.0

type Balance interface {
	GetConfirmedBalance() uint64
	GetUnconfirmedBalance() uint64
	GetLockedBalance() uint64
	GetTotalBalance() uint64
}

type BlockInfo added in v1.0.0

type BlockInfo interface {
	GetHash() string
	GetHeight() uint64
	GetTimestamp() int64
}

type BuildData added in v1.0.0

type BuildData interface {
	GetVersion() string
	GetCommit() string
	GetDate() string
}

type CustomPeriod added in v1.0.0

type CustomPeriod interface {
	GetStartDate() string
	GetEndDate() string
}

type Deposit added in v1.0.0

type Deposit interface {
	GetTxid() string
	GetTotalAmountPerAsset() map[string]uint64
	GetTimestamp() int64
}

type FragmenterReply added in v1.0.0

type FragmenterReply interface {
	GetMessage() string
	GetError() error
}

type Market added in v1.0.0

type Market interface {
	GetBaseAsset() string
	GetQuoteAsset() string
}

type MarketCollectedFees added in v1.0.0

type MarketCollectedFees interface {
	GetBaseAmount() uint64
	GetQuoteAmount() uint64
	GetTradeFeeInfo() []TradeFeeInfo
	GetStartDate() string
	GetEndDate() string
}

type MarketFee added in v1.0.0

type MarketFee interface {
	GetBaseAsset() uint64
	GetQuoteAsset() uint64
}

type MarketInfo added in v1.0.0

type MarketInfo interface {
	GetMarket() Market
	GetName() string
	IsTradable() bool
	GetStrategyType() MarketStrategy
	GetBalance() map[string]Balance
	GetPercentageFee() MarketFee
	GetFixedFee() MarketFee
	GetPrice() MarketPrice
	GetBaseAssetPrecision() uint32
	GetQuoteAssetPrecision() uint32
}

type MarketPrice added in v1.0.0

type MarketPrice interface {
	GetBasePrice() decimal.Decimal
	GetQuotePrice() decimal.Decimal
}

type MarketReport added in v1.0.0

type MarketReport interface {
	GetMarket() Market
	GetCollectedFees() MarketCollectedFees
	GetTotalVolume() MarketVolume
	GetVolumesPerFrame() []MarketVolume
}

type MarketStrategy added in v1.0.0

type MarketStrategy interface {
	IsBalanced() bool
	IsPluggable() bool
}

type MarketVolume added in v1.0.0

type MarketVolume interface {
	GetBaseVolume() uint64
	GetQuoteVolume() uint64
	GetStartDate() string
	GetEndDate() string
}

type Notification added in v1.0.0

type Notification interface {
	GetTxNotifications() chan WalletTxNotification
	GetUtxoNotifications() chan WalletUtxoNotification
}

type Page added in v1.0.0

type Page interface {
	GetNumber() int64
	GetSize() int64
}

type PredefinedPeriod added in v1.0.0

type PredefinedPeriod interface {
	IsLastHour() bool
	IsLastDay() bool
	IsLastWeek() bool
	IsLastMonth() bool
	IsLastThreeMonths() bool
	IsYearToDate() bool
	IsLastYear() bool
	IsAll() bool
}

type PriceFeed added in v1.0.0

type PriceFeed interface {
	GetMarket() Market
	GetPrice() MarketPrice
}

type PriceFeedInfo added in v1.0.0

type PriceFeedInfo interface {
	GetId() string
	GetMarket() Market
	GetSource() string
	GetTicker() string
	IsStarted() bool
}

type PriceFeeder added in v1.0.0

type PriceFeeder interface {
	// AddPriceFeed adds a new price feed for the target market.
	AddPriceFeed(
		ctx context.Context, market Market, source, ticker string,
	) (string, error)
	// StartFeed starts forwarding price feeds from the given source to the
	// target market.
	StartPriceFeed(ctx context.Context, id string) (chan PriceFeed, error)
	// StopFeed stops updating the target price feed.
	StopPriceFeed(ctx context.Context, id string) error
	// UpdatePriceFeed updates an existing price feed.
	UpdatePriceFeed(ctx context.Context, id, source, ticker string) error
	// RemovePriceFeed removes an existing price feed.
	RemovePriceFeed(ctx context.Context, id string) error
	// GetPriceFeed returns info about the target price feed.
	GetPriceFeed(ctx context.Context, id string) (PriceFeedInfo, error)
	// ListPriceFeeds returns the list of price feeds.
	ListPriceFeeds(ctx context.Context) ([]PriceFeedInfo, error)
	// ListSources returns the list of supported price sources.
	ListSources(ctx context.Context) []string

	Close()
}

type PubSubStore added in v0.4.0

type PubSubStore interface {
	// Init initialize the store with an optional encryption password.
	Init(password string) error
	// IsLocked returns whether the store is locked.
	IsLocked() bool
	// Lock locks the store.
	Lock()
	// UnlockStore unlocks the internal store.
	Unlock(password string) error
	// ChangePassword allows to change the encryption password.
	ChangePassword(oldPwd, newPwd string) error
	// Close should be used to gracefully close the connection with the store.
	Close() error
}

PubSubStore defines the methods to manage the internal store of a SecurePubSub service.

type RepoManager added in v0.3.1

type RepoManager interface {
	MarketRepository() domain.MarketRepository
	TradeRepository() domain.TradeRepository
	DepositRepository() domain.DepositRepository
	WithdrawalRepository() domain.WithdrawalRepository

	Close()
}

RepoManager interface defines the methods for swap, price and unspent.

type SecurePubSub added in v0.4.0

type SecurePubSub interface {
	// Store returns the internal store.
	Store() PubSubStore
	// Subscribe adds a new subscription for the requested topic.
	Subscribe(topic, endpoint, secret string) (string, error)
	// SubscribeWithID adds a subscription for the requested topic by using the
	// given id instead of assinging a new one.
	SubscribeWithID(id, topic, endpoint, secret string) (string, error)
	// Unsubscribe removes some client defined by its id for a topic.
	Unsubscribe(topic, id string) error
	// ListSubscriptionsForTopic returns the info of all clients subscribed for
	// a certain topic.
	ListSubscriptionsForTopic(topic string) []Subscription
	// Publish publishes a message for a certain topic. All clients subscribed
	// for such topic will receive the message.
	Publish(topic string, message string) error
}

SecurePubSub defines the methods of a pubsub service and its internal store. This service might need to store some data in memory or on the disk, for this reason along with the typical methods of a pubsub service, allows to manage an internal optionally encrypted storage.

type Subscription added in v0.4.0

type Subscription interface {
	Topic() string
	Id() string
	IsSecured() bool
	NotifyAt() string
}

type SwapAccept added in v1.0.0

type SwapAccept interface {
	GetId() string
	GetRequestId() string
	GetTransaction() string
	GetUnblindedInputs() []UnblindedInput
}

type SwapComplete added in v1.0.0

type SwapComplete interface {
	GetId() string
	GetAcceptId() string
	GetTransaction() string
}

type SwapFail added in v1.0.0

type SwapFail interface {
	GetId() string
	GetMessageId() string
	GetFailureCode() uint32
	GetFailureMessage() string
}

type SwapRequest added in v1.0.0

type SwapRequest interface {
	GetId() string
	GetAssetP() string
	GetAmountP() uint64
	GetAssetR() string
	GetAmountR() uint64
	GetTransaction() string
	GetFeeAsset() string
	GetFeeAmount() uint64
	GetUnblindedInputs() []UnblindedInput
}

type TimeRange added in v1.0.0

type TimeRange interface {
	GetPredefinedPeriod() PredefinedPeriod
	GetCustomPeriod() CustomPeriod
}

type Trade added in v1.0.0

type Trade interface {
	GetId() string
	GetType() TradeType
	GetStatus() TradeStatus
	GetSwapInfo() SwapRequest
	GetSwapFailInfo() SwapFail
	GetRequestTimestamp() int64
	GetAcceptTimestamp() int64
	GetCompleteTimestamp() int64
	GetSettleTimestamp() int64
	GetExpiryTimestamp() int64
	GetMarket() Market
	GetMarketPercentageFee() MarketFee
	GetMarketFixedFee() MarketFee
	GetMarketPrice() MarketPrice
	GetTxid() string
	GetTxHex() string
	GetFeeAsset() string
	GetFeeAmount() uint64
}

type TradeFeeInfo added in v1.0.0

type TradeFeeInfo interface {
	GetTradeId() string
	GetPercentageFee() uint64
	GetFixedFee() uint64
	GetFeeAsset() string
	GetFeeAmount() uint64
	GetMarketPrice() decimal.Decimal
	GetTimestamp() int64
}

type TradePreview added in v1.0.0

type TradePreview interface {
	GetAmount() uint64
	GetAsset() string
	GetMarketPercentageFee() MarketFee
	GetMarketFixedFee() MarketFee
	GetMarketPrice() MarketPrice
	GetFeeAmount() uint64
	GetFeeAsset() string
}

type TradeStatus added in v1.0.0

type TradeStatus interface {
	IsRequest() bool
	IsAccept() bool
	IsComplete() bool
	IsSettled() bool
	IsExpired() bool
	IsFailed() bool
}

type TradeType added in v1.0.0

type TradeType interface {
	IsBuy() bool
	IsSell() bool
}

type Transaction

type Transaction interface {
	GetTransaction(ctx context.Context, txid string) (string, error)
	EstimateFees(
		ctx context.Context, ins []TxInput, outs []TxOutput, msatsPerByte uint64,
	) (uint64, error)
	SelectUtxos(
		ctx context.Context, accountName, asset string, amount uint64,
	) ([]Utxo, uint64, int64, error)
	CreatePset(
		ctx context.Context, ins []TxInput, outs []TxOutput,
	) (string, error)
	UpdatePset(
		ctx context.Context, pset string,
		ins []TxInput, outs []TxOutput,
	) (string, error)
	BlindPset(
		ctx context.Context, pset string, extraUnblindedIns []UnblindedInput,
	) (string, error)
	SignPset(
		ctx context.Context, pset string, extractRawTx bool,
	) (string, error)
	Transfer(
		ctx context.Context,
		accountName string, outs []TxOutput, msatsPerByte uint64,
	) (string, error)
	BroadcastTransaction(ctx context.Context, txHex string) (string, error)
}

type TxInput added in v1.0.0

type TxInput interface {
	UtxoKey
	GetScript() string
	GetScriptSigSize() int
	GetWitnessSize() int
}

type TxOutput added in v1.0.0

type TxOutput interface {
	GetAsset() string
	GetAmount() uint64
	GetScript() string
	GetBlindingKey() string
}

type UnblindedInput added in v1.0.0

type UnblindedInput interface {
	GetIndex() uint32
	GetAsset() string
	GetAmount() uint64
	GetAssetBlinder() string
	GetAmountBlinder() string
}

type Utxo added in v1.0.0

type Utxo interface {
	UtxoKey
	GetAsset() string
	GetValue() uint64
	GetScript() string
	GetAssetBlinder() string
	GetValueBlinder() string
	GetConfirmedStatus() UtxoStatus
	GetSpentStatus() UtxoStatus
	GetRedeemScript() string
}

type UtxoKey added in v1.0.0

type UtxoKey interface {
	GetTxid() string
	GetIndex() uint32
}

type UtxoStatus added in v1.0.0

type UtxoStatus interface {
	GetTxid() string
	GetBlockInfo() BlockInfo
}

type Wallet added in v1.0.0

type Wallet interface {
	GenSeed(ctx context.Context) ([]string, error)
	InitWallet(ctx context.Context, mnemonic []string, password string) error
	RestoreWallet(ctx context.Context, mnemonic []string, password string) error
	Unlock(ctx context.Context, password string) error
	Lock(ctx context.Context, password string) error
	ChangePassword(ctx context.Context, oldPwd, newPwd string) error
	Status(ctx context.Context) (WalletStatus, error)
	Info(ctx context.Context) (WalletInfo, error)
	Auth(ctx context.Context, password string) (bool, error)
}

type WalletAccount added in v1.0.0

type WalletAccount interface {
	GetNamespace() string
	GetLabel() string
	GetDerivationPath() string
	GetXpubs() []string
	GetMasterBlindingKey() string
}

type WalletInfo added in v1.0.0

type WalletInfo interface {
	GetNetwork() string
	GetNativeAsset() string
	GetRootPath() string
	GetBirthdayBlockHash() string
	GetBirthdayBlockHeight() uint32
	GetAccounts() []WalletAccount
}

type WalletService added in v1.0.0

type WalletService interface {
	Wallet() Wallet
	Account() Account
	Transaction() Transaction
	Notification() Notification
	Close()
}

type WalletStatus added in v1.0.0

type WalletStatus interface {
	IsInitialized() bool
	IsUnlocked() bool
	IsSynced() bool
}

type WalletTxEventType added in v1.0.0

type WalletTxEventType interface {
	IsUnconfirmed() bool
	IsConfirmed() bool
	IsBroadcasted() bool
}

type WalletTxNotification added in v1.0.0

type WalletTxNotification interface {
	GetEventType() WalletTxEventType
	GetAccountNames() []string
	GetTxHex() string
	GetBlockDetails() BlockInfo
}

type WalletUtxoEventType added in v1.0.0

type WalletUtxoEventType interface {
	IsUnconfirmed() bool
	IsConfirmed() bool
	IsLocked() bool
	IsUnlocked() bool
	IsSpent() bool
}

type WalletUtxoNotification added in v1.0.0

type WalletUtxoNotification interface {
	GetEventType() WalletUtxoEventType
	GetUtxos() []Utxo
}

type Webhook added in v1.0.0

type Webhook interface {
	GetId() string
	GetEvent() WebhookEvent
	GetEndpoint() string
	GetSecret() string
}

type WebhookEvent added in v1.0.0

type WebhookEvent interface {
	IsUnspecified() bool
	IsTradeSettled() bool
	IsAccountLowBalance() bool
	IsAccountWithdraw() bool
	IsAccountDeposit() bool
	IsAny() bool
}

type WebhookInfo added in v1.0.0

type WebhookInfo interface {
	GetId() string
	GetEvent() WebhookEvent
	GetEndpoint() string
	IsSecured() bool
}

type Withdrawal added in v1.0.0

type Withdrawal interface {
	GetTxid() string
	GetTotalAmountPerAsset() map[string]uint64
	GetTimestamp() int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL