Documentation ¶
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func DefaultCoinDenomRegex() string
- func Encode(b []byte) string
- func FromHex(s string) []byte
- func GetBaseDenom() (string, error)
- func GetDenomUnit(denom string) (sdktypes.Dec, bool)
- func Hex2Bytes(str string) []byte
- func IsHexAddress(s string) bool
- func RegisterDenom(denom string, unit sdktypes.Dec) error
- func SetCoinDenomRegex(reFn func() string)
- func ValidateDenom(denom string) error
- func VerifyP2pAddrBytes(p2pPubkey []byte, p2pAddr string) bool
- func VerifyP2pSignBytes(p2pPubkey []byte, signature []byte, message []byte) bool
- func VerifyP2pSignString(p2pPubkey []byte, signature []byte, message string) bool
- func VerifyWalletAddr(walletPubkey, walletAddr string) int
- func VerifyWalletAddrBytes(walletPubkey []byte, walletAddr string) int
- func VerifyWalletSign(walletPubkey, signature, message string) bool
- func VerifyWalletSignBytes(walletPubkey []byte, signature []byte, message string) bool
- type AccPrivKey
- type AccPubKey
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (a Address) Compare(b Address) int
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) P2pAddressToBech() (string, error)
- func (a Address) P2pPublicKeyToBech() (string, error)
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a Address) ToBech(hrp string) (string, error)
- func (a Address) WalletAddressToBech() (string, error)
- type Coin
- func (coin Coin) Add(coinB Coin) Coin
- func (coin Coin) AddAmount(amount sdktypes.Int) Coin
- func (coin Coin) IsEqual(other Coin) bool
- func (coin Coin) IsGTE(other Coin) bool
- func (coin Coin) IsLT(other Coin) bool
- func (coin Coin) IsNegative() bool
- func (coin Coin) IsNil() bool
- func (coin Coin) IsPositive() bool
- func (coin Coin) IsValid() bool
- func (coin Coin) IsZero() bool
- func (coin Coin) String() string
- func (coin Coin) Sub(coinB Coin) Coin
- func (coin Coin) SubAmount(amount sdktypes.Int) Coin
- func (coin Coin) Validate() error
- type Coins
- func (coins Coins) Add(coinsB ...Coin) Coins
- func (coins Coins) AmountOf(denom string) sdktypes.Int
- func (coins Coins) AmountOfNoDenomValidation(denom string) sdktypes.Int
- func (coins Coins) DenomsSubsetOf(coinsB Coins) bool
- func (coins Coins) Empty() bool
- func (coins Coins) GetDenomByIndex(i int) string
- func (coins Coins) IsAllGT(coinsB Coins) bool
- func (coins Coins) IsAllGTE(coinsB Coins) bool
- func (coins Coins) IsAllLT(coinsB Coins) bool
- func (coins Coins) IsAllLTE(coinsB Coins) bool
- func (coins Coins) IsAllPositive() bool
- func (coins Coins) IsAnyGT(coinsB Coins) bool
- func (coins Coins) IsAnyGTE(coinsB Coins) bool
- func (coins Coins) IsAnyNegative() bool
- func (coins Coins) IsAnyNil() bool
- func (coins Coins) IsEqual(coinsB Coins) bool
- func (coins Coins) IsValid() bool
- func (coins Coins) IsZero() bool
- func (coins Coins) Len() int
- func (coins Coins) Less(i, j int) bool
- func (coins Coins) MarshalJSON() ([]byte, error)
- func (coins Coins) Max(coinsB Coins) Coins
- func (coins Coins) Min(coinsB Coins) Coins
- func (coins Coins) SafeSub(coinsB Coins) (Coins, bool)
- func (coins Coins) Sort() Coins
- func (coins Coins) String() string
- func (coins Coins) Sub(coinsB Coins) Coins
- func (coins Coins) Swap(i, j int)
- func (coins Coins) Validate() error
- type DecCoin
- func ConvertDecCoin(coin DecCoin, denom string) (DecCoin, error)
- func NewDecCoin(denom string, amount sdktypes.Int) DecCoin
- func NewDecCoinFromCoin(coin Coin) DecCoin
- func NewDecCoinFromDec(denom string, amount sdktypes.Dec) DecCoin
- func NewInt64DecCoin(denom string, amount int64) DecCoin
- func NormalizeDecCoin(coin DecCoin) DecCoin
- func ParseDecCoin(coinStr string) (coin DecCoin, err error)
- func (coin DecCoin) Add(coinB DecCoin) DecCoin
- func (coin DecCoin) IsEqual(other DecCoin) bool
- func (coin DecCoin) IsGTE(other DecCoin) bool
- func (coin DecCoin) IsLT(other DecCoin) bool
- func (coin DecCoin) IsNegative() bool
- func (coin DecCoin) IsPositive() bool
- func (coin DecCoin) IsValid() bool
- func (coin DecCoin) IsZero() bool
- func (coin DecCoin) String() string
- func (coin DecCoin) Sub(coinB DecCoin) DecCoin
- func (coin DecCoin) TruncateDecimal() (Coin, DecCoin)
- func (coin DecCoin) Validate() error
- type DecCoins
- func (coins DecCoins) Add(coinsB ...DecCoin) DecCoins
- func (coins DecCoins) AmountOf(denom string) sdktypes.Dec
- func (coins DecCoins) Empty() bool
- func (coins DecCoins) GetDenomByIndex(i int) string
- func (coins DecCoins) Intersect(coinsB DecCoins) DecCoins
- func (coins DecCoins) IsAllPositive() bool
- func (coins DecCoins) IsAnyNegative() bool
- func (coins DecCoins) IsEqual(coinsB DecCoins) bool
- func (coins DecCoins) IsValid() bool
- func (coins DecCoins) IsZero() bool
- func (coins DecCoins) Len() int
- func (coins DecCoins) Less(i, j int) bool
- func (coins DecCoins) MulDec(d sdktypes.Dec) DecCoins
- func (coins DecCoins) MulDecTruncate(d sdktypes.Dec) DecCoins
- func (coins DecCoins) QuoDec(d sdktypes.Dec) DecCoins
- func (coins DecCoins) QuoDecTruncate(d sdktypes.Dec) DecCoins
- func (coins DecCoins) SafeSub(coinsB DecCoins) (DecCoins, bool)
- func (coins DecCoins) Sort() DecCoins
- func (coins DecCoins) String() string
- func (coins DecCoins) Sub(coinsB DecCoins) DecCoins
- func (coins DecCoins) Swap(i, j int)
- func (coins DecCoins) TruncateDecimal() (truncatedCoins Coins, changeCoins DecCoins)
- func (coins DecCoins) Validate() error
- type Hash
- type NetworkID
- type P2pPrivKey
- type P2pPubKey
- type TxFee
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength AddressLength = 20 // AccPublicKeyLength AccPublicKeyLength = 33 // AccPrivateKeyLength AccPrivateKeyLength = 32 // P2pPublicKeyLength P2pPublicKeyLength = 32 // P2pPrivateKeyLength P2pPrivateKeyLength = 64 P2pAddressBech32Length = 44 P2pSignatureLength = 64 )
Lengths of hashes and addresses in bytes.
const ( Stos = "stos" Gwei = "gwei" Wei = "wei" // WeiDenomUnit defines the base denomination unit for stos. // 1 stos = 1x10^{WeiDenomUnit} wei WeiDenomUnit = 18 GweiDenomUnit = 9 )
const NetworkIDPrefix = "snode:"
Variables ¶
This section is empty.
Functions ¶
func DefaultCoinDenomRegex ¶ added in v0.9.0
func DefaultCoinDenomRegex() string
DefaultCoinDenomRegex returns the default regex string
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GetBaseDenom ¶ added in v0.9.0
GetBaseDenom returns the denom of smallest unit registered
func GetDenomUnit ¶ added in v0.9.0
GetDenomUnit returns a unit for a given denomination if it exists. A boolean is returned if the denomination is registered.
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.
func RegisterDenom ¶ added in v0.9.0
RegisterDenom registers a denomination with a corresponding unit. If the denomination is already registered, an error will be returned.
func SetCoinDenomRegex ¶ added in v0.9.0
func SetCoinDenomRegex(reFn func() string)
SetCoinDenomRegex allows for coin's custom validation by overriding the regular expression string used for denom validation.
func ValidateDenom ¶ added in v0.9.0
ValidateDenom is the default validation function for Coin.Denom.
func VerifyP2pAddrBytes ¶ added in v0.9.0
VerifyP2pAddrBytes verify whether P2P address matches public key
func VerifyP2pSignBytes ¶ added in v0.9.0
VerifyP2pSignBytes verify the signature made by P2P key
func VerifyP2pSignString ¶ added in v0.10.0
VerifyP2pSignString verify the signature made by P2P key
func VerifyWalletAddr ¶ added in v0.9.0
VerifyWalletAddr verify the wallet address and public key match
func VerifyWalletAddrBytes ¶ added in v0.9.0
VerifyWalletAddrBytes []byte version of VerifyWalletKey() for the pubkey format
func VerifyWalletSign ¶ added in v0.9.0
VerifyWalletSign verify the signature by wallet key
Types ¶
type AccPrivKey ¶ added in v0.9.0
type AccPrivKey [AccPrivateKeyLength]byte
AccPrivKey account(wallet) private key
func BytesToAccPriveKey ¶ added in v0.9.0
func BytesToAccPriveKey(b []byte) AccPrivKey
BytesToAccPriveKey sets b to PrivKey. If b is larger than len(h), b will be cropped from the left.
func (AccPrivKey) Bytes ¶ added in v0.9.0
func (p AccPrivKey) Bytes() []byte
Bytes gets the byte representation of the underlying hash.
func (AccPrivKey) PubKeyFromPrivKey ¶ added in v0.9.0
func (p AccPrivKey) PubKeyFromPrivKey() AccPubKey
PubKeyFromPrivKey generate a AccPubKey from the AccPrivKey
func (*AccPrivKey) SetBytes ¶ added in v0.9.0
func (p *AccPrivKey) SetBytes(b []byte)
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
type AccPubKey ¶ added in v0.9.0
type AccPubKey [AccPublicKeyLength]byte
AccPubKey account(wallet) public key
func BytesToAccPubKey ¶ added in v0.9.0
BytesToPubKey sets b to PubKey. If b is larger than len(h), b will be cropped from the left.
func WalletPubkeyFromBech ¶ added in v0.9.0
WalletPubkeyFromBech create an AccPubKey from Bech of wallet pubkey
func (AccPubKey) Address ¶ added in v0.9.0
Address generate a wallet address from account public key
type Address ¶
type Address [AddressLength]byte
Address
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func P2pAddressFromBech ¶ added in v0.5.0
func WalletAddressFromBech ¶ added in v0.6.0
func (Address) P2pAddressToBech ¶ added in v0.8.0
func (Address) P2pPublicKeyToBech ¶ added in v0.9.0
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (Address) WalletAddressToBech ¶ added in v0.8.0
type Coin ¶ added in v0.9.0
func ConvertCoin ¶ added in v0.9.0
ConvertCoin attempts to convert a coin to a given denomination. If the given denomination is invalid or if neither denomination is registered, an error is returned.
func NewCoin ¶ added in v0.9.0
NewCoin returns a new coin with a denomination and amount. It will panic if the amount is negative or if the denomination is invalid.
func NewInt64Coin ¶ added in v0.9.0
NewInt64Coin returns a new coin with a denomination and amount. It will panic if the amount is negative.
func NormalizeCoin ¶ added in v0.9.0
NormalizeCoin try to convert a coin to the smallest unit registered, returns original one if failed.
func ParseCoinNormalized ¶ added in v0.9.0
ParseCoinNormalized parses and normalize a cli input for one coin type, returning errors if invalid or on an empty string as well. Expected format: "{amount}{denomination}"
func (Coin) Add ¶ added in v0.9.0
Add adds amounts of two coins with same denom. If the coins differ in denom then it panics.
func (Coin) IsEqual ¶ added in v0.9.0
IsEqual returns true if the two sets of Coins have the same value
func (Coin) IsGTE ¶ added in v0.9.0
IsGTE returns true if they are the same type and the receiver is an equal or greater value
func (Coin) IsLT ¶ added in v0.9.0
IsLT returns true if they are the same type and the receiver is a smaller value
func (Coin) IsNegative ¶ added in v0.9.0
IsNegative returns true if the coin amount is negative and false otherwise.
TODO: Remove once unsigned integers are used.
func (Coin) IsNil ¶ added in v0.9.0
IsNil returns true if the coin amount is nil and false otherwise.
func (Coin) IsPositive ¶ added in v0.9.0
IsPositive returns true if coin amount is positive.
TODO: Remove once unsigned integers are used.
func (Coin) IsValid ¶ added in v0.9.0
IsValid returns true if the Coin has a non-negative amount and the denom is valid.
func (Coin) Sub ¶ added in v0.9.0
Sub subtracts amounts of two coins with same denom. If the coins differ in denom then it panics.
type Coins ¶ added in v0.9.0
type Coins []Coin
Coins is a set of Coin, one per currency
func NewCoins ¶ added in v0.9.0
NewCoins constructs a new coin set. The provided coins will be sanitized by removing zero coins and sorting the coin set. A panic will occur if the coin set is not valid.
func NormalizeCoins ¶ added in v0.9.0
NormalizeCoins normalize and truncate a list of decimal coins
func ParseCoinsNormalized ¶ added in v0.9.0
ParseCoinsNormalized will parse out a list of coins separated by commas, and normalize them by converting to the smallest unit. If the parsing is successful, the provided coins will be sanitized by removing zero coins and sorting the coin set. Lastly a validation of the coin set is executed. If the check passes, ParseCoinsNormalized will return the sanitized coins. Otherwise, it will return an error. If an empty string is provided to ParseCoinsNormalized, it returns nil Coins. ParseCoinsNormalized supports decimal coins as inputs, and truncate them to int after converted to the smallest unit. Expected format: "{amount0}{denomination},...,{amountN}{denominationN}"
func (Coins) Add ¶ added in v0.9.0
Add adds two sets of coins.
e.g. {2A} + {A, 2B} = {3A, 2B} {2A} + {0B} = {2A}
NOTE: Add operates under the invariant that coins are sorted by denominations.
CONTRACT: Add will never return Coins where one Coin has a non-positive amount. In otherwords, IsValid will always return true. The function panics if `coins` or `coinsB` are not sorted (ascending).
func (Coins) AmountOfNoDenomValidation ¶ added in v0.9.0
AmountOfNoDenomValidation returns the amount of a denom from coins without validating the denomination.
func (Coins) DenomsSubsetOf ¶ added in v0.9.0
DenomsSubsetOf returns true if receiver's denom set is subset of coinsB's denoms.
func (Coins) GetDenomByIndex ¶ added in v0.9.0
GetDenomByIndex returns the Denom of the certain coin to make the findDup generic
func (Coins) IsAllGT ¶ added in v0.9.0
IsAllGT returns true if for every denom in coinsB, the denom is present at a greater amount in coins.
func (Coins) IsAllGTE ¶ added in v0.9.0
IsAllGTE returns false if for any denom in coinsB, the denom is present at a smaller amount in coins; else returns true.
func (Coins) IsAllLT ¶ added in v0.9.0
IsAllLT returns True iff for every denom in coins, the denom is present at a smaller amount in coinsB.
func (Coins) IsAllLTE ¶ added in v0.9.0
IsAllLTE returns true iff for every denom in coins, the denom is present at a smaller or equal amount in coinsB.
func (Coins) IsAllPositive ¶ added in v0.9.0
IsAllPositive returns true if there is at least one coin and all currencies have a positive value.
func (Coins) IsAnyGT ¶ added in v0.9.0
IsAnyGT returns true iff for any denom in coins, the denom is present at a greater amount in coinsB.
e.g. {2A, 3B}.IsAnyGT{A} = true {2A, 3B}.IsAnyGT{5C} = false {}.IsAnyGT{5C} = false {2A, 3B}.IsAnyGT{} = false
func (Coins) IsAnyGTE ¶ added in v0.9.0
IsAnyGTE returns true iff coins contains at least one denom that is present at a greater or equal amount in coinsB; it returns false otherwise.
NOTE: IsAnyGTE operates under the invariant that both coin sets are sorted by denominations and there exists no zero coins.
func (Coins) IsAnyNegative ¶ added in v0.9.0
IsAnyNegative returns true if there is at least one coin whose amount is negative; returns false otherwise. It returns false if the coin set is empty too.
TODO: Remove once unsigned integers are used.
func (Coins) IsAnyNil ¶ added in v0.9.0
IsAnyNil returns true if there is at least one coin whose amount is nil; returns false otherwise. It returns false if the coin set is empty too.
func (Coins) IsEqual ¶ added in v0.9.0
IsEqual returns true if the two sets of Coins have the same value
func (Coins) IsValid ¶ added in v0.9.0
IsValid calls Validate and returns true when the Coins are sorted, have positive amount, with a valid and unique denomination (i.e no duplicates).
func (Coins) IsZero ¶ added in v0.9.0
IsZero returns true if there are no coins or all coins are zero.
func (Coins) MarshalJSON ¶ added in v0.9.0
MarshalJSON implements a custom JSON marshaller for the Coins type to allow nil Coins to be encoded as an empty array.
func (Coins) Max ¶ added in v0.9.0
Max takes two valid Coins inputs and returns a valid Coins result where for every denom D, AmountOf(D) of the result is the maximum of AmountOf(D) of the inputs. Note that the result might be not be equal to either input. For any valid Coins a, b, and c, the following are always true:
a.IsAllLTE(a.Max(b)) b.IsAllLTE(a.Max(b)) a.IsAllLTE(c) && b.IsAllLTE(c) == a.Max(b).IsAllLTE(c) a.Add(b...).IsEqual(a.Min(b).Add(a.Max(b)...))
E.g. {1A, 3B, 2C}.Max({4A, 2B, 2C} == {4A, 3B, 2C}) {2A, 3B}.Max({1B, 4C}) == {2A, 3B, 4C} {1A, 2B}.Max({}) == {1A, 2B}
func (Coins) Min ¶ added in v0.9.0
Min takes two valid Coins inputs and returns a valid Coins result where for every denom D, AmountOf(D) of the result is the minimum of AmountOf(D) of the inputs. Note that the result might be not be equal to either input. For any valid Coins a, b, and c, the following are always true:
a.Min(b).IsAllLTE(a) a.Min(b).IsAllLTE(b) c.IsAllLTE(a) && c.IsAllLTE(b) == c.IsAllLTE(a.Min(b)) a.Add(b...).IsEqual(a.Min(b).Add(a.Max(b)...))
E.g. {1A, 3B, 2C}.Min({4A, 2B, 2C} == {1A, 2B, 2C}) {2A, 3B}.Min({1B, 4C}) == {1B} {1A, 2B}.Min({3C}) == empty
See also DecCoins.Intersect().
func (Coins) SafeSub ¶ added in v0.9.0
SafeSub performs the same arithmetic as Sub but returns a boolean if any negative coin amount was returned. The function panics if `coins` or `coinsB` are not sorted (ascending).
func (Coins) Sub ¶ added in v0.9.0
Sub subtracts a set of coins from another.
e.g. {2A, 3B} - {A} = {A, 3B} {2A} - {0B} = {2A} {A, B} - {A} = {B}
CONTRACT: Sub will never return Coins where one Coin has a non-positive amount. In otherwords, IsValid will always return true.
type DecCoin ¶ added in v0.9.0
func ConvertDecCoin ¶ added in v0.9.0
ConvertDecCoin attempts to convert a decimal coin to a given denomination. If the given denomination is invalid or if neither denomination is registered, an error is returned.
func NewDecCoin ¶ added in v0.9.0
NewDecCoin creates a new DecCoin instance from an Int.
func NewDecCoinFromCoin ¶ added in v0.9.0
NewDecCoinFromCoin creates a new DecCoin from a Coin.
func NewDecCoinFromDec ¶ added in v0.9.0
NewDecCoinFromDec creates a new DecCoin instance from a Dec.
func NewInt64DecCoin ¶ added in v0.9.0
NewInt64DecCoin returns a new DecCoin with a denomination and amount. It will panic if the amount is negative or denom is invalid.
func NormalizeDecCoin ¶ added in v0.9.0
NormalizeDecCoin try to convert a decimal coin to the smallest unit registered, returns original one if failed.
func ParseDecCoin ¶ added in v0.9.0
ParseDecCoin parses a decimal coin from a string, returning an error if invalid. An empty string is considered invalid.
func (DecCoin) IsEqual ¶ added in v0.9.0
IsEqual returns true if the two sets of Coins have the same value.
func (DecCoin) IsGTE ¶ added in v0.9.0
IsGTE returns true if they are the same type and the receiver is an equal or greater value.
func (DecCoin) IsLT ¶ added in v0.9.0
IsLT returns true if they are the same type and the receiver is a smaller value.
func (DecCoin) IsNegative ¶ added in v0.9.0
IsNegative returns true if the coin amount is negative and false otherwise.
TODO: Remove once unsigned integers are used.
func (DecCoin) IsPositive ¶ added in v0.9.0
IsPositive returns true if coin amount is positive.
TODO: Remove once unsigned integers are used.
func (DecCoin) IsValid ¶ added in v0.9.0
IsValid returns true if the DecCoin has a non-negative amount and the denom is valid.
func (DecCoin) String ¶ added in v0.9.0
String implements the Stringer interface for DecCoin. It returns a human-readable representation of a decimal coin.
func (DecCoin) TruncateDecimal ¶ added in v0.9.0
TruncateDecimal returns a Coin with a truncated decimal and a DecCoin for the change. Note, the change may be zero.
type DecCoins ¶ added in v0.9.0
type DecCoins []DecCoin
DecCoins defines a slice of coins with decimal values
func NewDecCoins ¶ added in v0.9.0
NewDecCoins constructs a new coin set with with decimal values from DecCoins. The provided coins will be sanitized by removing zero coins and sorting the coin set. A panic will occur if the coin set is not valid.
func NewDecCoinsFromCoins ¶ added in v0.9.0
NewDecCoinsFromCoins constructs a new coin set with decimal values from regular Coins.
func ParseDecCoins ¶ added in v0.9.0
ParseDecCoins will parse out a list of decimal coins separated by commas. If the parsing is successuful, the provided coins will be sanitized by removing zero coins and sorting the coin set. Lastly a validation of the coin set is executed. If the check passes, ParseDecCoins will return the sanitized coins. Otherwise it will return an error. If an empty string is provided to ParseDecCoins, it returns nil Coins. Expected format: "{amount0}{denomination},...,{amountN}{denominationN}"
func (DecCoins) Add ¶ added in v0.9.0
Add adds two sets of DecCoins.
NOTE: Add operates under the invariant that coins are sorted by denominations.
CONTRACT: Add will never return Coins where one Coin has a non-positive amount. In otherwords, IsValid will always return true.
func (DecCoins) Empty ¶ added in v0.9.0
Empty returns true if there are no coins and false otherwise.
func (DecCoins) GetDenomByIndex ¶ added in v0.9.0
GetDenomByIndex returns the Denom to make the findDup generic
func (DecCoins) Intersect ¶ added in v0.9.0
Intersect will return a new set of coins which contains the minimum DecCoin for common denoms found in both `coins` and `coinsB`. For denoms not common to both `coins` and `coinsB` the minimum is considered to be 0, thus they are not added to the final set. In other words, trim any denom amount from coin which exceeds that of coinB, such that (coin.Intersect(coinB)).IsLTE(coinB). See also Coins.Min().
func (DecCoins) IsAllPositive ¶ added in v0.9.0
IsAllPositive returns true if there is at least one coin and all currencies have a positive value.
TODO: Remove once unsigned integers are used.
func (DecCoins) IsAnyNegative ¶ added in v0.9.0
IsAnyNegative returns true if there is at least one coin whose amount is negative; returns false otherwise. It returns false if the DecCoins set is empty too.
TODO: Remove once unsigned integers are used.
func (DecCoins) IsEqual ¶ added in v0.9.0
IsEqual returns true if the two sets of DecCoins have the same value.
func (DecCoins) IsValid ¶ added in v0.9.0
IsValid calls Validate and returns true when the DecCoins are sorted, have positive amount, with a valid and unique denomination (i.e no duplicates).
func (DecCoins) MulDec ¶ added in v0.9.0
MulDec multiplies all the coins by a decimal.
CONTRACT: No zero coins will be returned.
func (DecCoins) MulDecTruncate ¶ added in v0.9.0
MulDecTruncate multiplies all the decimal coins by a decimal, truncating. It panics if d is zero.
CONTRACT: No zero coins will be returned.
func (DecCoins) QuoDec ¶ added in v0.9.0
QuoDec divides all the decimal coins by a decimal. It panics if d is zero.
CONTRACT: No zero coins will be returned.
func (DecCoins) QuoDecTruncate ¶ added in v0.9.0
QuoDecTruncate divides all the decimal coins by a decimal, truncating. It panics if d is zero.
CONTRACT: No zero coins will be returned.
func (DecCoins) SafeSub ¶ added in v0.9.0
SafeSub performs the same arithmetic as Sub but returns a boolean if any negative coin amount was returned.
func (DecCoins) Sort ¶ added in v0.9.0
Sort is a helper function to sort the set of decimal coins in-place.
func (DecCoins) String ¶ added in v0.9.0
String implements the Stringer interface for DecCoins. It returns a human-readable representation of decimal coins.
func (DecCoins) Sub ¶ added in v0.9.0
Sub subtracts a set of DecCoins from another (adds the inverse).
func (DecCoins) TruncateDecimal ¶ added in v0.9.0
TruncateDecimal returns the coins with truncated decimals and returns the change. Note, it will not return any zero-amount coins in either the truncated or change coins.
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
type NetworkID ¶
func IDFromString ¶
type P2pPrivKey ¶ added in v0.9.0
type P2pPrivKey [P2pPrivateKeyLength]byte
P2pPrivKey P2P address private key
func BytesToP2pPrivKey ¶ added in v0.9.0
func BytesToP2pPrivKey(b []byte) P2pPrivKey
BytesToAccPriveKey sets b to P2pPrivKey. If b is larger than len(h), b will be cropped from the left.
func (P2pPrivKey) Address ¶ added in v0.10.0
func (p P2pPrivKey) Address() Address
Address generate an Address from a P2pPrivKey
func (P2pPrivKey) Bytes ¶ added in v0.9.0
func (p P2pPrivKey) Bytes() []byte
Bytes gets the byte representation of the underlying hash.
func (P2pPrivKey) PubKey ¶ added in v0.9.0
func (p P2pPrivKey) PubKey() P2pPubKey
PubKey generate a P2pPubKey from a P2pPrivKey
func (*P2pPrivKey) SetBytes ¶ added in v0.9.0
func (p *P2pPrivKey) SetBytes(b []byte)
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (P2pPrivKey) Sign ¶ added in v0.9.0
func (p P2pPrivKey) Sign(b []byte) []byte
Sign p2p address uses ed25519 algo
type P2pPubKey ¶ added in v0.9.0
type P2pPubKey [P2pPublicKeyLength]byte
P2pPubKey P2P address public key
func BytesToP2pPubKey ¶ added in v0.9.0
BytesToP2pPubKey sets b to P2pPubKey If b is larger than len(h), b will be cropped from the left.
func P2pPubKeyFromBech ¶ added in v0.10.0
P2pPubKeyFromBech create a P2pPubKey from a Bech-encoded P2P public key