Documentation ¶
Index ¶
- type DB
- func (db DB) AddNewTransaction(log *logrus.Entry, paymentChannel paymentchannel.Channel, txHash string, ...) (isDuplicate bool, err error)
- func (db *DB) GetActiveExchangeCurrecnyByID(exchangeID int, phaseID int, log *logrus.Entry) (*ExchangeCurrency, *m.IcoPhaseActivatedExchangeCurrency, error)
- func (db *DB) GetAllICOs(log *logrus.Entry) (m.IcoSlice, error)
- func (db *DB) GetBitcoinBlockToProcess() (uint64, error)
- func (db *DB) GetEthereumBlockToProcess() (uint64, error)
- func (db *DB) GetExchangeCurrecnyByCode(assetCode string, log *logrus.Entry) (*ExchangeCurrency, error)
- func (db *DB) GetExchangeCurrecnyByID(id int, log *logrus.Entry) (*ExchangeCurrency, error)
- func (db *DB) GetICOByID(id int, log *logrus.Entry) (*m.Ico, error)
- func (db *DB) GetICOPhaseByID(id int, log *logrus.Entry) (*m.IcoPhase, error)
- func (db *DB) GetOrderForAddress(l paymentchannel.Channel, address string, paymentUsage string) (*m.UserOrder, error)
- func (db *DB) GetStellarLedgerToProcess() (int, error)
- func (db *DB) PriceForCoins(coins int64, ec *ExchangeCurrency, ph *m.IcoPhase) (denom *big.Int, nativAmount string, err error)
- func (db *DB) SaveLastProcessedBitcoinBlock(block uint64) error
- func (db *DB) SaveLastProcessedEthereumBlock(block uint64) error
- func (db *DB) SaveLastProcessedStellarLedger(ledgerID int) error
- type ExchangeCurrency
- type ExchangeCurrencySlice
- type NativeCalculator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB general DB struct
func CreateNewDB ¶
CreateNewDB creates a new DB connection
func (DB) AddNewTransaction ¶
func (db DB) AddNewTransaction(log *logrus.Entry, paymentChannel paymentchannel.Channel, txHash string, toAddress string, fromAddress string, order *m.UserOrder, denomAmount *big.Int, BTCOutIndex int) (isDuplicate bool, err error)
AddNewTransaction adds a transaction from the payment network to the database and returns true, if it was allready present The function implies, that the order is in status OrderStatusPaymentReceived
func (*DB) GetActiveExchangeCurrecnyByID ¶
func (db *DB) GetActiveExchangeCurrecnyByID(exchangeID int, phaseID int, log *logrus.Entry) (*ExchangeCurrency, *m.IcoPhaseActivatedExchangeCurrency, error)
GetActiveExchangeCurrecnyByID returns the phase activated EC for the given id error if not activated
func (*DB) GetAllICOs ¶
GetAllICOs returns a list of all ICOs
func (*DB) GetBitcoinBlockToProcess ¶
GetBitcoinBlockToProcess saves the last processed btc block
func (*DB) GetEthereumBlockToProcess ¶
GetEthereumBlockToProcess gets the last processed eth block
func (*DB) GetExchangeCurrecnyByCode ¶
func (db *DB) GetExchangeCurrecnyByCode(assetCode string, log *logrus.Entry) (*ExchangeCurrency, error)
GetExchangeCurrecnyByCode returns the EC for the given asset code
func (*DB) GetExchangeCurrecnyByID ¶
GetExchangeCurrecnyByID returns the EC for the given id
func (*DB) GetICOByID ¶
GetICOByID returns the given ICO by ID
func (*DB) GetICOPhaseByID ¶
GetICOPhaseByID returns the given ICOPhase by ID
func (*DB) GetOrderForAddress ¶
func (db *DB) GetOrderForAddress(l paymentchannel.Channel, address string, paymentUsage string) (*m.UserOrder, error)
GetOrderForAddress reads the user orders for open payments for the specified address and chain If no open order was found(OrderStatusWaitingForPayment), the function will return either nil or filter for any other order with the given address The function will be called for EVERY payment transaction in the external PaymentNetworks paymentUsage is either an empty string or, for stellar, the MEMO with the orderID. If no memo/or wrong was given, the order will not be processed
func (*DB) GetStellarLedgerToProcess ¶
GetStellarLedgerToProcess returns the new ledgerid to process
func (*DB) PriceForCoins ¶
func (db *DB) PriceForCoins(coins int64, ec *ExchangeCurrency, ph *m.IcoPhase) (denom *big.Int, nativAmount string, err error)
PriceForCoins returns the price for a given token-amount
func (*DB) SaveLastProcessedBitcoinBlock ¶
SaveLastProcessedBitcoinBlock saves the last processed btc block
func (*DB) SaveLastProcessedEthereumBlock ¶
SaveLastProcessedEthereumBlock saves the last processed eth block
func (*DB) SaveLastProcessedStellarLedger ¶
SaveLastProcessedStellarLedger saves the last processed stellar ledger
type ExchangeCurrency ¶
type ExchangeCurrency struct { *m.ExchangeCurrency NativeCalculator }
ExchangeCurrency is one ec
type ExchangeCurrencySlice ¶
type ExchangeCurrencySlice []*ExchangeCurrency
ExchangeCurrencySlice list of ec's
type NativeCalculator ¶
type NativeCalculator struct {
// contains filtered or unexported fields
}
NativeCalculator calculates the native and denomination amounts
func NewNativeCalculator ¶
func NewNativeCalculator(decimals int) NativeCalculator
NewNativeCalculator returns a new calculator that can be used in NativeCalculator
func (*NativeCalculator) DenomFromNativ ¶
func (nc *NativeCalculator) DenomFromNativ(nativValue string) (*big.Int, error)
DenomFromNativ converts a given nativ (string)value (like eth,xlm,btc,euro) to its denomination The value can be in format 123.45 or 123,45 If the maximum number of accuracy is exceeded, an error is returned
func (*NativeCalculator) DenomFromString ¶
func (nc *NativeCalculator) DenomFromString(denomValue string) (*big.Int, error)
DenomFromString returns the denominator as *big.Int for a given denominator string, e.g. 1234567