Documentation ¶
Index ¶
- Constants
- Variables
- func ContainsAsset(asset Asset, assets []Asset) bool
- func ConvertAndEncode(hrp string, data []byte) (string, error)
- func CosmosPrivateKeyToTMPrivateKey(privateKey cryptotypes.PrivKey) crypto.PrivKey
- func Decrypt(data []byte, passphrase string) ([]byte, error)
- func Encrypt(data []byte, passphrase string) ([]byte, error)
- func GetSafeShare(part, total, allocation cosmos.Uint) cosmos.Uint
- func GetUncappedShare(part, total, allocation cosmos.Uint) (share cosmos.Uint)
- func RandHexString(n int) string
- func SafeSub(input1, input2 cosmos.Uint) cosmos.Uint
- func Sign(buf []byte) ([]byte, []byte, error)
- func SignBase64(buf []byte) (string, string, error)
- type Account
- type Address
- func (addr Address) AbbreviatedString(version semver.Version) string
- func (addr Address) AccAddress() (cosmos.AccAddress, error)
- func (addr Address) Equals(addr2 Address) bool
- func (addr Address) GetChain(version semver.Version) Chain
- func (addr Address) GetNetwork(version semver.Version, chain Chain) ChainNetwork
- func (addr Address) IsChain(chain Chain, version semver.Version) bool
- func (addr Address) IsChainV107(chain Chain) bool
- func (addr Address) IsChainV108(chain Chain) bool
- func (addr Address) IsChainV111(chain Chain) bool
- func (addr Address) IsEmpty() bool
- func (addr Address) IsNoop() bool
- func (addr Address) IsValidBCHAddress() bool
- func (addr Address) String() string
- type AddressSuite
- type Asset
- func (*Asset) Descriptor() ([]byte, []int)
- func (a Asset) Equals(a2 Asset) bool
- func (a Asset) GetChain() Chain
- func (a Asset) GetLayer1Asset() Asset
- func (a Asset) GetSyntheticAsset() Asset
- func (a Asset) IsBNB() bool
- func (a Asset) IsBase() bool
- func (a Asset) IsEmpty() bool
- func (a Asset) IsGasAsset() bool
- func (a Asset) IsNative() bool
- func (a Asset) IsNativeBase() bool
- func (a Asset) IsSyntheticAsset() bool
- func (a Asset) IsVaultAsset() bool
- func (m *Asset) Marshal() (dAtA []byte, err error)
- func (a Asset) MarshalJSON() ([]byte, error)
- func (a Asset) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error)
- func (m *Asset) MarshalTo(dAtA []byte) (int, error)
- func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (a Asset) MimirString() string
- func (a Asset) Native() string
- func (*Asset) ProtoMessage()
- func (m *Asset) Reset()
- func (a Asset) ShortCode() string
- func (m *Asset) Size() (n int)
- func (a Asset) String() string
- func (a Asset) TwoLetterShortCode() string
- func (m *Asset) Unmarshal(dAtA []byte) error
- func (a *Asset) UnmarshalJSON(data []byte) error
- func (a *Asset) UnmarshalJSONPB(unmarshal *jsonpb.Unmarshaler, content []byte) error
- func (a Asset) Valid() error
- func (m *Asset) XXX_DiscardUnknown()
- func (m *Asset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Asset) XXX_Merge(src proto.Message)
- func (m *Asset) XXX_Size() int
- func (m *Asset) XXX_Unmarshal(b []byte) error
- type Assets
- type Chain
- func (c Chain) AddressPrefix(cn ChainNetwork) string
- func (c Chain) ApproximateBlockMilliseconds() int64
- func (c Chain) DefaultCoinbase() float64
- func (c Chain) DustThreshold() cosmos.Uint
- func (c Chain) Equals(c2 Chain) bool
- func (c Chain) GetGasAsset() Asset
- func (c Chain) GetGasAssetDecimal() int64
- func (c Chain) GetGasUnits() string
- func (c Chain) GetSigningAlgo() SigningAlgo
- func (c Chain) InboundNotes() string
- func (c Chain) IsBASEChain() bool
- func (c Chain) IsBNB() bool
- func (c Chain) IsEVM() bool
- func (c Chain) IsEmpty() bool
- func (c Chain) IsValidAddress(addr Address) bool
- func (c Chain) MaxMemoLength() int
- func (c Chain) String() string
- func (c Chain) Valid() error
- func (c Chain) Validate() error
- type ChainNetwork
- type ChainPoolInfo
- type Chains
- type Coin
- func (*Coin) Descriptor() ([]byte, []int)
- func (c Coin) Equals(cc Coin) bool
- func (c Coin) IsEmpty() bool
- func (c Coin) IsNative() bool
- func (m *Coin) Marshal() (dAtA []byte, err error)
- func (m *Coin) MarshalTo(dAtA []byte) (int, error)
- func (m *Coin) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (c Coin) Native() (cosmos.Coin, error)
- func (*Coin) ProtoMessage()
- func (m *Coin) Reset()
- func (m *Coin) Size() (n int)
- func (c Coin) String() string
- func (m *Coin) Unmarshal(dAtA []byte) error
- func (c Coin) Valid() error
- func (c Coin) WithDecimals(decimal int64) Coin
- func (m *Coin) XXX_DiscardUnknown()
- func (m *Coin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Coin) XXX_Merge(src proto.Message)
- func (m *Coin) XXX_Size() int
- func (m *Coin) XXX_Unmarshal(b []byte) error
- type Coins
- func (cs Coins) Add(coin Coin) Coins
- func (cs Coins) Adds_deprecated(coins Coins) Coins
- func (cs Coins) Contains(c Coin) bool
- func (cs Coins) Copy() Coins
- func (cs Coins) Distinct() Coins
- func (cs Coins) Equals(cs2 Coins) bool
- func (cs Coins) EqualsEx(cs2 Coins) bool
- func (cs Coins) GetCoin(asset Asset) Coin
- func (cs Coins) HasNoneNativeRune() bool
- func (cs Coins) HasSynthetic() bool
- func (cs Coins) IsEmpty() bool
- func (cs Coins) Native() (cosmos.Coins, error)
- func (cs Coins) NoneEmpty() Coins
- func (cs Coins) SafeSub(coin Coin) Coins
- func (cs Coins) String() string
- func (cs Coins) Valid() error
- type Duration
- type Fee
- func (*Fee) Descriptor() ([]byte, []int)
- func (m *Fee) Marshal() (dAtA []byte, err error)
- func (m *Fee) MarshalTo(dAtA []byte) (int, error)
- func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Fee) ProtoMessage()
- func (m *Fee) Reset()
- func (m *Fee) Size() (n int)
- func (f Fee) String() string
- func (m *Fee) Unmarshal(dAtA []byte) error
- func (m *Fee) XXX_DiscardUnknown()
- func (m *Fee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Fee) XXX_Merge(src proto.Message)
- func (m *Fee) XXX_Size() int
- func (m *Fee) XXX_Unmarshal(b []byte) error
- type Gas
- type Invariant
- type InvariantRoute
- type NodeRelay
- type NodeRelayMsg
- type ProtoUint
- func (*ProtoUint) Descriptor() ([]byte, []int)
- func (m *ProtoUint) Marshal() (dAtA []byte, err error)
- func (m *ProtoUint) MarshalTo(dAtA []byte) (int, error)
- func (m *ProtoUint) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ProtoUint) ProtoMessage()
- func (m *ProtoUint) Reset()
- func (m *ProtoUint) Size() (n int)
- func (this *ProtoUint) String() string
- func (m *ProtoUint) Unmarshal(dAtA []byte) error
- func (m *ProtoUint) XXX_DiscardUnknown()
- func (m *ProtoUint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ProtoUint) XXX_Merge(src proto.Message)
- func (m *ProtoUint) XXX_Size() int
- func (m *ProtoUint) XXX_Unmarshal(b []byte) error
- type PubKey
- func (pubKey PubKey) EVMPubkeyToAddress() (Address, error)
- 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
- func (pks PubKeySet) Contains(pk PubKey) bool
- func (*PubKeySet) Descriptor() ([]byte, []int)
- func (pks PubKeySet) Equals(pks1 PubKeySet) bool
- func (pks PubKeySet) GetAddress(chain Chain) (Address, error)
- func (pks PubKeySet) IsEmpty() bool
- func (m *PubKeySet) Marshal() (dAtA []byte, err error)
- func (m *PubKeySet) MarshalTo(dAtA []byte) (int, error)
- func (m *PubKeySet) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PubKeySet) ProtoMessage()
- func (m *PubKeySet) Reset()
- func (m *PubKeySet) Size() (n int)
- func (pks PubKeySet) String() string
- func (m *PubKeySet) Unmarshal(dAtA []byte) error
- func (m *PubKeySet) XXX_DiscardUnknown()
- func (m *PubKeySet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PubKeySet) XXX_Merge(src proto.Message)
- func (m *PubKeySet) XXX_Size() int
- func (m *PubKeySet) XXX_Unmarshal(b []byte) error
- type PubKeys
- type SigningAlgo
- type Symbol
- type Ticker
- type Tickers
- type Tx
- func (*Tx) Descriptor() ([]byte, []int)
- func (tx Tx) Equals(tx2 Tx) bool
- func (tx Tx) EqualsEx(tx2 Tx) bool
- func (tx Tx) Hash() string
- func (tx Tx) IsEmpty() bool
- func (m *Tx) Marshal() (dAtA []byte, err error)
- func (m *Tx) MarshalTo(dAtA []byte) (int, error)
- func (m *Tx) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Tx) ProtoMessage()
- func (m *Tx) Reset()
- func (m *Tx) Size() (n int)
- func (tx Tx) String() string
- func (tx Tx) ToAttributes() []cosmos.Attribute
- func (m *Tx) Unmarshal(dAtA []byte) error
- func (tx Tx) Valid() error
- func (m *Tx) XXX_DiscardUnknown()
- func (m *Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Tx) XXX_Merge(src proto.Message)
- func (m *Tx) XXX_Size() int
- func (m *Tx) XXX_Unmarshal(b []byte) error
- type TxID
- type TxIDs
- type Txs
Constants ¶
const ( NoAddress = Address("") NoopAddress = Address("noop") EVMNullAddress = Address("0x0000000000000000000000000000000000000000") )
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("CACAO") )
const BASEChainDecimals = 8
BASEChainDecimals indicate the number of decimal points used in BASEChain
const CurrentChainNetwork = MainNet
const One = 100000000
One is useful type so THORNode doesn't need to manage 8 zeroes all the time
Variables ¶
var ( RadixAccountAddressPrefix = "account_rdx1" RadixPrefixAbbreviations = []string{"ardx1", "rdx1", "1"} )
var ( // EmptyAsset empty asset, not valid EmptyAsset = Asset{Chain: EmptyChain, Symbol: "", Ticker: "", Synth: false} // RUNEAsset RUNE RUNEAsset = Asset{Chain: THORChain, Symbol: "RUNE", Ticker: "RUNE", Synth: false} // ATOMAsset ATOM ATOMAsset = Asset{Chain: GAIAChain, Symbol: "ATOM", Ticker: "ATOM", Synth: false} // BNBAsset BNB BNBAsset = Asset{Chain: BNBChain, Symbol: "BNB", Ticker: "BNB", Synth: false} // BTCAsset BTC BTCAsset = Asset{Chain: BTCChain, Symbol: "BTC", Ticker: "BTC", Synth: false} // LTCAsset BTC LTCAsset = Asset{Chain: LTCChain, Symbol: "LTC", Ticker: "LTC", Synth: false} // BCHAsset BCH BCHAsset = Asset{Chain: BCHChain, Symbol: "BCH", Ticker: "BCH", Synth: false} // DASHAsset DASH DASHAsset = Asset{Chain: DASHChain, Symbol: "DASH", Ticker: "DASH", Synth: false} // DOGEAsset DOGE DOGEAsset = Asset{Chain: DOGEChain, Symbol: "DOGE", Ticker: "DOGE", Synth: false} // ETHAsset ETH ETHAsset = Asset{Chain: ETHChain, Symbol: "ETH", Ticker: "ETH", Synth: false} // USDTAsset ETH USDTAsset = Asset{Chain: ETHChain, Symbol: "USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7", Ticker: "USDT", Synth: false} USDTAssetV1 = Asset{Chain: ETHChain, Symbol: "USDT-0xdAC17F958D2ee523a2206206994597C13D831ec7", Ticker: "ETH", Synth: false} // USDCAsset ETH USDCAsset = Asset{Chain: ETHChain, Symbol: "USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", Ticker: "USDC", Synth: false} USDCAssetV1 = Asset{Chain: ETHChain, Symbol: "USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", Ticker: "ETH", Synth: false} // WSTETHAsset ETH WSTETHAsset = Asset{Chain: ETHChain, Symbol: "WSTETH-0X7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0", Ticker: "WSTETH", Synth: false} WSTETHAssetV1 = Asset{Chain: ETHChain, Symbol: "WSTETH-0X7F39C581F595B53C5CB19BD0B3F8DA6C935E2CA0", Ticker: "ETH", Synth: false} // PEPEAsset ETH PEPEAsset = Asset{Chain: ETHChain, Symbol: "PEPE-0x25D887CE7A35172C62FEBFD67A1856F20FAEBB00", Ticker: "PEPE", Synth: false} // ETHAsset ARB AETHAsset = Asset{Chain: ARBChain, Symbol: "ETH", Ticker: "ETH", Synth: false} // USDTAsset ARB AUSDTAsset = Asset{Chain: ARBChain, Symbol: "USDT-0XFD086BC7CD5C481DCC9C85EBE478A1C0B69FCBB9", Ticker: "USDT", Synth: false} // USDCAsset ARB AUSDCAsset = Asset{Chain: ARBChain, Symbol: "USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831", Ticker: "USDC", Synth: false} // DAIAsset ARB ADAIAsset = Asset{Chain: ARBChain, Symbol: "DAI-0XDA10009CBD5D07DD0CECC66161FC93D7C9000DA1", Ticker: "DAI", Synth: false} // PEPEAsset ARB APEPEAsset = Asset{Chain: ARBChain, Symbol: "PEPE-0X25D887CE7A35172C62FEBFD67A1856F20FAEBB00", Ticker: "PEPE", Synth: false} // WSTETHAsset ARB AWSTETHAsset = Asset{Chain: ARBChain, Symbol: "WSTETH-0X5979D7B546E38E414F7E9822514BE443A4800529", Ticker: "WSTETH", Synth: false} // WBTCAsset ARB AWBTCAsset = Asset{Chain: ARBChain, Symbol: "WBTC-0X2F2A2543B76A4166549F7AAB2E75BEF0AEFC5B0F", Ticker: "WBTC", Synth: false} // ATGTAsset ARB ATGTAsset = Asset{Chain: ARBChain, Symbol: "TGT-0x429FED88F10285E61B12BDF00848315FBDFCC341", Ticker: "TGT", Synth: false} // KUJIAsset KUJI KUJIAsset = Asset{Chain: KUJIChain, Symbol: "KUJI", Ticker: "KUJI", Synth: false} // USKAsset KUJI USKAsset = Asset{Chain: KUJIChain, Symbol: "USK", Ticker: "KUJI", Synth: false} // AVAXAsset AVAX AVAXAsset = Asset{Chain: AVAXChain, Symbol: "AVAX", Ticker: "AVAX", Synth: false} // XRDAsset XRD XRDAsset = Asset{Chain: XRDChain, Symbol: "XRD", Ticker: "XRD", Synth: false} // BaseNative CACAO on mayachain BaseNative = Asset{Chain: BASEChain, Symbol: "CACAO", Ticker: "CACAO", Synth: false} MayaNative = Asset{Chain: BASEChain, Symbol: "MAYA", Ticker: "MAYA", Synth: false} )
var ( EmptyChain = Chain("") BNBChain = Chain("BNB") ETHChain = Chain("ETH") BTCChain = Chain("BTC") LTCChain = Chain("LTC") BCHChain = Chain("BCH") DASHChain = Chain("DASH") DOGEChain = Chain("DOGE") BASEChain = Chain("MAYA") AZTECChain = Chain("AZTEC") THORChain = Chain("THOR") GAIAChain = Chain("GAIA") AVAXChain = Chain("AVAX") KUJIChain = Chain("KUJI") ARBChain = Chain("ARB") XRDChain = Chain("XRD") SigningAlgoSecp256k1 = SigningAlgo("secp256k1") SigningAlgoEd25519 = SigningAlgo("ed25519") )
var ( ErrInvalidLengthCommon = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCommon = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupCommon = fmt.Errorf("proto: unexpected end of group") )
var AllChains = Chains{ ETHChain, BTCChain, DASHChain, BASEChain, THORChain, KUJIChain, ARBChain, XRDChain, }
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 LatestVersion semver.Version = semver.MustParse("999.0.0")
var NoCoin = Coin{ Asset: EmptyAsset, Amount: cosmos.ZeroUint(), }
NoCoin is empty Coin
Functions ¶
func ContainsAsset ¶ added in v1.104.1
GetAsset returns true if the asset exists in the list of assets
func ConvertAndEncode ¶
ConvertAndEncode converts from a base64 encoded byte string to hex or base32 encoded byte string and then to bech32
func CosmosPrivateKeyToTMPrivateKey ¶
func CosmosPrivateKeyToTMPrivateKey(privateKey cryptotypes.PrivKey) crypto.PrivKey
CosmosPrivateKeyToTMPrivateKey convert cosmos implementation of private key to tendermint private key
func GetSafeShare ¶
GetSafeShare does the same as GetUncappedShare , but GetSafeShare will guarantee the result will not more than total
func GetUncappedShare ¶
GetUncappedShare this method will panic if any of the input parameter can't be convert to cosmos.Dec which shouldn't happen
func RandHexString ¶ added in v1.110.0
RandHexString generates random hex string used for test purpose
func SafeSub ¶
SafeSub subtract input2 from input1, given cosmos.Uint can't be negative , otherwise it will panic thus in this method,when input2 is larger than input 1, it will just return cosmos.ZeroUint
Types ¶
type Address ¶
type Address string
func ConvertToNewBCHAddressFormatV83 ¶
ConvertToNewBCHAddressFormatV83 convert the given BCH to new address format
func NewAddressV1 ¶ added in v1.111.0
NewAddress create a new Address. Supports Binance, Bitcoin, and Ethereum
func NewAddressV111 ¶ added in v1.111.0
NewAddress create a new Address. Supports Binance, Bitcoin, and Ethereum
func (Address) AbbreviatedString ¶ added in v1.111.0
func (Address) AccAddress ¶
func (addr Address) AccAddress() (cosmos.AccAddress, error)
func (Address) GetNetwork ¶
func (addr Address) GetNetwork(version semver.Version, chain Chain) ChainNetwork
func (Address) IsChainV107 ¶ added in v1.108.0
func (Address) IsChainV108 ¶ added in v1.108.0
func (Address) IsChainV111 ¶ added in v1.111.0
func (Address) IsValidBCHAddress ¶
IsValidBCHAddress determinate whether the address is a valid new BCH address format
type AddressSuite ¶ added in v1.110.0
type AddressSuite struct{}
func (*AddressSuite) TestAddress ¶ added in v1.110.0
func (s *AddressSuite) TestAddress(c *C)
type Asset ¶ added in v1.110.0
type Asset struct { Chain Chain `protobuf:"bytes,1,opt,name=chain,proto3,casttype=Chain" json:"chain,omitempty"` Symbol Symbol `protobuf:"bytes,2,opt,name=symbol,proto3,casttype=Symbol" json:"symbol,omitempty"` Ticker Ticker `protobuf:"bytes,3,opt,name=ticker,proto3,casttype=Ticker" json:"ticker,omitempty"` Synth bool `protobuf:"varint,4,opt,name=synth,proto3" json:"synth,omitempty"` }
func BaseAsset ¶ added in v1.110.0
func BaseAsset() Asset
BaseAsset return RUNE Asset depends on different environment
func NewAssetWithShortCodes ¶ added in v1.110.0
func NewAssetWithShortCodesV110 ¶ added in v1.110.0
func NewAssetWithShortCodesV111 ¶ added in v1.111.0
func (*Asset) Descriptor ¶ added in v1.110.0
func (Asset) GetLayer1Asset ¶ added in v1.110.0
Get layer1 asset version
func (Asset) GetSyntheticAsset ¶ added in v1.110.0
Get synthetic asset of asset
func (Asset) IsBNB ¶ added in v1.110.0
IsBNB is a helper function, return true only when the asset represent BNB
func (Asset) IsBase ¶ added in v1.110.0
IsCacao is a helper function ,return true only when the asset represent RUNE
func (Asset) IsEmpty ¶ added in v1.110.0
IsEmpty will be true when any of the field is empty, chain,symbol or ticker
func (Asset) IsGasAsset ¶ added in v1.110.0
IsGasAsset check whether asset is base asset used to pay for gas
func (Asset) IsNative ¶ added in v1.110.0
IsNative is a helper function, returns true when the asset is a native asset to THORChain (ie rune, a synth, etc)
func (Asset) IsNativeBase ¶ added in v1.110.0
IsNativeRune is a helper function, return true only when the asset represent NATIVE RUNE
func (Asset) IsSyntheticAsset ¶ added in v1.110.0
Check if asset is a pegged asset
func (Asset) IsVaultAsset ¶ added in v1.110.0
func (Asset) MarshalJSON ¶ added in v1.110.0
MarshalJSON implement Marshaler interface
func (Asset) MarshalJSONPB ¶ added in v1.110.0
MarshalJSONPB implement jsonpb.Marshaler
func (*Asset) MarshalToSizedBuffer ¶ added in v1.110.0
func (Asset) MimirString ¶ added in v1.110.0
Replace pool name "." with a "-" for Mimir key checking.
func (*Asset) ProtoMessage ¶ added in v1.110.0
func (*Asset) ProtoMessage()
func (Asset) String ¶ added in v1.110.0
String implement fmt.Stringer , return the string representation of Asset
func (Asset) TwoLetterShortCode ¶ added in v1.110.0
ShortCode returns the short code for the asset.
func (*Asset) UnmarshalJSON ¶ added in v1.110.0
UnmarshalJSON implement Unmarshaler interface
func (*Asset) UnmarshalJSONPB ¶ added in v1.110.0
func (a *Asset) UnmarshalJSONPB(unmarshal *jsonpb.Unmarshaler, content []byte) error
UnmarshalJSONPB implement jsonpb.Unmarshaler
func (*Asset) XXX_DiscardUnknown ¶ added in v1.110.0
func (m *Asset) XXX_DiscardUnknown()
func (*Asset) XXX_Marshal ¶ added in v1.110.0
func (*Asset) XXX_Unmarshal ¶ added in v1.110.0
type Chain ¶
type Chain string
func ChainsThatCanBundleMultipleBlocks ¶ added in v1.111.0
func ChainsThatCanBundleMultipleBlocks() []Chain
ChainsThatCanBundleMultipleBlocks Returns a list of chains for which bifrost observer is allowed to bundle transactions from multiple blocks in a single TxIn. These are the chains with a very short block time (e.g. shorter than `MayachainBlockTime`).
func GetEVMChains ¶
func GetEVMChains() []Chain
GetEVMChains returns all "EVM" chains connected to THORChain "EVM" is defined, in thornode's context, as a chain that: - uses 0x as an address prefix - has a "Router" Smart Contract
func (Chain) AddressPrefix ¶
func (c Chain) AddressPrefix(cn ChainNetwork) string
AddressPrefix return the address prefix used by the given network (testnet/mainnet)
func (Chain) ApproximateBlockMilliseconds ¶ added in v1.102.0
func (Chain) DefaultCoinbase ¶ added in v1.102.0
DefaultCoinbase returns the default coinbase address for each chain, returns 0 if no coinbase emission is used. This is used used at the time of writing as a fallback value in Bifrost, and for inbound confirmation count estimates in the quote APIs.
func (Chain) DustThreshold ¶
DustThreshold returns the min dust threshold for each chain The min dust threshold defines the lower end of the withdraw range of memoless savers txs The native coin value provided in a memoless tx defines a basis points amount of Withdraw or Add to a savers position as follows: Withdraw range: (dust_threshold + 1) -> (dust_threshold + 10_000) Add range: dust_threshold -> Inf NOTE: these should all be in 8 decimal places
func (Chain) GetGasAssetDecimal ¶
GetGasAssetDecimal for the gas asset of given chain , what kind of precision it is using BASEChain is using 1E8, if an external chain's gas asset is larger than 1E8, just return cosmos.DefaultCoinDecimals
func (Chain) GetGasUnits ¶ added in v1.106.0
GetGasUnits returns name of the gas unit for each chain
func (Chain) GetSigningAlgo ¶
func (c Chain) GetSigningAlgo() SigningAlgo
GetSigningAlgo get the signing algorithm for the given chain
func (Chain) InboundNotes ¶ added in v1.104.0
func (Chain) IsBASEChain ¶
func (Chain) IsEVM ¶
IsEVM returns true if given chain is an EVM chain. See working definition of an "EVM" chain in the `GetEVMChains` function description
func (Chain) IsValidAddress ¶
IsValidAddress make sure the address is correct for the chain And this also make sure testnet doesn't use mainnet address vice versa
func (Chain) MaxMemoLength ¶ added in v1.102.0
MaxMemoLength returns the max memo length for each chain. Returns 0 if no max is configured.
type ChainNetwork ¶
type ChainNetwork uint8
ChainNetwork is to indicate which chain environment THORNode are working with
const ( // TestNet network for test - DO NOT USE // TODO: remove on hard fork TestNet ChainNetwork = iota // MainNet network for mainnet MainNet // MockNet network for mocknet MockNet // Stagenet network for stagenet StageNet )
func (ChainNetwork) SoftEquals ¶
func (net ChainNetwork) SoftEquals(net2 ChainNetwork) bool
Soft Equals check is mainnet == mainet, or mocknet == mocknet
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 Coin ¶ added in v1.110.0
type Coin struct { Asset Asset `protobuf:"bytes,1,opt,name=asset,proto3" json:"asset"` Amount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"amount"` Decimals int64 `protobuf:"varint,3,opt,name=decimals,proto3" json:"decimals,omitempty"` }
func (*Coin) Descriptor ¶ added in v1.110.0
func (Coin) Equals ¶ added in v1.110.0
Equals compare two coins to see whether they represent the same information
func (Coin) IsEmpty ¶ added in v1.110.0
IsEmpty check whether asset is empty and also amount is zero
func (*Coin) MarshalToSizedBuffer ¶ added in v1.110.0
func (*Coin) ProtoMessage ¶ added in v1.110.0
func (*Coin) ProtoMessage()
func (Coin) WithDecimals ¶ added in v1.110.0
WithDecimals update coin with a decimal
func (*Coin) XXX_DiscardUnknown ¶ added in v1.110.0
func (m *Coin) XXX_DiscardUnknown()
func (*Coin) XXX_Marshal ¶ added in v1.110.0
func (*Coin) XXX_Unmarshal ¶ added in v1.110.0
type Coins ¶
type Coins []Coin
Coins represent a slice of Coin
func (Coins) Adds_deprecated ¶ added in v1.110.0
This overwrites cs by changing its slice-referenced values, so it is recommended to use destination := make(Coins, len(source)) and copy(destination, source) first.
func (Coins) Equals ¶
Equals Check if two lists of coins are equal to each other. Order does not matter This method has side effect because it uses sort.Slice on the input parameter which will potentially change the order of cs1 & cs2 Note: quite a few places already using this method , which can't be changed, otherwise it will cause consensus failure on CHAOSNET Deprecated
func (Coins) EqualsEx ¶
EqualsEx Check if two lists of coins are equal to each other. This method will make a copy of cs1 & cs2 , thus the original coins order will not be changed
func (Coins) GetCoin ¶
GetCoin gets a specific coin by asset. Assumes there is only one of this coin in the list.
func (Coins) HasNoneNativeRune ¶
HasNoneNativeRune check whether the coins contains NoneNativeRUNE
At the moment, there are BEP2 RUNE, ERC20 RUNE and Native RUNE
func (Coins) HasSynthetic ¶
HasSynthetic check whether the coins contains synth 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 Fee ¶ added in v1.110.0
type Fee struct { Coins Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=Coins" json:"coins"` PoolDeduct github_com_cosmos_cosmos_sdk_types.Uint `` /* 132-byte string literal not displayed */ }
func (*Fee) Descriptor ¶ added in v1.110.0
func (*Fee) MarshalToSizedBuffer ¶ added in v1.110.0
func (*Fee) ProtoMessage ¶ added in v1.110.0
func (*Fee) ProtoMessage()
func (*Fee) XXX_DiscardUnknown ¶ added in v1.110.0
func (m *Fee) XXX_DiscardUnknown()
func (*Fee) XXX_Marshal ¶ added in v1.110.0
func (*Fee) XXX_Unmarshal ¶ added in v1.110.0
type Gas ¶
type Gas Coins
Gas coins
func CalcBinanceGasPrice ¶
CalcBinanceGasPrice calculate gas price for Binance chain
func GetEVMGasFee ¶ added in v1.109.0
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
func (Gas) NoneEmpty ¶ added in v1.104.0
NoneEmpty returns a new Gas which ignores any coin which is empty either Coin asset is empty or amount is empty
type Invariant ¶ added in v1.110.0
An Invariant is a function which tests a particular invariant. The invariant returns a descriptive message about what happened and a boolean indicating whether the invariant has been broken.
type InvariantRoute ¶ added in v1.110.0
invariant route
func NewInvariantRoute ¶ added in v1.110.0
func NewInvariantRoute(route string, invariant Invariant) InvariantRoute
NewInvariantRoute - create an InvariantRoute object
type NodeRelay ¶
type NodeRelay struct { Msg NodeRelayMsg `json:"msg"` Signature string `json:"signature"` PubKey string `json:"pubkey"` }
func NewNodeRelay ¶
type NodeRelayMsg ¶
type ProtoUint ¶ added in v1.110.0
type ProtoUint struct {
Value github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,1,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"value"`
}
func (*ProtoUint) Descriptor ¶ added in v1.110.0
func (*ProtoUint) MarshalToSizedBuffer ¶ added in v1.110.0
func (*ProtoUint) ProtoMessage ¶ added in v1.110.0
func (*ProtoUint) ProtoMessage()
func (*ProtoUint) XXX_DiscardUnknown ¶ added in v1.110.0
func (m *ProtoUint) XXX_DiscardUnknown()
func (*ProtoUint) XXX_Marshal ¶ added in v1.110.0
func (*ProtoUint) XXX_Unmarshal ¶ added in v1.110.0
type PubKey ¶
type PubKey string
PubKey used in thorchain, it should be bech32 encoded string thus it will be something like tmayapub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcy7cau6l tmayapub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70kujkcf2
var EmptyPubKey PubKey
func NewPubKeyFromCrypto ¶
NewPubKeyFromCrypto
func (PubKey) EVMPubkeyToAddress ¶
EVMPubkeyToAddress converts a pubkey of an EVM chain to the corresponding address
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 ¶ added in v1.110.0
type PubKeySet struct { Secp256k1 PubKey `protobuf:"bytes,1,opt,name=secp256k1,proto3,casttype=PubKey" json:"secp256k1,omitempty"` Ed25519 PubKey `protobuf:"bytes,2,opt,name=ed25519,proto3,casttype=PubKey" json:"ed25519,omitempty"` }
PubKeySet contains two pub keys , secp256k1 and ed25519
var EmptyPubKeySet PubKeySet
func NewPubKeySet ¶ added in v1.110.0
NewPubKeySet create a new instance of PubKeySet , which contains two keys
func (*PubKeySet) Descriptor ¶ added in v1.110.0
func (PubKeySet) GetAddress ¶ added in v1.110.0
GetAddress
func (*PubKeySet) MarshalToSizedBuffer ¶ added in v1.110.0
func (*PubKeySet) ProtoMessage ¶ added in v1.110.0
func (*PubKeySet) ProtoMessage()
func (*PubKeySet) XXX_DiscardUnknown ¶ added in v1.110.0
func (m *PubKeySet) XXX_DiscardUnknown()
func (*PubKeySet) XXX_Marshal ¶ added in v1.110.0
func (*PubKeySet) XXX_Unmarshal ¶ added in v1.110.0
type PubKeys ¶
type PubKeys []PubKey
PubKey used in thorchain, it should be bech32 encoded string thus it will be something like tmayapub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcy7cau6l tmayapub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70kujkcf2
type SigningAlgo ¶
type SigningAlgo string
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 ¶ added in v1.110.0
type Tx struct { ID TxID `protobuf:"bytes,1,opt,name=id,proto3,casttype=TxID" json:"id,omitempty"` Chain Chain `protobuf:"bytes,2,opt,name=chain,proto3,casttype=Chain" json:"chain,omitempty"` FromAddress Address `protobuf:"bytes,3,opt,name=from_address,json=fromAddress,proto3,casttype=Address" json:"from_address,omitempty"` ToAddress Address `protobuf:"bytes,4,opt,name=to_address,json=toAddress,proto3,casttype=Address" json:"to_address,omitempty"` Coins Coins `protobuf:"bytes,5,rep,name=coins,proto3,castrepeated=Coins" json:"coins"` Gas Gas `protobuf:"bytes,6,rep,name=gas,proto3,castrepeated=Gas" json:"gas"` Memo string `protobuf:"bytes,7,opt,name=memo,proto3" json:"memo,omitempty"` }
func GetRagnarokTx ¶ added in v1.110.0
GetRagnarokTx return a tx used for ragnarok
func (*Tx) Descriptor ¶ added in v1.110.0
func (Tx) Equals ¶ added in v1.110.0
Equals compare two Tx to see whether they represent the same Tx Note: 1) this method has a side effect , it is using coins.Equals to compare coins , which potentially will change the order of coins in tx & tx2 2) for the places that are already using Equals , it can't be changed, continue to use Equals otherwise it will cause consensus failure on CHAOSNET Deprecated
func (Tx) EqualsEx ¶ added in v1.110.0
EqualsEx compare two Tx to see whether they represent the same Tx This method will not change the original tx & tx2
func (Tx) Hash ¶ added in v1.110.0
Hash calculate a hash based on from address, coins and to address
func (*Tx) MarshalToSizedBuffer ¶ added in v1.110.0
func (*Tx) ProtoMessage ¶ added in v1.110.0
func (*Tx) ProtoMessage()
func (Tx) String ¶ added in v1.110.0
String implement fmt.Stringer return a string representation of the tx
func (Tx) ToAttributes ¶ added in v1.110.0
ToAttributes push all the tx fields into a slice of cosmos Attribute(key value pairs)
func (Tx) Valid ¶ added in v1.110.0
Valid do some data sanity check , if the tx contains invalid information it will return an none nil error
func (*Tx) XXX_DiscardUnknown ¶ added in v1.110.0
func (m *Tx) XXX_DiscardUnknown()
func (*Tx) XXX_Marshal ¶ added in v1.110.0
func (*Tx) XXX_Unmarshal ¶ added in v1.110.0
Source Files ¶
- account.go
- address.go
- address_archive.go
- address_test_mainnet.go
- asset.go
- chain.go
- chain_network.go
- chain_network_mainnet.go
- coin.go
- common.go
- common.pb.go
- duration.go
- encryption.go
- fee.go
- gas.go
- invariant.go
- node-relay.go
- pubkey.go
- random_string.go
- sign.go
- symbol.go
- ticker.go
- tx.go
- type_chain_pool_addr.go
- type_convert.go