Documentation ¶
Index ¶
- type Account
- type Contract
- type ContractParam
- type Extra
- type Token
- type Wallet
- func (w *Wallet) AddAccount(acc *Account)
- func (w *Wallet) AddToken(tok *Token)
- func (w *Wallet) Close()
- func (w *Wallet) CreateAccount(name, passphrase string) error
- func (w *Wallet) GetAccount(h util.Uint160) *Account
- func (w *Wallet) GetChangeAddress() util.Uint160
- func (w *Wallet) JSON() ([]byte, error)
- func (w *Wallet) Path() string
- func (w *Wallet) RemoveAccount(addr string) error
- func (w *Wallet) RemoveToken(h util.Uint160) error
- func (w *Wallet) Save() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // NEO public address. Address string `json:"address"` // Encrypted WIF of the account also known as the key. EncryptedWIF string `json:"key"` // Label is a label the user had made for this account. Label string `json:"label"` // Contract is a Contract object which describes the details of the contract. // This field can be null (for watch-only address). Contract *Contract `json:"contract"` // Indicates whether the account is locked by the user. // the client shouldn't spend the funds in a locked account. Locked bool `json:"lock"` // Indicates whether the account is the default change account. Default bool `json:"isdefault"` // contains filtered or unexported fields }
Account represents a NEO account. It holds the private and public key along with some metadata.
func NewAccount ¶
NewAccount creates a new Account with a random generated PrivateKey.
func NewAccountFromEncryptedWIF ¶
NewAccountFromEncryptedWIF creates a new Account from the given encrypted WIF.
func NewAccountFromWIF ¶
NewAccountFromWIF creates a new Account from the given WIF.
func (*Account) ConvertMultisig ¶
ConvertMultisig sets a's contract to multisig contract with m sufficient signatures.
func (*Account) Decrypt ¶
Decrypt decrypts the EncryptedWIF with the given passphrase returning error if anything goes wrong.
func (*Account) Encrypt ¶
Encrypt encrypts the wallet's PrivateKey with the given passphrase under the NEP-2 standard.
func (*Account) PrivateKey ¶
func (a *Account) PrivateKey() *keys.PrivateKey
PrivateKey returns private key corresponding to the account.
func (*Account) SignTx ¶
func (a *Account) SignTx(t *transaction.Transaction) error
SignTx signs transaction t and updates it's Witnesses.
type Contract ¶
type Contract struct { // Script of the contract deployed on the blockchain. Script []byte `json:"script"` // A list of parameters used deploying this contract. Parameters []ContractParam `json:"parameters"` // Indicates whether the contract has been deployed to the blockchain. Deployed bool `json:"deployed"` }
Contract represents a subset of the smartcontract to embed in the Account so it's NEP-6 compliant.
func (Contract) ScriptHash ¶
ScriptHash returns the hash of contract's script.
type ContractParam ¶
type ContractParam struct { Name string `json:"name"` Type smartcontract.ParamType `json:"type"` }
ContractParam is a descriptor of a contract parameter containing type and optional name.
type Extra ¶
type Extra struct { // Tokens is a list of imported token contracts. Tokens []*Token }
Extra stores imported token contracts.
type Token ¶
type Token struct { Name string `json:"name"` Hash util.Uint160 `json:"script_hash"` Decimals int64 `json:"decimals"` Symbol string `json:"symbol"` }
Token represents imported token contract.
type Wallet ¶
type Wallet struct { // Version of the wallet, used for later upgrades. Version string `json:"version"` // A list of accounts which describes the details of each account // in the wallet. Accounts []*Account `json:"accounts"` Scrypt keys.ScryptParams `json:"scrypt"` // Extra metadata can be used for storing arbitrary data. // This field can be empty. Extra Extra `json:"extra"` // contains filtered or unexported fields }
Wallet represents a NEO (NEP-2, NEP-6) compliant wallet.
func NewWalletFromFile ¶
NewWalletFromFile creates a Wallet from the given wallet file path
func (*Wallet) AddAccount ¶
AddAccount adds an existing Account to the wallet.
func (*Wallet) Close ¶
func (w *Wallet) Close()
Close closes the internal rw if its an io.ReadCloser.
func (*Wallet) CreateAccount ¶
CreateAccount generates a new account for the end user and encrypts the private key with the given passphrase.
func (*Wallet) GetAccount ¶
GetAccount returns account corresponding to the provided scripthash.
func (*Wallet) GetChangeAddress ¶
GetChangeAddress returns the default address to send transaction's change to.
func (*Wallet) RemoveAccount ¶
RemoveAccount removes an Account with the specified addr from the wallet.
func (*Wallet) RemoveToken ¶
RemoveToken removes token with the specified hash from the wallet.