Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureEd25519PrivateKeyCorrect(candidatePrivateKey ed25519.PrivateKey) error
- func SignBytes(chainID string, o Signable) []byte
- type Account
- type Address
- func AddressFromBytes(bs []byte) (address Address, err error)
- func AddressFromHexString(str string) (Address, error)
- func AddressFromWord256(addr binary.Word256) Address
- func MaybeAddressFromBytes(bs []byte) (*Address, error)
- func MustAddressFromBytes(addr []byte) Address
- func NewContractAddress(caller Address, sequence uint64) (newAddr Address)
- func (address Address) Bytes() []byte
- func (address Address) MarshalJSON() ([]byte, error)
- func (address Address) MarshalText() ([]byte, error)
- func (address Address) String() string
- func (address *Address) UnmarshalJSON(data []byte) error
- func (address *Address) UnmarshalText(text []byte) error
- func (address Address) Word256() binary.Word256
- type Addressable
- type AddressableSigner
- type Addresses
- type Bytecode
- func (bc Bytecode) Bytes() []byte
- func (bc Bytecode) MarshalJSON() ([]byte, error)
- func (bc Bytecode) MarshalText() ([]byte, error)
- func (bc Bytecode) String() string
- func (bc Bytecode) Tokens() ([]string, error)
- func (bc *Bytecode) UnmarshalJSON(data []byte) error
- func (bc *Bytecode) UnmarshalText(text []byte) error
- type ConcreteAccount
- type ConcretePrivateAccount
- type ConcreteValidator
- type MutableAccount
- type PrivateAccount
- type PrivateKey
- func (pk PrivateKey) MarshalJSON() ([]byte, error)
- func (pk PrivateKey) MarshalText() ([]byte, error)
- func (pk PrivateKey) PublicKey() PublicKey
- func (pk PrivateKey) RawBytes() []byte
- func (pk PrivateKey) Sign(msg []byte) (Signature, error)
- func (pk *PrivateKey) UnmarshalJSON(data []byte) error
- func (pk *PrivateKey) UnmarshalText(text []byte) error
- type PublicKey
- func (pk PublicKey) Address() Address
- func (pk PublicKey) MarshalJSON() ([]byte, error)
- func (pk PublicKey) MarshalText() ([]byte, error)
- func (pk PublicKey) RawBytes() []byte
- func (pk *PublicKey) UnmarshalJSON(data []byte) error
- func (pk *PublicKey) UnmarshalText(text []byte) error
- func (pk PublicKey) VerifyBytes(msg []byte, signature Signature) bool
- type Signable
- type Signature
- type Signer
- type Validator
Constants ¶
const AddressHexLength = 2 * binary.Word160Length
Variables ¶
var GlobalPermissionsAddress = Address(binary.Zero160)
var ZeroAddress = Address{}
Functions ¶
func EnsureEd25519PrivateKeyCorrect ¶ added in v0.18.0
func EnsureEd25519PrivateKeyCorrect(candidatePrivateKey ed25519.PrivateKey) error
Ensures the last 32 bytes of the ed25519 private key is the public key derived from the first 32 private bytes
Types ¶
type Account ¶
type Account interface { Addressable // The value held by this account in terms of the chain-native token Balance() uint64 // The EVM byte code held by this account (or equivalently, this contract) Code() Bytecode // The sequence number of this account, incremented each time a mutation of the // Account is persisted to the blockchain state Sequence() uint64 // The hash of all the values in this accounts storage (typically the root of some subtree // in the merkle tree of global storage state) StorageRoot() []byte // The permission flags and roles for this account Permissions() ptypes.AccountPermissions // Obtain a deterministic serialisation of this account // (i.e. update order and Go runtime independent) Encode() ([]byte, error) // String representation of the account String() string }
The default immutable interface to an account
type Address ¶ added in v0.18.0
func AddressFromBytes ¶ added in v0.18.0
Returns an address consisting of the first 20 bytes of bs, return an error if the bs does not have length exactly 20 but will still return either: the bytes in bs padded on the right or the first 20 bytes of bs truncated in any case.
func AddressFromHexString ¶ added in v0.18.0
func AddressFromWord256 ¶ added in v0.18.0
func MaybeAddressFromBytes ¶ added in v0.18.0
Returns a pointer to an Address that is nil iff len(bs) == 0 otherwise does the same as AddressFromBytes
func MustAddressFromBytes ¶ added in v0.18.0
func NewContractAddress ¶ added in v0.18.0
func (Address) MarshalJSON ¶ added in v0.18.0
func (Address) MarshalText ¶ added in v0.18.0
func (*Address) UnmarshalJSON ¶ added in v0.18.0
func (*Address) UnmarshalText ¶ added in v0.18.0
type Addressable ¶ added in v0.18.0
type AddressableSigner ¶ added in v0.18.0
type AddressableSigner interface { Addressable Signer }
func SigningAccounts ¶ added in v0.18.0
func SigningAccounts(concretePrivateAccounts []*ConcretePrivateAccount) []AddressableSigner
Convert slice of ConcretePrivateAccounts to slice of SigningAccounts
type Bytecode ¶ added in v0.18.0
type Bytecode []byte
func BytecodeFromHex ¶ added in v0.18.0
func NewBytecode ¶ added in v0.18.0
Builds new bytecode using the Splice helper to map byte-like and byte-slice-like types to a flat bytecode slice
func (Bytecode) MarshalJSON ¶ added in v0.18.0
func (Bytecode) MarshalText ¶ added in v0.18.0
func (*Bytecode) UnmarshalJSON ¶ added in v0.18.0
func (*Bytecode) UnmarshalText ¶ added in v0.18.0
type ConcreteAccount ¶ added in v0.18.0
type ConcreteAccount struct { Address Address PublicKey PublicKey Sequence uint64 Balance uint64 Code Bytecode StorageRoot []byte Permissions ptypes.AccountPermissions }
ConcreteAccount is the canonical serialisation and bash-in-place object for an Account
func AsConcreteAccount ¶ added in v0.18.0
func AsConcreteAccount(account Account) *ConcreteAccount
Returns a mutable, serialisable ConcreteAccount by copying from account
func DecodeConcrete ¶ added in v0.18.0
func DecodeConcrete(accBytes []byte) (*ConcreteAccount, error)
func NewConcreteAccount ¶ added in v0.18.0
func NewConcreteAccount(pubKey PublicKey) ConcreteAccount
func NewConcreteAccountFromSecret ¶ added in v0.18.0
func NewConcreteAccountFromSecret(secret string) ConcreteAccount
func (ConcreteAccount) Account ¶ added in v0.18.0
func (acc ConcreteAccount) Account() Account
Return as immutable Account
func (*ConcreteAccount) Copy ¶ added in v0.18.0
func (acc *ConcreteAccount) Copy() *ConcreteAccount
func (*ConcreteAccount) Encode ¶ added in v0.18.0
func (acc *ConcreteAccount) Encode() ([]byte, error)
func (ConcreteAccount) MutableAccount ¶ added in v0.18.0
func (acc ConcreteAccount) MutableAccount() MutableAccount
Return as mutable MutableAccount
func (*ConcreteAccount) String ¶ added in v0.18.0
func (acc *ConcreteAccount) String() string
type ConcretePrivateAccount ¶ added in v0.18.0
type ConcretePrivateAccount struct { Address Address PublicKey PublicKey PrivateKey PrivateKey }
func AsConcretePrivateAccount ¶ added in v0.18.0
func AsConcretePrivateAccount(privateAccount PrivateAccount) *ConcretePrivateAccount
func (ConcretePrivateAccount) PrivateAccount ¶ added in v0.18.0
func (pa ConcretePrivateAccount) PrivateAccount() PrivateAccount
func (ConcretePrivateAccount) Sign ¶ added in v0.18.0
func (pa ConcretePrivateAccount) Sign(msg []byte) (Signature, error)
func (*ConcretePrivateAccount) String ¶ added in v0.18.0
func (pa *ConcretePrivateAccount) String() string
type ConcreteValidator ¶ added in v0.18.0
Neither abci_types or tm_types has quite the representation we want
func AsConcreteValidator ¶ added in v0.18.0
func AsConcreteValidator(validator Validator) *ConcreteValidator
func (*ConcreteValidator) Copy ¶ added in v0.18.0
func (cv *ConcreteValidator) Copy() *ConcreteValidator
func (*ConcreteValidator) String ¶ added in v0.18.0
func (cv *ConcreteValidator) String() string
func (ConcreteValidator) Validator ¶ added in v0.18.0
func (cv ConcreteValidator) Validator() Validator
type MutableAccount ¶ added in v0.18.0
type MutableAccount interface { Account // Set public key (needed for lazy initialisation), should also set the dependent address SetPublicKey(pubKey PublicKey) MutableAccount // Subtract amount from account balance (will panic if amount is greater than balance) SubtractFromBalance(amount uint64) (MutableAccount, error) // Add amount to balance (will panic if amount plus balance is a uint64 overflow) AddToBalance(amount uint64) (MutableAccount, error) // Set EVM byte code associated with account SetCode(code []byte) MutableAccount // Increment Sequence number by 1 (capturing the current Sequence number as the index for any pending mutations) IncSequence() MutableAccount // Set the storage root hash SetStorageRoot(storageRoot []byte) MutableAccount // Set account permissions SetPermissions(permissions ptypes.AccountPermissions) MutableAccount // Get a pointer this account's AccountPermissions in order to mutate them MutablePermissions() *ptypes.AccountPermissions // Create a complete copy of this MutableAccount that is itself mutable Copy() MutableAccount }
func AsMutableAccount ¶ added in v0.18.0
func AsMutableAccount(account Account) MutableAccount
Returns a MutableAccount by copying from account
func FromAddressable ¶ added in v0.18.0
func FromAddressable(addressable Addressable) MutableAccount
Creates an otherwise zeroed Account from an Addressable and returns it as MutableAccount
type PrivateAccount ¶ added in v0.18.0
type PrivateAccount interface { AddressableSigner PrivateKey() PrivateKey }
func GeneratePrivateAccount ¶ added in v0.18.0
func GeneratePrivateAccount() (PrivateAccount, error)
Generates a new account with private key.
func GeneratePrivateAccountFromPrivateKeyBytes ¶ added in v0.18.0
func GeneratePrivateAccountFromPrivateKeyBytes(privKeyBytes []byte) (PrivateAccount, error)
func GeneratePrivateAccountFromSecret ¶ added in v0.18.0
func GeneratePrivateAccountFromSecret(secret string) PrivateAccount
Generates a new account with private key from SHA256 hash of a secret
type PrivateKey ¶ added in v0.18.0
type PrivateKey struct {
crypto.PrivKey `json:"unwrap"`
}
func Ed25519PrivateKeyFromRawBytes ¶ added in v0.18.0
func Ed25519PrivateKeyFromRawBytes(privKeyBytes []byte) (PrivateKey, error)
Creates an ed25519 key from the raw private key bytes
func GeneratePrivateKey ¶ added in v0.18.0
func GeneratePrivateKey(randomReader io.Reader) (PrivateKey, error)
Generates private key from a source of random bytes, if randomReader is nil crypto/rand.Reader is useds
func PrivateKeyFromGoCryptoPrivKey ¶ added in v0.18.0
func PrivateKeyFromGoCryptoPrivKey(privKey crypto.PrivKey) (PrivateKey, error)
func PrivateKeyFromSecret ¶ added in v0.18.0
func PrivateKeyFromSecret(secret string) PrivateKey
func (PrivateKey) MarshalJSON ¶ added in v0.18.0
func (pk PrivateKey) MarshalJSON() ([]byte, error)
func (PrivateKey) MarshalText ¶ added in v0.18.0
func (pk PrivateKey) MarshalText() ([]byte, error)
func (PrivateKey) PublicKey ¶ added in v0.18.0
func (pk PrivateKey) PublicKey() PublicKey
func (PrivateKey) RawBytes ¶ added in v0.18.0
func (pk PrivateKey) RawBytes() []byte
Returns a copy of the raw untyped private key bytes
func (*PrivateKey) UnmarshalJSON ¶ added in v0.18.0
func (pk *PrivateKey) UnmarshalJSON(data []byte) error
func (*PrivateKey) UnmarshalText ¶ added in v0.18.0
func (pk *PrivateKey) UnmarshalText(text []byte) error
type PublicKey ¶ added in v0.18.0
type PublicKey struct {
crypto.PubKey `json:"unwrap"`
}
PublicKey
func PublicKeyFromBytes ¶ added in v0.18.0
Currently this is a stub that reads the raw bytes returned by key_client and returns an ed25519 public key.
func PublicKeyFromGoCryptoPubKey ¶ added in v0.18.0
func (PublicKey) MarshalJSON ¶ added in v0.18.0
func (PublicKey) MarshalText ¶ added in v0.18.0
func (*PublicKey) UnmarshalJSON ¶ added in v0.18.0
func (*PublicKey) UnmarshalText ¶ added in v0.18.0
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing.
type Signature ¶ added in v0.18.0
type Signature struct {
crypto.Signature `json:"unwrap"`
}
func SignatureFromBytes ¶ added in v0.18.0
Currently this is a stub that reads the raw bytes returned by key_client and returns an ed25519 signature.
func SignatureFromGoCryptoSignature ¶ added in v0.18.0
func SignatureFromGoCryptoSignature(signature crypto.Signature) Signature
func (Signature) GoCryptoSignature ¶ added in v0.18.0
func (s Signature) GoCryptoSignature() crypto.Signature
func (Signature) MarshalJSON ¶ added in v0.18.0
func (Signature) MarshalText ¶ added in v0.18.0
func (*Signature) UnmarshalJSON ¶ added in v0.18.0
func (*Signature) UnmarshalText ¶ added in v0.18.0
type Validator ¶ added in v0.18.0
type Validator interface { Addressable // The validator's voting power Power() uint64 // Alter the validator's voting power by amount that can be negative or positive. // A power of 0 effectively unbonds the validator WithNewPower(uint64) Validator }