Documentation ¶
Index ¶
- Constants
- func FilterK(keys []signature.PrivateKey, k int) []signature.PrivateKey
- func GetConfigPath() string
- type Account
- func (a *Account) MakeValidationKey(path *string) (newKeys *Keypair, err error)
- func (a *Account) String() string
- func (a *Account) ValidationPrivate() []signature.PrivateKey
- func (a *Account) ValidationPrivateK(keys int) []signature.PrivateKey
- func (a *Account) ValidationPublic() []signature.PublicKey
- type Config
- func (c *Config) CreateAccount(name string, hd bool) error
- func (c Config) EmitAccounts(w io.Writer)
- func (c Config) GetAccounts() []*Account
- func (c *Config) RecoverAccount(name string, phrase []string, lang string) error
- func (c *Config) Save() error
- func (c *Config) SetAccount(acct Account)
- func (c *Config) UpdateFrom(asscPath string) error
- type Keypair
- type SysAccount
Constants ¶
const AccountListOffset = 100
AccountListOffset specifies where account addresses start.
const AccountPathFormat = "/44'/20036'/%v/%v"
AccountPathFormat is a format string for making paths.
const AccountStartNumber = 1
AccountStartNumber is for the "change" part of the path.
0 is not used, 1 is the first valid account path for the wallet.
const DefaultAddress string = "http://localhost:26657"
DefaultAddress of the node to connect to
const ValidationKeyOffset = 10000
ValidationKeyOffset specifies where validation keys begin in the "account" part of the path.
const ValidationPathFormat = AccountPathFormat + "/%v/%v"
ValidationPathFormat is a format string for making validation keys
Variables ¶
This section is empty.
Functions ¶
func FilterK ¶
func FilterK(keys []signature.PrivateKey, k int) []signature.PrivateKey
FilterK filters a list of private keys by k, treating k as a bitset.
Keys appear in the output list if their index in the input list corresponds with a 1 in the bit index of k.
func GetConfigPath ¶
func GetConfigPath() string
GetConfigPath returns the location at which configuration is stored
Types ¶
type Account ¶
type Account struct { Name string `toml:"name"` Address address.Address `toml:"address"` Root *Keypair `toml:"root"` Ownership Keypair `toml:"ownership"` Validation []Keypair `toml:"validation"` ValidationScript chaincode `toml:"validation_script"` }
An Account contains the data necessary to interact with an account:
ownership keys, validation keys if assigned, an account nickname, and an address
func (*Account) MakeValidationKey ¶
MakeValidationKey makes a validation key for this account
It does not actually add it to the keys list--that may be contraindicated by errors further on.
func (*Account) ValidationPrivate ¶
func (a *Account) ValidationPrivate() []signature.PrivateKey
ValidationPrivate constructs a list of all private validation keys
func (*Account) ValidationPrivateK ¶
func (a *Account) ValidationPrivateK(keys int) []signature.PrivateKey
ValidationPrivateK constructs a list of all private validation keys which have their bits set, treating `keys` as a bitset with the lowest bit corresponding to the 0 index of the list of validation keys.
func (*Account) ValidationPublic ¶
ValidationPublic constructs a list of all private validation keys
type Config ¶
type Config struct { Node string `toml:"node"` Accounts map[string]*Account `toml:"accounts"` RFE *SysAccount `toml:"rfe"` NNR *SysAccount `toml:"nnr"` CVC *SysAccount `toml:"cvc"` RecordPrice *SysAccount `toml:"record_price"` SetSysvar *SysAccount `toml:"set_sysvar"` }
Config represents all data from `ndautool.toml`
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig creates a new configuration with the default address
func LoadDefault ¶
LoadDefault returns a config object loaded from its file
If the file does not exist, a default is transparently created
func (*Config) CreateAccount ¶
CreateAccount creates an account with the given name
func (Config) EmitAccounts ¶
EmitAccounts writes the accounts to the supplied writer
func (Config) GetAccounts ¶
GetAccounts returns the unique accounts known to this config.
Accounts are stored by default under two keys: one for the address, and one for the name. That's hard to iter over, so this excludes the duplicates.
func (*Config) RecoverAccount ¶
RecoverAccount recovers an account with the given name and phrase
func (*Config) SetAccount ¶
SetAccount sets the appropriate keys for the given account
func (*Config) UpdateFrom ¶
UpdateFrom updates the config file given the path to the associated data file and the public key of the BPC.
type Keypair ¶
type Keypair struct { Path *string `toml:"path"` Public signature.PublicKey `toml:"public"` Private signature.PrivateKey `toml:"private"` }
A Keypair holds a pair of keys
type SysAccount ¶
type SysAccount struct { Address address.Address `toml:"address"` Keys []signature.PrivateKey `toml:"keys"` }
SysAccount stores data for a system account
These are accounts supporting transactions like RFE, NNR: the address is stored as a system variable, but cached locally.
func SysAccountFromAssc ¶
func SysAccountFromAssc(assc generator.Associated, acct sv.SysAcct) (sa *SysAccount, err error)
SysAccountFromAssc creates a SysAccount from the associated data