bitbon

package
v0.0.0-...-e03aae4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

nolint:dupl

nolint:dupl

nolint:nakedret

Contains the Bibon constant definitions

nolint:nakedret,dupl

Index

Constants

View Source
const (
	ProtocolVersionStr     = "1.0.0"                  // The same, as a string
	ProtocolName           = "bitbon"                 // Nickname of the protocol in geth
	PrivateStorageFileName = ".bitbon.storage.sqlite" // File name for storage

	MaxPrepareAssetboxBatchSize     = 100
	DefaultPrepareAssetboxBatchSize = 10
	MaxPrepareAssetboxRetries       = 2
)

Bitbon constants

View Source
const MaxBlockPeriod = 300
View Source
const MaxBlockRange = 100
View Source
const MaxCheckTxPeriod = 300
View Source
const MaxTxPeriod = 300
View Source
const (
	SettingContractStorageAddress = "contract_storage_addr"
)

Variables

View Source
var DefaultConfig = Config{}

DefaultConfig represents (shocker!) the default configuration.

View Source
var ErrAPIStopped = errors.New("bitbon API has stopped")
View Source
var (
	ErrDistributionAccountsAndAmountsLengthMismatch = errors.New("fee distribution accounts and amounts has different size")
)
View Source
var (
	// ErrEmptyAddress is returned if passed assetbox address is empty
	ErrEmptyAddress = errors.New("empty address given")
)

Functions

func DecryptAssetboxWallet

func DecryptAssetboxWallet(walletEncrypted, passPhraseEncrypted []byte, password string, decryptFn func(data, key []byte) ([]byte, error)) (*keystore.Key, error)

func DecryptPrivateKeyForAssetbox

func DecryptPrivateKeyForAssetbox(address common.Address, walletEncrypted, passPhraseEncrypted []byte, password string, decryptFn func(data, key []byte) ([]byte, error)) (*ecdsa.PrivateKey, error)

func InitServicePart

func InitServicePart(b *Bitbon, config *Config) (err error)

func InitStorages

func InitStorages(ctx *node.ServiceContext, b *Bitbon) (err error)

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API provides the bitbon RPC service

func NewAPI

func NewAPI(b *Bitbon) *API

NewAPI create a new RPC bitbon service.

func (*API) AddMiningAgent

func (api *API) AddMiningAgent(ctx context.Context, address common.Address) error

func (*API) ApproveFullBalanceSafeTransfer

func (api *API) ApproveFullBalanceSafeTransfer(ctx context.Context, transfer *dto.ApproveFullBalanceSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) ApproveFullBalanceSafeTransferAsync

func (api *API) ApproveFullBalanceSafeTransferAsync(ctx context.Context, transfer *dto.ApproveFullBalanceSafeTransferRequest) (*common.Hash, error)

func (*API) ApproveFullBalanceWPCSafeTransfer

func (api *API) ApproveFullBalanceWPCSafeTransfer(ctx context.Context, transfer *dto.ApproveFullBalanceWPCSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) ApproveFullBalanceWPCSafeTransferAsync

func (api *API) ApproveFullBalanceWPCSafeTransferAsync(ctx context.Context, transfer *dto.ApproveFullBalanceWPCSafeTransferRequest) (*common.Hash, error)

func (*API) ApproveSafeTransfer

func (api *API) ApproveSafeTransfer(ctx context.Context,
	transfer *dto.ApproveSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) ApproveSafeTransferAsync

func (api *API) ApproveSafeTransferAsync(ctx context.Context,
	transfer *dto.ApproveSafeTransferRequest) (*common.Hash, error)

func (*API) ApproveWPCSafeTransfer

func (api *API) ApproveWPCSafeTransfer(ctx context.Context,
	transfer *dto.ApproveWPCSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) ApproveWPCSafeTransferAsync

func (api *API) ApproveWPCSafeTransferAsync(ctx context.Context,
	transfer *dto.ApproveWPCSafeTransferRequest) (*common.Hash, error)

func (*API) BalanceOfLocked

func (api *API) BalanceOfLocked(ctx context.Context, address common.Address) (*big.Int, error)

func (*API) BlockByHash

func (api *API) BlockByHash(ctx context.Context, hash common.Hash) (*dto.Block, error)

func (*API) BlockByNumber

func (api *API) BlockByNumber(ctx context.Context, number uint64) (*dto.Block, error)

func (*API) BlockByTime

func (api *API) BlockByTime(ctx context.Context, time uint64) (*dto.Block, error)

func (*API) BlockTransactionCountByBlockHash

func (api *API) BlockTransactionCountByBlockHash(ctx context.Context, hash common.Hash) (uint64, error)

func (*API) BlockTransactionCountByBlockNumber

func (api *API) BlockTransactionCountByBlockNumber(ctx context.Context, number uint64) (uint64, error)

func (*API) BlocksByTimePeriod

