config

package
v1.99.99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const AccountListOffset = 100

AccountListOffset specifies where account addresses start.

View Source
const AccountPathFormat = "/44'/20036'/%v/%v"

AccountPathFormat is a format string for making paths.

View Source
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.
View Source
const DefaultAddress string = "http://localhost:26657"

DefaultAddress of the node to connect to

View Source
const ValidationKeyOffset = 10000

ValidationKeyOffset specifies where validation keys begin in the "account" part of the path.

View Source
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

func (a *Account) MakeValidationKey(path *string) (newKeys *Keypair, err error)

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) String

func (a *Account) String() string

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

func (a *Account) ValidationPublic() []signature.PublicKey

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 Load

func Load(configPath string) (*Config, error)

Load returns a config object loaded from its file

func LoadDefault

func LoadDefault(configPath string) (*Config, error)

LoadDefault returns a config object loaded from its file

If the file does not exist, a default is transparently created

func NewConfig

func NewConfig(node string) *Config

NewConfig creates a new configuration with the given address

func (*Config) CreateAccount

func (c *Config) CreateAccount(name string, hd bool) error

CreateAccount creates an account with the given name

func (Config) EmitAccounts

func (c Config) EmitAccounts(w io.Writer)

EmitAccounts writes the accounts to the supplied writer

func (Config) GetAccounts

func (c Config) GetAccounts() []*Account

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

func (c *Config) RecoverAccount(name string, phrase []string, lang string) error

RecoverAccount recovers an account with the given name and phrase

func (*Config) Save

func (c *Config) Save() error

Save the current configuration

func (*Config) SetAccount

func (c *Config) SetAccount(acct Account)

SetAccount sets the appropriate keys for the given account

func (*Config) UpdateFrom

func (c *Config) UpdateFrom(asscPath string) error

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

func (Keypair) String

func (kp Keypair) String() string

String satisfies io.Stringer by writing the public key

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL