Documentation
¶
Index ¶
- Constants
- Variables
- func BlockHeight(ctx cosmos.Context) int64
- func ConvertAndEncode(hrp string, data []byte) (string, error)
- func Decrypt(data []byte, passphrase string) ([]byte, error)
- func Encrypt(data []byte, passphrase string) ([]byte, error)
- func GetShare(part, total, allocation cosmos.Uint) cosmos.Uint
- func RandStringBytesMask(n int) string
- func SafeSub(input1, input2 cosmos.Uint) cosmos.Uint
- func UpdateGasPrice(tx Tx, asset Asset, units []cosmos.Uint) []cosmos.Uint
- type Account
- type AccountCoin
- type AccountCoins
- type Address
- type Asset
- type Chain
- type ChainNetwork
- type ChainPoolInfo
- type Chains
- type Coin
- type Coins
- type Duration
- type Fee
- type Gas
- type PubKey
- func (pubKey PubKey) Equals(pubKey1 PubKey) bool
- func (pubKey PubKey) GetAddress(chain Chain) (Address, error)
- func (pubKey PubKey) GetThorAddress() (cosmos.AccAddress, error)
- func (pubKey PubKey) IsEmpty() bool
- func (pubKey PubKey) MarshalJSON() ([]byte, error)
- func (pubKey PubKey) String() string
- func (pubKey *PubKey) UnmarshalJSON(data []byte) error
- type PubKeySet
- type PubKeys
- type Symbol
- type Ticker
- type Tickers
- type Tx
- type TxID
- type TxIDs
- type Txs
Constants ¶
const ( // BNBSymbol BNB BNBSymbol = Symbol("BNB") // Rune67CSymbol RUNE on binance testnet Rune67CSymbol = Symbol("RUNE-67C") // RuneB1ASymbol RUNE on binance mainnet RuneB1ASymbol = Symbol("RUNE-B1A") )
const ( // BNBTicker BNB BNBTicker = Ticker("BNB") // RuneTicker RUNE RuneTicker = Ticker("RUNE") )
const NoSigningAlgo = keys.SigningAlgo("")
NoSigningAlgo empty signing algorithm
const One = 100000000
One is useful type so THORNode doesn't need to manage 8 zeroes all the time
Variables ¶
var ( // EmptyAsset empty asset, not valid EmptyAsset = Asset{Chain: EmptyChain, Symbol: "", Ticker: ""} // BNBAsset BNB BNBAsset = Asset{Chain: BNBChain, Symbol: "BNB", Ticker: "BNB"} // BTCAsset BTC BTCAsset = Asset{Chain: BTCChain, Symbol: "BTC", Ticker: "BTC"} // ETHAsset ETH ETHAsset = Asset{Chain: ETHChain, Symbol: "ETH", Ticker: "ETH"} // Rune67CAsset RUNE on Binance test net Rune67CAsset = Asset{Chain: BNBChain, Symbol: "RUNE-67C", Ticker: "RUNE"} // testnet asset on binance ganges // RuneB1AAsset RUNE on Binance main net RuneB1AAsset = Asset{Chain: BNBChain, Symbol: "RUNE-B1A", Ticker: "RUNE"} // mainnet // RuneNative RUNE on thorchain RuneNative = Asset{Chain: THORChain, Symbol: "RUNE", Ticker: "RUNE"} )
var ( EmptyChain = Chain("") BNBChain = Chain("BNB") ETHChain = Chain("ETH") BTCChain = Chain("BTC") THORChain = Chain("THOR") )
var BNBGasFeeMulti = Gas{ {Asset: BNBAsset, Amount: bnbMultiTxFee}, }
BNBGasFeeMulti gas fee for multi send
var BNBGasFeeSingleton = Gas{ {Asset: BNBAsset, Amount: bnbSingleTxFee}, }
BNBGasFeeSingleton fee charged by Binance for transfer with a single coin
var BlankTxID = TxID("0000000000000000000000000000000000000000000000000000000000000000")
BlankTxID represent blank
var ETHGasFeeTransfer = Gas{ {Asset: ETHAsset, Amount: ethTransferFee}, }
ETHGasFeeTransfer gas fee for ETH
var NoCoin = Coin{ Amount: cosmos.ZeroUint(), }
Functions ¶
func BlockHeight ¶
BlockHeight return the adjusted block height
func ConvertAndEncode ¶
ConvertAndEncode converts from a base64 encoded byte string to hex or base32 encoded byte string and then to bech32
func GetShare ¶
GetShare this method will panic if any of the input parameter can't be convert to cosmos.Dec which shouldn't happen
func RandStringBytesMask ¶
RandStringBytesMask generate random string used for test purpose
Types ¶
type Account ¶
type Account struct { Sequence int64 AccountNumber int64 Coins AccountCoins HasMemoFlag bool }
func NewAccount ¶
func NewAccount(sequence, accountNumber int64, coins AccountCoins, hasMemoFlag bool) Account
NewAccount
type AccountCoin ¶
type AccountCoins ¶
type AccountCoins []AccountCoin
func GetCoins ¶
func GetCoins(accCoins []types.Coin) AccountCoins
GetCoins transforms from binance coins
type Address ¶
type Address string
func NewAddress ¶
NewAddress create a new Address. Supports Binance, Bitcoin, and Ethereum
type Asset ¶
type Asset struct { Chain Chain `json:"chain"` Symbol Symbol `json:"symbol"` Ticker Ticker `json:"ticker"` }
Asset represent an asset in THORChain it is in BNB.BNB format for example BNB.RUNE-67C , BNB.RUNE-B1A
func RuneAsset ¶
func RuneAsset() Asset
RuneAsset return RUNE Asset depends on different environment
func (Asset) MarshalJSON ¶
MarshalJSON implement Marshaler interface
func (*Asset) UnmarshalJSON ¶
UnmarshalJSON implement Unmarshaler interface
type Chain ¶
type Chain string
Chain is an alias of string , represent a block chain
func (Chain) AddressPrefix ¶
func (c Chain) AddressPrefix(cn ChainNetwork) string
AddressPrefix return the address prefix used by the given network (testnet/mainnet)
func (Chain) GetSigningAlgo ¶
func (c Chain) GetSigningAlgo() keys.SigningAlgo
GetSigningAlgo get the signing algorithm for the given chain
type ChainNetwork ¶
type ChainNetwork uint8
ChainNetwork is to indicate which chain environment THORNode are working with
const ( // TestNet network for test TestNet ChainNetwork = iota // MainNet network for main net MainNet // MockNet network for main net MockNet )
func GetCurrentChainNetwork ¶
func GetCurrentChainNetwork() ChainNetwork
GetCurrentChainNetwork determinate what kind of network currently it is working with
type ChainPoolInfo ¶
type ChainPoolInfo struct { Chain Chain `json:"chain"` PubKey PubKey `json:"pub_key"` PoolAddress Address `json:"pool_address"` }
ChainPoolInfo represent the pool address specific for a chain
var EmptyChainPoolInfo ChainPoolInfo
EmptyChainPoolInfo everything is empty
func NewChainPoolInfo ¶
func NewChainPoolInfo(chain Chain, pubKey PubKey) (ChainPoolInfo, error)
NewChainPoolInfo create a new instance of ChainPoolInfo
func (ChainPoolInfo) IsEmpty ¶
func (cpi ChainPoolInfo) IsEmpty() bool
IsEmpty whether the struct is empty
type Chains ¶
type Chains []Chain
Chains represent a slice of Chain
type Coins ¶
type Coins []Coin
type Duration ¶
Duration embedded time.Duration so THORNode could use string to represent duration in json file for example ,1s ,1h , 5m etc
func (Duration) MarshalJSON ¶
MarshalJSON marshal the duration to json string
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON convert the json value back to time.Duration
type Gas ¶
type Gas Coins
Gas coins
func CalcBinanceGasPrice ¶
CalcBinanceGasPrice calculate gas price for Binance chain
func GetETHGasFee ¶
GetETHGasFee return the gas for ETH
func MakeETHGas ¶
MakeETHGas return the gas for ETH
func (Gas) Add ¶
Add combines two gas objects into one, adding amounts where needed or appending new coins.
func (Gas) Equals ¶
Equals Check if two lists of coins are equal to each other. Order does not matter
type PubKey ¶
type PubKey string
PubKey used in thorchain, it should be bech32 encoded string thus it will be something like tthorpub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcycgtrnv tthorpub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70k6zq8qe
var EmptyPubKey PubKey
EmptyPubKey
func NewPubKeyFromCrypto ¶
NewPubKeyFromCrypto
func (PubKey) GetAddress ¶
GetAddress will return an address for the given chain
func (PubKey) GetThorAddress ¶
func (pubKey PubKey) GetThorAddress() (cosmos.AccAddress, error)
func (PubKey) MarshalJSON ¶
MarshalJSON to Marshals to JSON using Bech32
func (*PubKey) UnmarshalJSON ¶
UnmarshalJSON to Unmarshal from JSON assuming Bech32 encoding
type PubKeySet ¶
PubKeySet contains two pub keys , secp256k1 and ed25519
var EmptyPubKeySet PubKeySet
EmptyPubKeySet
func NewPubKeySet ¶
NewPubKeySet create a new instance of PubKeySet , which contains two keys
func (PubKeySet) GetAddress ¶
GetAddress
type PubKeys ¶
type PubKeys []PubKey
PubKey used in thorchain, it should be bech32 encoded string thus it will be something like tthorpub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcycgtrnv tthorpub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70k6zq8qe
type Symbol ¶
type Symbol string
Symbol represent an asset
func (Symbol) IsMiniToken ¶
IsMiniToken is to determine whether it is a mini token on binance chain
type Ticker ¶
type Ticker string
Ticker The trading 'symbol' or shortened name (typically in capital letters) that refer to a coin on a trading platform. For example: BNB
func NewTicker ¶
NewTicker parse the given string as ticker, return error if it is not legitimate ticker
type Tx ¶
type Tx struct { ID TxID `json:"id"` Chain Chain `json:"chain"` FromAddress Address `json:"from_address"` ToAddress Address `json:"to_address"` Coins Coins `json:"coins"` Gas Gas `json:"gas"` Memo string `json:"memo"` }
Tx transaction
func GetRagnarokTx ¶
GetRagnarokTx return a tx used for ragnarok
func (Tx) ToAttributes ¶
ToAttributes push all the tx fields into a slice of cosmos Attribute(key value pairs)