func (api *API) BlocksByTimePeriod(ctx context.Context, request *dto.BlocksTimePeriodRequest) ([]*dto.Block, error)

func (*API) CancelFullBalanceSafeTransfer

func (api *API) CancelFullBalanceSafeTransfer(ctx context.Context, transfer *dto.CancelFullBalanceSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CancelFullBalanceSafeTransferAsync

func (api *API) CancelFullBalanceSafeTransferAsync(ctx context.Context, transfer *dto.CancelFullBalanceSafeTransferRequest) (*common.Hash, error)

func (*API) CancelFullBalanceWPCSafeTransfer

func (api *API) CancelFullBalanceWPCSafeTransfer(ctx context.Context, transfer *dto.CancelFullBalanceWPCSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CancelFullBalanceWPCSafeTransferAsync

func (api *API) CancelFullBalanceWPCSafeTransferAsync(ctx context.Context, transfer *dto.CancelFullBalanceWPCSafeTransferRequest) (*common.Hash, error)

func (*API) CancelSafeTransfer

func (api *API) CancelSafeTransfer(ctx context.Context,
	transfer *dto.CancelSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CancelSafeTransferAsync

func (api *API) CancelSafeTransferAsync(ctx context.Context,
	transfer *dto.CancelSafeTransferRequest) (*common.Hash, error)

func (*API) CancelWPCSafeTransfer

func (api *API) CancelWPCSafeTransfer(ctx context.Context,
	transfer *dto.CancelWPCSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CancelWPCSafeTransferAsync

func (api *API) CancelWPCSafeTransferAsync(ctx context.Context,
	transfer *dto.CancelWPCSafeTransferRequest) (*common.Hash, error)

func (*API) CheckTransactionsByTimePeriod

func (api *API) CheckTransactionsByTimePeriod(_ context.Context,
	request *dto.TransactionTimePeriodRequest) (hash common.Hash, err error)

func (*API) CreateFullBalanceSafeTransfer

func (api *API) CreateFullBalanceSafeTransfer(ctx context.Context, transfer *dto.CreateFullBalanceSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CreateFullBalanceSafeTransferAsync

func (api *API) CreateFullBalanceSafeTransferAsync(ctx context.Context, transfer *dto.CreateFullBalanceSafeTransferRequest) (*common.Hash, error)

func (*API) CreateFullBalanceWPCSafeTransfer

func (api *API) CreateFullBalanceWPCSafeTransfer(ctx context.Context, transfer *dto.CreateFullBalanceWPCSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CreateFullBalanceWPCSafeTransferAsync

func (api *API) CreateFullBalanceWPCSafeTransferAsync(ctx context.Context, transfer *dto.CreateFullBalanceWPCSafeTransferRequest) (*common.Hash, error)

func (*API) CreateSafeTransfer

func (api *API) CreateSafeTransfer(ctx context.Context,
	transfer *dto.CreateSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CreateSafeTransferAsync

func (api *API) CreateSafeTransferAsync(ctx context.Context,
	transfer *dto.CreateSafeTransferRequest) (*common.Hash, error)

func (*API) CreateWPCSafeTransfer

func (api *API) CreateWPCSafeTransfer(ctx context.Context,
	transfer *dto.CreateWPCSafeTransferRequest) (*dto.TransferResponse, error)

func (*API) CreateWPCSafeTransferAsync

func (api *API) CreateWPCSafeTransferAsync(ctx context.Context,
	transfer *dto.CreateWPCSafeTransferRequest) (*common.Hash, error)

func (*API) DeleteAbiInfoByAddress

func (api *API) DeleteAbiInfoByAddress(address common.Address) (err error)

func (*API) DeleteAssetbox

func (api *API) DeleteAssetbox(ctx context.Context, req *dto.DeleteAssetboxRequest) error

func (*API) DirectTransfer

func (api *API) DirectTransfer(ctx context.Context,
	transfer *dto.DirectTransferRequest) (*dto.TransferResponse, error)

func (*API) DirectTransferAsync

func (api *API) DirectTransferAsync(ctx context.Context, transfer *dto.DirectTransferRequest) (*common.Hash, error)

func (*API) EditAbiInfo

func (api *API) EditAbiInfo(abiInfo *dto.AbiInfo) (err error)

func (*API) ExpireTransfersAsync

func (api *API) ExpireTransfersAsync(ctx context.Context, ids []string) (*common.Hash, error)

func (*API) FeeTransferAsync

func (api *API) FeeTransferAsync(ctx context.Context, transfer *dto.ServiceFeeTransferRequest) (*common.Hash, error)

func (*API) FillCurrentAbiInfo

func (api *API) FillCurrentAbiInfo(_ context.Context,
	version dto.ContractVersion) (addresses []common.Address, err error)

func (*API) FrameTransfer

func (api *API) FrameTransfer(ctx context.Context, transfer *dto.QuickTransferRequest) (*dto.TransferResponse, error)

func (*API) FrameTransferAsync

func (api *API) FrameTransferAsync(ctx context.Context, transfer *dto.QuickTransferRequest) (*common.Hash, error)

func (*API) FullBalanceQuickTransfer

func (api *API) FullBalanceQuickTransfer(ctx context.Context, transfer *dto.FullBalanceQuickTransferRequest) (*dto.TransferResponse, error)

func (*API) FullBalanceQuickTransferAsync

func (api *API) FullBalanceQuickTransferAsync(ctx context.Context, transfer *dto.FullBalanceQuickTransferRequest) (*common.Hash, error)

func (*API) GetAbiAddressesByVersion

func (api *API) GetAbiAddressesByVersion(version dto.ContractVersion) (addresses []common.Address, err error)

func (*API) GetAbiInfosByVersion

func (api *API) GetAbiInfosByVersion(version dto.ContractVersion) (abiInfos []*dto.AbiInfo, err error)

func (*API) GetAbiJSON

func (api *API) GetAbiJSON(address common.Address) (abiJSON string, err error)

func (*API) GetAbiVersion

func (api *API) GetAbiVersion(address common.Address) (version dto.ContractVersion, err error)

func (*API) GetAllMiningAgents

func (api *API) GetAllMiningAgents(ctx context.Context) ([]common.Address, error)

func (*API) GetAsseboxesMiningState

func (api *API) GetAsseboxesMiningState(ctx context.Context, addresses []common.Address) (map[common.Address]bool, error)

func (*API) GetAssetboxBalance

func (api *API) GetAssetboxBalance(ctx context.Context, address common.Address) (*big.Int, error)

func (*API) GetAssetboxBalances

func (api *API) GetAssetboxBalances(ctx context.Context,
	addresses []common.Address) (map[common.Address]*big.Int, error)

func (*API) GetAssetboxBalancesSum

func (api *API) GetAssetboxBalancesSum(ctx context.Context, addresses []common.Address) (*big.Int, error)

func (*API) GetContractAddresses

func (api *API) GetContractAddresses() (map[string]common.Address, error)

func (*API) GetCurrentDistribution

func (api *API) GetCurrentDistribution(ctx context.Context) (map[string]uint64, error)

func (*API) GetFee

func (api *API) GetFee(ctx context.Context, opType dto.OperationType) (*big.Int, error)

func (*API) GetFeeDistributionAccounts

func (api *API) GetFeeDistributionAccounts(ctx context.Context, operationType *big.Int) ([]common.Address, error)

func (*API) GetFeeDistributionAmounts

func (api *API) GetFeeDistributionAmounts(ctx context.Context, operationType *big.Int) ([]*big.Int, error)

func (*API) GetFeeForOperationType

func (api *API) GetFeeForOperationType(ctx context.Context, operationType dto.OperationType) (*big.Int, error)

func (*API) GetFeeSettings

func (api *API) GetFeeSettings(ctx context.Context) (*dto.FeeSettingsResponse, error)

func (*API) GetFullAbiInfo

func (api *API) GetFullAbiInfo(address common.Address) (abiInfo *dto.AbiInfo, err error)

func (*API) GetFullAbiInfoByVersionAndType

func (api *API) GetFullAbiInfoByVersionAndType(version dto.ContractVersion,
	contractType contract_snapshot.ContractType) (abiInfo *dto.AbiInfo, err error)

func (*API) GetPublicAssetboxInfo

func (api *API) GetPublicAssetboxInfo(ctx context.Context,
	address common.Address) (*dto.PublicAssetboxInfoResponse, error)

GetPublicAssetboxInfo returns public assetbox info from blockchain via calling smart contract method

func (*API) GetServiceAddress

func (api *API) GetServiceAddress() common.Address

func (*API) GetTransfer

func (api *API) GetTransfer(ctx context.Context, transferID string) (*contracts.ReceiptTransfer, error)

GetTransfer gets transfer data from blockchain

func (*API) GetTransferByIndex

func (api *API) GetTransferByIndex(ctx context.Context, index *big.Int) (*contracts.ReceiptTransfer, error)

GetTransferByIndex gets transfer data from blockchain

func (*API) IsMiningAgent

func (api *API) IsMiningAgent(ctx context.Context, address common.Address) (bool, error)

func (*API) PrepareAssetboxes

func (api *API) PrepareAssetboxes(ctx context.Context, req *dto.PrepareAssetboxesRequest) ([]*models.ShortAssetbox, error)

func (*API) ProposeDistribution

func (api *API) ProposeDistribution(ctx context.Context, req dto.ProposeDistributionRequest) error

func (*API) QuickTransfer

func (api *API) QuickTransfer(ctx context.Context, transfer *dto.QuickTransferRequest) (*dto.TransferResponse, error)

func (*API) QuickTransferAsync

func (api *API) QuickTransferAsync(ctx context.Context, transfer *dto.QuickTransferRequest) (*common.Hash, error)

Async Transfers - send txHash to client, without waiting while tx has been mined

func (*API) RangeBlockByNumber

func (api *API) RangeBlockByNumber(ctx context.Context, request *dto.RangeBlocksByNumberRequest) ([]*dto.Block, error)

func (*API) RemoveMiningAgent

func (api *API) RemoveMiningAgent(ctx context.Context, address common.Address) error

func (*API) SaveAbiInfo

func (api *API) SaveAbiInfo(abiInfo *dto.AbiInfo) (err error)

func (*API) ServiceFeeTransfer

func (api *API) ServiceFeeTransfer(ctx context.Context, transfer *dto.ServiceFeeTransferRequest) (*dto.TransferResponse, error)

func (*API) SetContractStorageAddress

func (api *API) SetContractStorageAddress(address common.Address) error

func (*API) SetPublicAssetboxInfo

func (api *API) SetPublicAssetboxInfo(ctx context.Context, req *dto.SetPublicAssetboxInfoRequest) error

func (*API) TransactionByBlockHashAndIndex

func (api *API) TransactionByBlockHashAndIndex(ctx context.Context,
	request *dto.TransactionByBlockHashAndIndexRequest) (*dto.Transaction, error)

func (*API) TransactionByBlockNumberAndIndex

func (api *API) TransactionByBlockNumberAndIndex(ctx context.Context,
	request *dto.TransactionByBlockNumberAndIndexRequest) (*dto.Transaction, error)

func (*API) TransactionByHash

func (api *API) TransactionByHash(ctx context.Context, txHash common.Hash) (*dto.Transaction, error)

func (*API) TransactionsByTimePeriod

func (api *API) TransactionsByTimePeriod(ctx context.Context,
	request *dto.TransactionTimePeriodRequest) ([]*dto.Transaction, error)

func (*API) TransferExists

func (api *API) TransferExists(ctx context.Context, transferID string) (bool, error)

TransferExists checks if transfer exists blockchain

func (*API) Version

func (api *API) Version(_ context.Context) string

Version returns the Whisper sub-protocol version.

type APINonce

type APINonce struct {
	// contains filtered or unexported fields
}

API provides the bitbon RPC service

func NewAPINonce

func NewAPINonce(b *Bitbon) *APINonce

NewAPI create a new RPC bitbon service.

func (*APINonce) ForceNoncerAccountNonce

func (api *APINonce) ForceNoncerAccountNonce(ctx context.Context, address common.Address, nonce uint64, force bool) error

ForceNoncerAccountNonce method sets nonce value for address in redis (noncer) Also it does some checks, to disable checks set force flag to true

func (*APINonce) ForceNoncerNonceFromBlockChain

func (api *APINonce) ForceNoncerNonceFromBlockChain(ctx context.Context, address common.Address) error

ForceNoncerNonceFromBlockChain takes the nonce for address from blockchain and sets it to redis noncer

func (*APINonce) GetNoncerAssetboxes

func (api *APINonce) GetNoncerAssetboxes(ctx context.Context) ([]common.Address, error)

func (*APINonce) GetNonces

func (api *APINonce) GetNonces(ctx context.Context, address common.Address) *dto.Nonces

GetNonces returns data according to nonces Fields in *dto.Nonces: dto.Nonces.Redis - nonce in noncer redis (it should be (nonce in blockchain - 1)) dto.Nonces.Blockchain - nonce in blockchain dto.Nonces.TxPoolQueued - min nonce in tx pool queued transactions dto.Nonces.TxPoolPending - min nonce in tx pool pending transactions dto.Nonces.Broken - flag that indicates if nonce is broken (there are transactions in tx pool queued transactions)

func (*APINonce) RemoveAssetboxesFromNoncer

func (api *APINonce) RemoveAssetboxesFromNoncer(ctx context.Context, addresses []common.Address) error

func (*APINonce) RestoreServiceAccountNonce

func (api *APINonce) RestoreServiceAccountNonce(ctx context.Context, fromNonce, toNonce uint64, force bool) error

RestoreServiceAccountNonce restores service account nonce in blockchain. Method creates fake transactions (EmitEther to itself) beginning from fromNonce and till toNonce (fromNonce <= nonce < toNonce) Also it does some checks, to disable checks set force flag to true the main aim of checks is blockchainNonce == noncerNonce + 1

type AssetboxManager

type AssetboxManager interface {
	PrepareAssetbox(ctx context.Context) (assetbox *models.Assetbox, err error)
	PrepareAssetboxes(ctx context.Context, count uint64) (assetboxes []*models.Assetbox, err error)
	SetPublicAssetboxInfo(ctx context.Context, req *dto.SetPublicAssetboxInfoRequest) (err error)
	SetPublicAssetboxInfos(ctx context.Context, assetboxes []*contracts.Assetbox) (err error)
	DeleteAssetbox(ctx context.Context, req *dto.DeleteAssetboxRequest) (err error)
}

type Bitbon

type Bitbon struct {
	// contains filtered or unexported fields
}

func InitDefaultBitbonService

func InitDefaultBitbonService(cfg *Config, ethServ *eth.Ethereum) *Bitbon

func New

func New(ctx *node.ServiceContext, config *Config) (b *Bitbon, err error)

New creates a new Bitbon object (including the initialisation of the common Bitbon object)

func (*Bitbon) APIStopped

func (b *Bitbon) APIStopped() bool

func (*Bitbon) APIs

func (b *Bitbon) APIs() []rpc.API

APIs is a meaningless implementation of node.Service.

func (*Bitbon) GetAPI

func (b *Bitbon) GetAPI() *API

func (*Bitbon) GetAssetboxManager

func (b *Bitbon) GetAssetboxManager() AssetboxManager

func (*Bitbon) GetContractsManager

func (b *Bitbon) GetContractsManager() ContractManager

func (*Bitbon) GetDecryptAssetboxWalletPassword

func (b *Bitbon) GetDecryptAssetboxWalletPassword() string

func (*Bitbon) GetEth

func (b *Bitbon) GetEth() *eth.Ethereum

func (*Bitbon) GetFeeManager

func (b *Bitbon) GetFeeManager() FeeManager

func (*Bitbon) GetParser

func (b *Bitbon) GetParser() *parser.Parser

func (*Bitbon) GetServiceAddress

func (b *Bitbon) GetServiceAddress() common.Address

func (*Bitbon) GetServiceID

func (b *Bitbon) GetServiceID() string

func (*Bitbon) GetServicePk

func (b *Bitbon) GetServicePk() *ecdsa.PrivateKey

func (*Bitbon) GetStorage

func (b *Bitbon) GetStorage() *Storage

func (*Bitbon) GetTransferManager

func (b *Bitbon) GetTransferManager() TransferManager

func (*Bitbon) InitBitbonParser

func (b *Bitbon) InitBitbonParser(apiWrapper *contracts.EthApiWrapper, storage *Storage)

func (*Bitbon) InjectAssetboxManager

func (b *Bitbon) InjectAssetboxManager(am AssetboxManager)

func (*Bitbon) InjectContractManager

func (b *Bitbon) InjectContractManager(cm ContractManager)

func (*Bitbon) InjectFeeManager

func (b *Bitbon) InjectFeeManager(fm FeeManager)

func (*Bitbon) InjectMiningAgent

func (b *Bitbon) InjectMiningAgent(ma MiningAgent)

func (*Bitbon) InjectTransferManager

func (b *Bitbon) InjectTransferManager(tm TransferManager)

func (*Bitbon) Protocols

func (b *Bitbon) Protocols() []p2p.Protocol

Protocols is a meaningless implementation of node.Service.

func (*Bitbon) SetDecryptAssetboxWalletPassword

func (b *Bitbon) SetDecryptAssetboxWalletPassword(value string)

func (*Bitbon) Start

func (b *Bitbon) Start(_ *p2p.Server) (err error)

Start implements node.Service

func (*Bitbon) Stop

func (b *Bitbon) Stop() error

Stop implements node.Service

func (*Bitbon) Stopped

func (b *Bitbon) Stopped() bool

type Config

type Config struct {
	// hex of service private key (ether account)
	ServicePrivateKey string
	// ID of service
	ServiceID string
	// Key for decrypting assetbox wallets
	DecryptAssetboxWalletPassword string
}

Config represents the configuration state of a bitbon service.

type ContractManager

type ContractManager interface {
	// system
	Stop() error
	Ready() bool
	Stopped() bool
	WaitReady(exit chan struct{}) bool
	GetNoncer() *noncer.Noncer

	GetContractAddressAssetboxInfo() (common.Address, error)
	GetContractAddressAssetbox() (common.Address, error)
	GetContractAddressBitbon() (common.Address, error)
	GetContractAddressTransfer() (common.Address, error)
	GetContractAddressSafeTransferStorage() (common.Address, error)
	GetContractAddressBitbonSupport() (common.Address, error)
	GetContractAddressBitbonStorage() (common.Address, error)
	GetContractAddressAccessStorage() (common.Address, error)
	GetContractAddressDistributionStorage() (common.Address, error)
	GetContractAddressMiningAgentStorage() (common.Address, error)
	GetContractStorageAddress() (common.Address, error)
	GetContractAddresses() map[contract_snapshot.ContractType]common.Address
	GetCurrentContractAbiInfo(version dto.ContractVersion) ([]*dto.AbiInfo, error)
	SaveContractStorageAddress(addr common.Address) error
	GetEthAPIWrapper() *contracts.EthApiWrapper

	// assetboxes
	GetAssetboxInfo(ctx context.Context, addr common.Address) (a *contracts.Assetbox, err error)
	GetAssetboxBalance(ctx context.Context, addr common.Address) (balance *big.Int, err error)
	BalanceOfLocked(ctx context.Context, addr common.Address) (balance *big.Int, err error)
	GetAssetboxBalances(ctx context.Context,
		addresses []common.Address) (balances map[common.Address]*big.Int, err error)
	GetAsseboxesMiningState(ctx context.Context, address common.Address) (bool, error)
	GetAssetboxBalancesSum(ctx context.Context, addresses []common.Address) (sum *big.Int, err error)
	SetAssetboxInfo(ctx context.Context, a *contracts.Assetbox, key *ecdsa.PrivateKey) (err error)
	SetAssetboxInfos(ctx context.Context, a []*contracts.Assetbox, key *ecdsa.PrivateKey) (err error)
	GetAssetboxInfoByAlias(ctx context.Context, alias string) (a *contracts.Assetbox, err error)
	DeleteAssetboxInfo(ctx context.Context, key *ecdsa.PrivateKey) (err error)

	// transactions
	EmitEther(ctx context.Context, to common.Address, value *big.Int, nonce *uint64) (err error)
	ApproveWPCSafeTransfer(ctx context.Context, transferID, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	ApproveFullBalanceWPCSafeTransfer(ctx context.Context, transferID, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	CreateWPCSafeTransfer(ctx context.Context, t *contracts.Transfer,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	CreateFullBalanceWPCSafeTransfer(ctx context.Context, t *contracts.Transfer,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	CancelSafeTransfer(ctx context.Context, transferID, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	CancelFullBalanceSafeTransfer(ctx context.Context, transferID, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	ApproveSafeTransfer(ctx context.Context, transferID, protectionCode,
		extraData []byte, key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	ApproveFullBalanceSafeTransfer(ctx context.Context, transferID, protectionCode,
		extraData []byte, key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	WatchBitbonBalanceUnLocked(sink chan<- *contracts.Balance) (err error)
	WatchBitbonBalanceLocked(sink chan<- *contracts.Balance) (err error)
	WatchBitbonBalanceChanged(sink chan<- *contracts.Balance) (err error)
	WatchAssetboxInfoSet(sink chan<- *contracts.Assetbox) (err error)
	WatchTransferExpired(sink chan<- *contracts.TransferExpired) (err error)
	WatchAssetboxInfoDeleted(sink chan<- *contracts.Assetbox) (err error)
	GetExpiredTransfers(ctx context.Context, firstTransfer,
		lastTransfer *big.Int) (expireTransferIds [][32]byte, err error)
	GetTransferLength(ctx context.Context) (transferLength *big.Int, err error)
	GetOldestPending(ctx context.Context) (oldestPendingID *big.Int, err error)
	TransferExists(ctx context.Context, transferID []byte) (exists bool, err error)
	GetTransferState(ctx context.Context, transferID []byte) (state uint8, err error)
	QuickTransfer(ctx context.Context, to common.Address, value *big.Int, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	FullBalanceQuickTransfer(ctx context.Context, to common.Address, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	FrameTransfer(ctx context.Context, to common.Address, value *big.Int, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	GetTransferByIndex(ctx context.Context, index *big.Int) (transfer *contracts.ReceiptTransfer, err error)
	GetTransfer(ctx context.Context, transferID []byte) (transfer *contracts.ReceiptTransfer, err error)
	CancelWPCSafeTransfer(ctx context.Context, transferID, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	CancelFullBalanceWPCSafeTransfer(ctx context.Context, transferID, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	SetOldestPending(ctx context.Context, pendingIndex *big.Int, key *ecdsa.PrivateKey) (err error)
	RemoveMiningAgent(ctx context.Context, address common.Address, key *ecdsa.PrivateKey) (err error)
	ExpireSafeTransfers(ctx context.Context, ids [][32]byte, key *ecdsa.PrivateKey) (blockNum uint64, txHash common.Hash, err error)
	CreateSafeTransfer(ctx context.Context, t *contracts.Transfer,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	CreateFullBalanceSafeTransfer(ctx context.Context, t *contracts.Transfer,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	SearchOldestPending(ctx context.Context, firstTransfer,
		lastTransfer *big.Int) (index *big.Int, present bool, err error)
	IsMiningAgent(ctx context.Context, address common.Address) (res bool, err error)
	DirectTransfer(ctx context.Context, from, to common.Address,
		value *big.Int, extraData []byte,
		key *ecdsa.PrivateKey, async bool) (blockNum uint64, txHash common.Hash, err error)
	AddMiningAgent(ctx context.Context, address common.Address, key *ecdsa.PrivateKey) (err error)
	GetCurrentDistribution(ctx context.Context) (distribution map[string]uint64, err error)
	ProposeDistribution(ctx context.Context, distribution map[string]uint64, key *ecdsa.PrivateKey) (err error)
	GetAllMiningAgents(ctx context.Context) (res []common.Address, err error)

	ServiceFeeTransfer(ctx context.Context, params dto.ServiceFeeTransferParams, async bool) (blockNum uint64, txHash common.Hash, err error)
	GetFee(ctx context.Context, opType dto.OperationType) (fee *big.Int, err error)
	GetFeeDistributionAccounts(ctx context.Context, operationType *big.Int) (accounts []common.Address, err error)
	GetFeeDistributionAmounts(ctx context.Context, operationType *big.Int) (amounts []*big.Int, err error)
	GetFeeValueSettings(ctx context.Context) (optTypes []*big.Int, feeValues []*big.Int, err error)
	WatchFeeValueChanged(sink chan<- *contracts.FeeValueChanged) error
	WatchExceptionalAccountsChanged(sink chan<- *contracts.ExceptionalAccountsChanged) error
	WatchFeeDistributionSettingsChanged(sink chan<- *contracts.DistributionSettingsChanged) error
}

type FeeManager

type FeeManager interface {
	GetFee(ctx context.Context, opType dto.OperationType) (*big.Int, error)
	GetFeeDistributionAccounts(ctx context.Context, operationType *big.Int) ([]common.Address, error)
	GetFeeDistributionAmounts(ctx context.Context, operationType *big.Int) ([]*big.Int, error)
	GetFeeSettings(ctx context.Context) (*models.FeeSettingsResponseObj, error)
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewFeeManager

func NewFeeManager(b *Bitbon) *Manager

func (*Manager) GetFee

func (f *Manager) GetFee(ctx context.Context, opType dto.OperationType) (*big.Int, error)

func (*Manager) GetFeeDistributionAccounts

func (f *Manager) GetFeeDistributionAccounts(ctx context.Context, operationType *big.Int) ([]common.Address, error)

func (*Manager) GetFeeDistributionAmounts

func (f *Manager) GetFeeDistributionAmounts(ctx context.Context, operationType *big.Int) ([]*big.Int, error)

func (*Manager) GetFeeDistributionSettings

func (f *Manager) GetFeeDistributionSettings(ctx context.Context, optType *big.Int) ([]*models.FeeDistribution, error)

func (*Manager) GetFeeSettings

func (f *Manager) GetFeeSettings(ctx context.Context) (*models.FeeSettingsResponseObj, error)

type MiningAgent

type MiningAgent interface {
	ProposeDistribution(ctx context.Context,
		req dto.ProposeDistributionRequest) (err error)
	GetCurrentDistribution(ctx context.Context) (distribution map[string]uint64, err error)
	GetAllMiningAgents(ctx context.Context) (res []common.Address, err error)
	IsMiningAgent(ctx context.Context, address common.Address) (res bool, err error)
	AddMiningAgent(ctx context.Context, address common.Address) (err error)
	RemoveMiningAgent(ctx context.Context, address common.Address) (err error)
}

type PkEncryptor

type PkEncryptor interface {
	Encrypt(data, key []byte) ([]byte, error)
	Decrypt(data, key []byte) ([]byte, error)
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(dbPath string) (dbStorage *Storage, err error)

func (*Storage) BeginAbiTransaction

func (s *Storage) BeginAbiTransaction() (storage.Transaction, error)

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) DeleteAbiInfoByAddress

func (s *Storage) DeleteAbiInfoByAddress(tx storage.Transaction, address common.Address) (err error)

func (*Storage) EditAbiInfo

func (s *Storage) EditAbiInfo(tx storage.Transaction, abiInfo *dto.AbiInfo) (err error)

func (*Storage) GetAbiAddressesByVersion

func (s *Storage) GetAbiAddressesByVersion(tx storage.Transaction,
	version dto.ContractVersion) (addresses []common.Address, err error)

func (*Storage) GetAbiInfosByVersion

func (s *Storage) GetAbiInfosByVersion(tx storage.Transaction,
	version dto.ContractVersion) (abiInfos []*dto.AbiInfo, err error)

func (*Storage) GetAbiJSON

func (s *Storage) GetAbiJSON(tx storage.Transaction, address common.Address) (abiJSON string, err error)

func (*Storage) GetAbiVersion

func (s *Storage) GetAbiVersion(tx storage.Transaction,
	address common.Address) (version dto.ContractVersion, err error)

func (*Storage) GetFullAbiInfo

func (s *Storage) GetFullAbiInfo(tx storage.Transaction, address common.Address) (abiInfo *dto.AbiInfo, err error)

func (*Storage) GetFullAbiInfoByVersionAndType

func (s *Storage) GetFullAbiInfoByVersionAndType(tx storage.Transaction, version dto.ContractVersion,
	contractType contract_snapshot.ContractType) (abiInfo *dto.AbiInfo, err error)

func (*Storage) GetSettingContractStorageAddress

func (s *Storage) GetSettingContractStorageAddress() (common.Address, error)

func (*Storage) SaveAbiInfo

func (s *Storage) SaveAbiInfo(tx storage.Transaction, abiInfo *dto.AbiInfo) (err error)

func (*Storage) SaveSettingContractStorageAddress

func (s *Storage) SaveSettingContractStorageAddress(addr common.Address) error

type TransferManager

type TransferManager interface {
	Stop() error

	QuickTransfer(ctx context.Context, transfer *models.QuickTransferObj) (*models.TransferResponseObj, error)
	QuickTransferAsync(ctx context.Context, transfer *models.QuickTransferObj) (*models.TransferResponseObj, error)
	FrameTransfer(ctx context.Context, transfer *models.QuickTransferObj) (*models.TransferResponseObj, error)
	FrameTransferAsync(ctx context.Context, transfer *models.QuickTransferObj) (*models.TransferResponseObj, error)
	CreateSafeTransfer(ctx context.Context, transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	CreateSafeTransferAsync(ctx context.Context,
		transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	ApproveSafeTransfer(ctx context.Context, transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	ApproveSafeTransferAsync(ctx context.Context,
		transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	CancelSafeTransfer(ctx context.Context, transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	CancelSafeTransferAsync(ctx context.Context,
		transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	CreateWPCSafeTransfer(ctx context.Context,
		transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	CreateWPCSafeTransferAsync(ctx context.Context,
		transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	ApproveWPCSafeTransfer(ctx context.Context,
		transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	ApproveWPCSafeTransferAsync(ctx context.Context,
		transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	CancelWPCSafeTransfer(ctx context.Context, transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	CancelWPCSafeTransferAsync(ctx context.Context,
		transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	DirectTransfer(ctx context.Context, transfer *models.DirectTransferObj) (*models.TransferResponseObj, error)
	DirectTransferAsync(ctx context.Context, transfer *models.DirectTransferObj) (*models.TransferResponseObj, error)
	ExpireTransfersAsync(ctx context.Context, ids []string) (*models.TransferResponseObj, error)
	GetTransfer(ctx context.Context, transferID string) (*contracts.ReceiptTransfer, error)
	GetTransferByIndex(ctx context.Context, index *big.Int) (*contracts.ReceiptTransfer, error)
	TransferExists(ctx context.Context, transferID string) (bool, error)
	ServiceFeeTransfer(ctx context.Context, transfer *models.ServiceFeeTransferObj) (*models.TransferResponseObj, error)
	ServiceFeeTransferAsync(ctx context.Context, transfer *models.ServiceFeeTransferObj) (*models.TransferResponseObj, error)
	FullBalanceQuickTransfer(ctx context.Context, transfer *models.QuickTransferObj) (*models.TransferResponseObj, error)
	FullBalanceQuickTransferAsync(ctx context.Context, transfer *models.QuickTransferObj) (*models.TransferResponseObj, error)
	CreateFullBalanceWPCSafeTransfer(ctx context.Context, transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	CreateFullBalanceWPCSafeTransferAsync(ctx context.Context, transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	ApproveFullBalanceWPCSafeTransfer(ctx context.Context, transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	ApproveFullBalanceWPCSafeTransferAsync(ctx context.Context, transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	CancelFullBalanceWPCSafeTransfer(ctx context.Context, transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	CancelFullBalanceWPCSafeTransferAsync(ctx context.Context, transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	CreateFullBalanceSafeTransfer(ctx context.Context, transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	CreateFullBalanceSafeTransferAsync(ctx context.Context, transfer *models.CreateTransferObj) (*models.TransferResponseObj, error)
	ApproveFullBalanceSafeTransfer(ctx context.Context, transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	ApproveFullBalanceSafeTransferAsync(ctx context.Context, transfer *models.ApproveTransferObj) (*models.TransferResponseObj, error)
	CancelFullBalanceSafeTransfer(ctx context.Context, transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
	CancelFullBalanceSafeTransferAsync(ctx context.Context, transfer *models.CancelTransferObj) (*models.TransferResponseObj, error)
}

Directories

Path Synopsis
Contains the Bibon constant definitions
Contains the Bibon constant definitions
nolint:dupl
nolint:dupl
nolint:nakedret,dupl nolint:nakedret nolint:nakedret nolint:nakedret nolint:nakedret nolint:nakedret,dupl nolint:nakedret,dupl
nolint:nakedret,dupl nolint:nakedret nolint:nakedret nolint:nakedret nolint:nakedret nolint:nakedret,dupl nolint:nakedret,dupl
nolint:nakedret nolint:nakedret nolint:nakedret nolint:nakedret
nolint:nakedret nolint:nakedret nolint:nakedret nolint:nakedret
dto
nolint:golint,stylecheck
nolint:golint,stylecheck
nolint:nakedret Package transfer is a generated GoMock package.
nolint:nakedret Package transfer is a generated GoMock package.

Jump to

Keyboard shortcuts

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