common

package
v0.0.0-...-e54d674 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BTC   = NewSymbol("BTC", 8)
	BNB   = NewSymbol("BNB", 8)
	BTCB1 = NewSymbol("BTC.B", 8)
	BTCB2 = NewSymbol("BTCB", 8)
	ETH   = NewSymbol("ETH", 18)
)
View Source
var Symbols = []Symbol{BTC, BNB, BTCB1, BTCB2}

If this list is updated please also update it in data/fees.go

Functions

This section is empty.

Types

type Amount

type Amount interface {
	fmt.Stringer
	// Adds another Amount to this one and returns a new Amount
	Add(Amount) (Amount, error)
	// Subtracts another Amount from this one and returns a new Amount
	Sub(Amount) (Amount, error)
	// Checks for amount equality and returns true if both are equal
	Equals(Amount) bool
	// Returns amount as big int
	BigInt() *big.Int
	// Returns amount in satoshi unit format
	Int() int64
	Uint() uint64
	// Returns the number of decimal precision
	DecimalCount() int
	// Floor the last n number of decimals
	// precision is calculated by Amount.Decimals - n
	// decimals = 6 & n = 3 | 0.123456 -> 0.123000
	FloorDecimals(n int) Amount
	// Returns a string with the number of decimals fixed to the number of decimals for this Amount (e.g. 0.00010000 if 8 decimals)
	StringFixedDecs() string
}

type AmountUnit

type AmountUnit int

type BroadcastParams

type BroadcastParams struct {
	HEX string `json:"hex"`
}

type BroadcastResponse

type BroadcastResponse struct {
	Response
	TxHash string `json:"txHash,omitempty"`
}

type Db

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

func NewDB

func NewDB() *Db

func (*Db) AddMempoolTxs

func (d *Db) AddMempoolTxs(addr string, tx Transaction) error

func (*Db) GetIdxs

func (d *Db) GetIdxs(address string, isReceived bool) ([]Index, error)

func (*Db) GetMemoTxs

func (d *Db) GetMemoTxs(memo string) ([]string, error)

func (*Db) GetMempoolTxs

func (d *Db) GetMempoolTxs(addr string) ([]Transaction, error)

func (*Db) GetTx

func (d *Db) GetTx(key string) (*Transaction, error)

func (*Db) Start

func (d *Db) Start(path string, pruneHours int64) error

func (*Db) StoreIdx

func (d *Db) StoreIdx(id string, tx *Transaction, isReceived bool) error

func (*Db) StoreMemoTxs

func (d *Db) StoreMemoTxs(memo string, txkey string) error

func (*Db) StoreMempoolTxs

func (d *Db) StoreMempoolTxs(addr string, txs []Transaction) error

func (*Db) StoreTx

func (d *Db) StoreTx(key string, tx Transaction) error

type DynamicAmount

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

func NewAmountFromBigInt

func NewAmountFromBigInt(i *big.Int) (DynamicAmount, error)

func NewAmountFromBigIntDirect

func NewAmountFromBigIntDirect(val *big.Int) (DynamicAmount, error)

func NewAmountFromFloat64

func NewAmountFromFloat64(f float64) (DynamicAmount, error)

func NewAmountFromInt64

func NewAmountFromInt64(val int64) (DynamicAmount, error)

func NewAmountFromString

func NewAmountFromString(val string) (DynamicAmount, error)

func (DynamicAmount) Add

func (b DynamicAmount) Add(y Amount) (Amount, error)

func (DynamicAmount) BigInt

func (b DynamicAmount) BigInt() *big.Int

func (DynamicAmount) DecimalCount

func (b DynamicAmount) DecimalCount() int

func (DynamicAmount) Equals

func (b DynamicAmount) Equals(y Amount) bool

func (DynamicAmount) FloorDecimals

func (b DynamicAmount) FloorDecimals(decimals int) Amount

func (DynamicAmount) Int

func (b DynamicAmount) Int() int64

func (DynamicAmount) String

func (b DynamicAmount) String() string

func (DynamicAmount) StringFixedDecs

func (b DynamicAmount) StringFixedDecs() string

func (DynamicAmount) Sub

func (b DynamicAmount) Sub(y Amount) (Amount, error)

func (DynamicAmount) Uint

func (b DynamicAmount) Uint() uint64

type Idxs

type Idxs []Index

func (Idxs) GetRangeTxs

func (idxs Idxs) GetRangeTxs(fromNum int, toNum int) []Index

type Index

type Index struct {
	ID        string
	Height    int64
	Timestamp int64
}

type Response

type Response struct {
	Result bool   `json:"result"`
	Msg    string `json:"msg,omitempty"`
}

type Symbol

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

func NewSymbol

func NewSymbol(s string, decimals int) Symbol

func (*Symbol) Decimlas

func (s *Symbol) Decimlas() int

func (*Symbol) String

func (s *Symbol) String() string

type Transaction

type Transaction struct {
	TxID        string
	From        string
	To          string
	Amount      Amount
	Timestamp   time.Time
	Currency    Symbol
	Height      int64
	Memo        string
	OutputIndex int
	Spent       bool
}

func (Transaction) MarshalJSON

func (tx Transaction) MarshalJSON() ([]byte, error)

func (Transaction) Serialize

func (tx Transaction) Serialize() string

type TxJSON

type TxJSON struct {
	TxID        string `json:"txId"`
	From        string `json:"from"`
	To          string `json:"to"`
	Amount      string `json:"amount"`
	Currency    string `json:"currency"`
	Decimals    int    `json:"decimals"`
	Height      int64  `json:"height"`
	Timestamp   int64  `json:"time"`
	Memo        string `json:"memo"`
	OutputIndex int    `json:"outputIndex"`
	Spent       bool   `json:"spent"`
}

func (TxJSON) ToCommTx

func (t TxJSON) ToCommTx() (Transaction, error)

type TxResponse

type TxResponse struct {
	Response
	LatestHeight  int64         `json:"latestHeight"`
	InTxsMempool  []Transaction `json:"inTxsMempool"`
	InTxs         []Transaction `json:"inTxs"`
	OutTxsMempool []Transaction `json:"outTxsMempool"`
	OutTxs        []Transaction `json:"outTxs"`
}

type Txs

type Txs []Transaction

func (Txs) Page

func (txs Txs) Page(page int, limit int) Txs

func (Txs) ReceiveMempool

func (txs Txs) ReceiveMempool(address string) Txs

func (Txs) SendMempool

func (txs Txs) SendMempool(address string) Txs

func (Txs) Sort

func (txs Txs) Sort() Txs

Jump to

Keyboard shortcuts

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