Documentation ¶
Index ¶
- type Account
- type Contract
- type ScryptParams
- type Wallet
- func (w *Wallet) AddAccount(acc *Account)
- func (w *Wallet) AddNewAccount() error
- func (w *Wallet) DecryptAll(password string) error
- func (w *Wallet) EncryptAll(password string) error
- func (w *Wallet) ImportFromNEP2Key(nep2Key, passphare string) error
- func (w *Wallet) ImportFromWIF(wif string) error
- func (w *Wallet) JSON() ([]byte, error)
- func (w *Wallet) Save(path string) error
- type WalletHelper
- func (w *WalletHelper) ClaimGas(from string) (string, error)
- func (w *WalletHelper) DeployContract(script []byte, paramTypes string, returnTypeHexString string, hasStorage bool, ...) (*helper.UInt160, error)
- func (w *WalletHelper) GetBalance(address string) (neoBalance int, gasBalance float64, err error)
- func (w *WalletHelper) InvokeContract(scriptHash helper.UInt160, method string, args []sc.ContractParameter) (*helper.UInt256, error)
- func (w *WalletHelper) Transfer(assetId helper.UInt256, from string, to string, amount float64) (string, error)
- func (w *WalletHelper) TransferNep5(assetId helper.UInt160, from string, to string, amount float64) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // NEO KeyPair. KeyPair *keys.KeyPair `json:"-"` // NEO public address. Address string `json:"address"` // Label is a label the user had made for this account. Label string `json:"label"` // Indicates whether the account is the default change account. Default bool `json:"isDefault"` // Indicates whether the account is locked by the user. // the client shouldn't spend the funds in a locked account. Locked bool `json:"lock"` // Encrypted Key of the account also known as the key. Nep2Key string `json:"key"` // 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"` // This field can be empty. Extra interface{} `json:"extra"` }
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 NewAccountFromKeyPair ¶
NewAccountFromKeyPair created a wallet from the given PrivateKey.
func NewAccountFromNEP2 ¶
NewAccountFromNep2 decrypts the nep2Key with the given passphrase and returns the decrypted Account.
func NewAccountFromWIF ¶
NewAccountFromWIF creates a new Account from the given WIF.
type Contract ¶
type Contract struct { // Script hash of the contract deployed on the block chain. Script string `json:"script"` // A list of parameters used deploying this contract. Parameters []interface{} `json:"parameters"` // Indicates whether the contract has been deployed to the block chain. Deployed bool `json:"deployed"` }
Contract represents a subset of the smart contract to embed in the Account so it's NEP-6 compliant.
type ScryptParams ¶
ScryptParams is a json-serializable container for scrypt KDF parameters.
type Wallet ¶
type Wallet struct { // string type Name string `json:"name"` // Version of the wallet, used for later upgrades. Version string `json:"version"` Scrypt *ScryptParams `json:"scrypt"` // A list of accounts which describes the details of each account // in the wallet. Accounts []*Account `json:"accounts"` // Extra metadata can be used for storing arbitrary data. // This field can be empty. Extra interface{} `json:"extra"` }
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 if the account is not in wallet
func (*Wallet) AddNewAccount ¶
CreateAccount generates a new account for the end user and encrypts the private key with the given passphrase.
func (*Wallet) DecryptAll ¶
decrypt all the accounts in wallet, save the nep2Key
func (*Wallet) EncryptAll ¶
encrypt all the accounts in wallet, save the nep2Key
func (*Wallet) ImportFromNEP2Key ¶
Import account from Nep2Key
func (*Wallet) ImportFromWIF ¶
Import account from WIF
type WalletHelper ¶
type WalletHelper struct { TxBuilder *tx.TransactionBuilder Account *Account }
func NewWalletHelper ¶
func NewWalletHelper(txBuilder *tx.TransactionBuilder, account *Account) *WalletHelper
func (*WalletHelper) ClaimGas ¶
func (w *WalletHelper) ClaimGas(from string) (string, error)
ClaimGas, return txid
func (*WalletHelper) DeployContract ¶
func (*WalletHelper) GetBalance ¶
func (w *WalletHelper) GetBalance(address string) (neoBalance int, gasBalance float64, err error)
GetBalance is used to get neo and gas balance of an address
func (*WalletHelper) InvokeContract ¶
func (w *WalletHelper) InvokeContract(scriptHash helper.UInt160, method string, args []sc.ContractParameter) (*helper.UInt256, error)
func (*WalletHelper) Transfer ¶
func (w *WalletHelper) Transfer(assetId helper.UInt256, from string, to string, amount float64) (string, error)
Transfer is used to transfer neo or gas or other utxo asset, single signature, return txid