Documentation ¶
Index ¶
- Variables
- func BlockString(block *protocol.Block) string
- func BlockTopologyString(topo *koinos.BlockTopology) string
- func CalculateMerkleRoot(nodes [][]byte) ([]byte, error)
- func CheckIsValidAddress(s string) bool
- func DecimalToSatoshi(d *decimal.Decimal, precision int) (uint64, error)
- func DecodeWIF(wif string) ([]byte, error)
- func DisplayAddress(addressBytes []byte) string
- func EncodeWIF(privKey []byte, compress bool, netID byte) string
- func EnsureDir(dir string) error
- func GenerateBase58ID(length int) string
- func GetAppDir(baseDir string, appName string) string
- func GetBoolOption(key string, defaultValue bool, cliArg bool, configs ...map[string]interface{}) bool
- func GetHomeDir() string
- func GetIntOption(key string, defaultValue int, cliArg int, configs ...map[string]interface{}) int
- func GetStringOption(key string, defaultValue string, cliArg string, ...) string
- func GetStringSliceOption(key string, cliArg []string, configs ...map[string]interface{}) []string
- func HashMessage(message proto.Message) ([]byte, error)
- func HexStringToBytes(s string) ([]byte, error)
- func InitBaseDir(baseDir string) (string, error)
- func MultihashString(hash []byte) string
- func NonceBytesToUInt64(nonceBytes []byte) (uint64, error)
- func SatoshiToDecimal(balance uint64, precision int) (*decimal.Decimal, error)
- func SignTransaction(key []byte, tx *protocol.Transaction) error
- func TransactionString(transaction *protocol.Transaction) string
- func UInt64ToNonceBytes(value uint64) ([]byte, error)
- type KoinosKey
- type Void
- type YamlConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidNonce is the error returned when a nonce is invalid ErrInvalidNonce = errors.New("invalid nonce") )
Functions ¶
func BlockString ¶
BlockString returns a string containing the given block's height and ID
func BlockTopologyString ¶
func BlockTopologyString(topo *koinos.BlockTopology) string
BlockTopologyString returns a string representation of the BlockTopologyCmp
func CalculateMerkleRoot ¶
CalculateMerkleRoot calculates the merkle root for given leafs
func CheckIsValidAddress ¶ added in v1.1.0
CheckIsValidAddress takes a string and returns a boolean if it is potentially valid Uses P2PKH (original bitcoin spec) 33-35 alphanumeric characters beginning with the number 1, random digits, upper/lower case characters exceptions: uppercase letter O, uppercase letter I, lowercase letter l, and the number 0
func DecimalToSatoshi ¶
DecimalToSatoshi converts the given decimal to a satoshi value
func DisplayAddress ¶
DisplayAddress takes address bytes and returns a properly formatted human-readable string
func GenerateBase58ID ¶
GenerateBase58ID generates a random seed string
func GetBoolOption ¶
func GetBoolOption(key string, defaultValue bool, cliArg bool, configs ...map[string]interface{}) bool
GetBoolOption fetches a bool cli value, respecting values in a given config
func GetHomeDir ¶
func GetHomeDir() string
GetHomeDir gets the user's home directory with special casing for windows
func GetIntOption ¶
GetIntOption fetches an int value, respecting values in a given config
func GetStringOption ¶
func GetStringOption(key string, defaultValue string, cliArg string, configs ...map[string]interface{}) string
GetStringOption fetches a string cli value, respecting values in a given config
func GetStringSliceOption ¶
GetStringSliceOption fetches a string slicecli value, respecting values in a given config
func HashMessage ¶
HashMessage takes a protobuf message and returns the multihash of the message
func HexStringToBytes ¶
HexStringToBytes decodes a hex string to a byte slice
func InitBaseDir ¶
InitBaseDir creates the base directory
func MultihashString ¶
MultihashString returns a hex string representation of the given multihash
func NonceBytesToUInt64 ¶
NonceBytesToUInt64 converts the given nonce bytes to a UInt64
func SatoshiToDecimal ¶
SatoshiToDecimal converts the given UInt64 value to a decimals with the given precision
func SignTransaction ¶
func SignTransaction(key []byte, tx *protocol.Transaction) error
SignTransaction signs the transaction with the given key
func TransactionString ¶
func TransactionString(transaction *protocol.Transaction) string
TransactionString returns a string containing the given transaction's ID
func UInt64ToNonceBytes ¶
UInt64ToNonceBytes converts the given nonce uint64 to nonce bytes
Types ¶
type KoinosKey ¶
type KoinosKey struct {
PrivateKey *ecdsa.PrivateKey
}
KoinosKey represents a set of keys
func GenerateKoinosKey ¶
GenerateKoinosKey generates a new set of keys
func NewKoinosKeyFromBytes ¶ added in v1.1.0
NewKoinosKeyFromBytes creates a new key set from a private key byte slice
func (*KoinosKey) AddressBytes ¶
AddressBytes fetches the byte address associated with this key set
func (*KoinosKey) PrivateBytes ¶
PrivateBytes gets the private key bytes
func (*KoinosKey) PublicBytes ¶
PublicBytes get the public key bytes
type YamlConfig ¶
type YamlConfig struct { Global map[string]interface{} `yaml:"global,omitempty"` P2P map[string]interface{} `yaml:"p2p,omitempty"` BlockStore map[string]interface{} `yaml:"block_store,omitempty"` JSONRPC map[string]interface{} `yaml:"jsonrpc,omitempty"` TransactionStore map[string]interface{} `yaml:"transaction_store,omitempty"` ContractMetaStore map[string]interface{} `yaml:"contract_meta_store,omitempty"` }
YamlConfig represents the koinos yaml application config values
func InitYamlConfig ¶
func InitYamlConfig(baseDir string) *YamlConfig
InitYamlConfig initializes a yaml config