Documentation ¶
Index ¶
- Constants
- Variables
- func GetPrivateKeyFromNEP2(nep2 string, passphrase string, version byte, N, R, P int) ([]byte, error)
- func GetPrivateKeyFromWIF(wif string) ([]byte, error)
- func Sign(verifiable tx.IVerifiable, pair *keys.KeyPair, magic uint32) ([]byte, error)
- type AccountAndBalance
- type AccountAndBalanceSlice
- type ContextItem
- type ContractParametersContext
- func (c *ContractParametersContext) AddItemWithIndex(contract *sc.Contract, index int, parameter interface{}) bool
- func (c *ContractParametersContext) AddItemWithParams(contract *sc.Contract, parameters []interface{}) bool
- func (c *ContractParametersContext) AddSignature(contract *sc.Contract, pubKey *crypto.ECPoint, signature []byte) (bool, error)
- func (c *ContractParametersContext) GetCompleted() bool
- func (c *ContractParametersContext) GetParameter(scriptHash *helper.UInt160, index int) *sc.ContractParameter
- func (c *ContractParametersContext) GetParameters(scriptHash *helper.UInt160) []sc.ContractParameter
- func (c *ContractParametersContext) GetScript(scriptHash *helper.UInt160) []byte
- func (c *ContractParametersContext) GetScriptHashes() []helper.UInt160
- func (c *ContractParametersContext) GetSignatures(scriptHash *helper.UInt160) map[string][]byte
- func (c *ContractParametersContext) GetWitnesses() ([]tx.Witness, error)
- type IAccount
- type IWallet
- type NEP6Account
- func (a *NEP6Account) Decrypted() bool
- func (a *NEP6Account) GetAddress() string
- func (a *NEP6Account) GetContract() *NEP6Contract
- func (a *NEP6Account) GetIsDefault() bool
- func (a *NEP6Account) GetKey() (*keys.KeyPair, error)
- func (a *NEP6Account) GetKeyFromPassword(password string) (*keys.KeyPair, error)
- func (a *NEP6Account) GetLabel() string
- func (a *NEP6Account) GetLock() bool
- func (a *NEP6Account) GetScriptHash() *helper.UInt160
- func (a *NEP6Account) HasKey() bool
- func (a *NEP6Account) SetContract(contract *NEP6Contract)
- func (a *NEP6Account) SetIsDefault(isDefault bool)
- func (a *NEP6Account) SetLabel(label *string)
- func (a *NEP6Account) SetLock(lock bool)
- func (a *NEP6Account) VerifyPassword(password string) bool
- func (a *NEP6Account) WatchOnly() bool
- type NEP6Contract
- type NEP6ParameterDescriptor
- type NEP6Wallet
- func (w *NEP6Wallet) Contains(scriptHash *helper.UInt160) bool
- func (w *NEP6Wallet) CreateAccount() (IAccount, error)
- func (w *NEP6Wallet) CreateAccountWithContract(contract *sc.Contract, pair *keys.KeyPair) (IAccount, error)
- func (w *NEP6Wallet) CreateAccountWithPrivateKey(privateKey []byte) (IAccount, error)
- func (w *NEP6Wallet) CreateAccountWithScriptHash(scriptHash *helper.UInt160) (IAccount, error)
- func (w *NEP6Wallet) DecryptKey(nep2Key string) (*keys.KeyPair, error)
- func (w *NEP6Wallet) DeleteAccount(scriptHash *helper.UInt160) bool
- func (w *NEP6Wallet) GetAccountByPublicKey(pubKey *crypto.ECPoint) IAccount
- func (w *NEP6Wallet) GetAccountByScriptHash(scriptHash *helper.UInt160) IAccount
- func (w *NEP6Wallet) GetAccounts() []IAccount
- func (w *NEP6Wallet) GetName() string
- func (w *NEP6Wallet) GetPath() string
- func (w *NEP6Wallet) GetVersion() string
- func (w *NEP6Wallet) ImportFromNEP2(nep2, passphrase string, N, R, P int) (IAccount, error)
- func (w *NEP6Wallet) ImportFromWIF(wif string) (IAccount, error)
- func (w *NEP6Wallet) JSON() ([]byte, error)
- func (w *NEP6Wallet) Lock()
- func (w *NEP6Wallet) Save(path string) error
- func (w *NEP6Wallet) Unlock(password string) error
- func (w *NEP6Wallet) VerifyPassword(password string) bool
- type ScryptParameters
- type WalletHelper
- func NewWalletHelperFromContract(rpc rpc.IRpcClient, contract *sc.Contract, pair *keys.KeyPair) (*WalletHelper, error)
- func NewWalletHelperFromNEP2(rpc rpc.IRpcClient, nep2 string, passphrase string, N, R, P int) (*WalletHelper, error)
- func NewWalletHelperFromPrivateKey(rpc rpc.IRpcClient, priKey []byte) (*WalletHelper, error)
- func NewWalletHelperFromWIF(rpc rpc.IRpcClient, wif string) (*WalletHelper, error)
- func NewWalletHelperFromWallet(rpc rpc.IRpcClient, wlt *NEP6Wallet) *WalletHelper
- func (w *WalletHelper) CalculateNetworkFee(trx *tx.Transaction) (uint64, error)
- func (w *WalletHelper) ClaimGas(magic uint32) (string, error)
- func (w *WalletHelper) ExecuMakeTransaction(script []byte, cosigners []tx.Signer, attributes []tx.ITransactionAttribute, ...) (*tx.Transaction, error)
- func (w *WalletHelper) ExecuTransfer(assetHash *helper.UInt160, toAddress string, amount *big.Int, magic uint32) (*tx.Transaction, error)
- func (w *WalletHelper) GetAccountAndBalance(assetHash *helper.UInt160) ([]AccountAndBalance, error)
- func (w *WalletHelper) GetBalanceFromAccount(assetHash *helper.UInt160, account *helper.UInt160) (*big.Int, error)
- func (w *WalletHelper) GetBalanceFromWallet(assetHash *helper.UInt160, wlt *NEP6Wallet) (*big.Int, error)
- func (w *WalletHelper) GetBlockHeight() (uint32, error)
- func (w *WalletHelper) GetContractState(hash *helper.UInt160) (*models.RpcContractState, error)
- func (w *WalletHelper) GetGasConsumed(script []byte, signers []models.RpcSigner) (int64, error)
- func (w *WalletHelper) GetUnClaimedGas() (uint64, error)
- func (w *WalletHelper) MakeTransaction(script []byte, cosigners []tx.Signer, attributes []tx.ITransactionAttribute, ...) (*tx.Transaction, error)
- func (w *WalletHelper) Sign(ctx *ContractParametersContext, magic uint32) (bool, error)
- func (w *WalletHelper) SignTransaction(trx *tx.Transaction, magic uint32) (*tx.Transaction, error)
- func (w *WalletHelper) Transfer(assetHash *helper.UInt160, toAddress string, amount *big.Int, magic uint32) (string, error)
Constants ¶
const (
// The current version of wallet implementations.
Neo3WalletVersion = "3.0"
)
Variables ¶
var DefaultScryptParameters = NewScryptParameters(16384, 8, 8)
Functions ¶
func GetPrivateKeyFromNEP2 ¶
func GetPrivateKeyFromWIF ¶
Types ¶
type AccountAndBalance ¶
func FindPayingAccounts ¶
func FindPayingAccounts(orderedAccounts []AccountAndBalance, amount *big.Int) []AccountAndBalance
func FindRemainingAccountAndBalance ¶
func FindRemainingAccountAndBalance(used, all []AccountAndBalance) []AccountAndBalance
type AccountAndBalanceSlice ¶
type AccountAndBalanceSlice []AccountAndBalance
func (AccountAndBalanceSlice) Len ¶
func (us AccountAndBalanceSlice) Len() int
func (AccountAndBalanceSlice) RemoveAt ¶
func (us AccountAndBalanceSlice) RemoveAt(index int) []AccountAndBalance
func (AccountAndBalanceSlice) Swap ¶
func (us AccountAndBalanceSlice) Swap(i, j int)
type ContextItem ¶
type ContextItem struct { Script []byte Parameters []sc.ContractParameter Signatures map[string][]byte // Dictionary<ECPoint, byte[]> }
func NewContextItem ¶
func NewContextItem(contract *sc.Contract) *ContextItem
type ContractParametersContext ¶
type ContractParametersContext struct { Verifiable tx.IVerifiable // transaction ? ContextItems map[helper.UInt160]*ContextItem // contains filtered or unexported fields }
func NewContractParametersContract ¶
func NewContractParametersContract(verifiable tx.IVerifiable) *ContractParametersContext
func (*ContractParametersContext) AddItemWithIndex ¶
func (c *ContractParametersContext) AddItemWithIndex(contract *sc.Contract, index int, parameter interface{}) bool
func (*ContractParametersContext) AddItemWithParams ¶
func (c *ContractParametersContext) AddItemWithParams(contract *sc.Contract, parameters []interface{}) bool
func (*ContractParametersContext) AddSignature ¶
func (*ContractParametersContext) GetCompleted ¶
func (c *ContractParametersContext) GetCompleted() bool
func (*ContractParametersContext) GetParameter ¶
func (c *ContractParametersContext) GetParameter(scriptHash *helper.UInt160, index int) *sc.ContractParameter
func (*ContractParametersContext) GetParameters ¶
func (c *ContractParametersContext) GetParameters(scriptHash *helper.UInt160) []sc.ContractParameter
func (*ContractParametersContext) GetScript ¶
func (c *ContractParametersContext) GetScript(scriptHash *helper.UInt160) []byte
func (*ContractParametersContext) GetScriptHashes ¶
func (c *ContractParametersContext) GetScriptHashes() []helper.UInt160
func (*ContractParametersContext) GetSignatures ¶
func (c *ContractParametersContext) GetSignatures(scriptHash *helper.UInt160) map[string][]byte
func (*ContractParametersContext) GetWitnesses ¶
func (c *ContractParametersContext) GetWitnesses() ([]tx.Witness, error)
type IAccount ¶
type IAccount interface { GetScriptHash() *helper.UInt160 GetLabel() string SetLabel(label *string) GetIsDefault() bool SetIsDefault(isDefault bool) GetLock() bool SetLock(lock bool) GetContract() *NEP6Contract SetContract(c *NEP6Contract) GetAddress() string HasKey() bool WatchOnly() bool GetKey() (*keys.KeyPair, error) }
type IWallet ¶
type IWallet interface { GetName() string GetPath() string GetVersion() string //ChangePassword(oldPassword string, newPassword string) bool Contains(scriptHash *helper.UInt160) bool CreateAccount() (IAccount, error) CreateAccountWithPrivateKey(privateKey []byte) (IAccount, error) CreateAccountWithContract(contract *sc.Contract, key *keys.KeyPair) (IAccount, error) CreateAccountWithScriptHash(scriptHash *helper.UInt160) (IAccount, error) DeleteAccount(scriptHash *helper.UInt160) bool GetAccountByPublicKey(pubKey *crypto.ECPoint) IAccount GetAccountByScriptHash(scriptHash *helper.UInt160) IAccount GetAccounts() []IAccount }
type NEP6Account ¶
type NEP6Account struct { Address string `json:"address"` Label *string `json:"label"` IsDefault bool `json:"isdefault"` Lock bool `json:"lock"` Nep2Key *string `json:"key"` Contract *NEP6Contract `json:"contract"` Extra interface{} `json:"extra"` // contains filtered or unexported fields }
NEP6Account represents a NEO account. It holds the private and public key along with some metadata.
func GenerateNEP6Account ¶
func GenerateNEP6Account(password string) (*NEP6Account, error)
GenerateNEP6Account creates a new NEP6Account with a random generated PrivateKey.
func NewNEP6Account ¶
func NewNEP6Account(wallet *NEP6Wallet, scriptHash *helper.UInt160, nep2Key *string) *NEP6Account
func NewNEP6AccountFromKeyPair ¶
func NewNEP6AccountFromKeyPair(wallet *NEP6Wallet, scriptHash *helper.UInt160, pair *keys.KeyPair, password string) (*NEP6Account, error)
func (*NEP6Account) Decrypted ¶
func (a *NEP6Account) Decrypted() bool
func (*NEP6Account) GetAddress ¶
func (a *NEP6Account) GetAddress() string
func (*NEP6Account) GetContract ¶
func (a *NEP6Account) GetContract() *NEP6Contract
func (*NEP6Account) GetIsDefault ¶
func (a *NEP6Account) GetIsDefault() bool
func (*NEP6Account) GetKeyFromPassword ¶
func (a *NEP6Account) GetKeyFromPassword(password string) (*keys.KeyPair, error)
func (*NEP6Account) GetLabel ¶
func (a *NEP6Account) GetLabel() string
func (*NEP6Account) GetLock ¶
func (a *NEP6Account) GetLock() bool
func (*NEP6Account) GetScriptHash ¶
func (a *NEP6Account) GetScriptHash() *helper.UInt160
func (*NEP6Account) HasKey ¶
func (a *NEP6Account) HasKey() bool
func (*NEP6Account) SetContract ¶
func (a *NEP6Account) SetContract(contract *NEP6Contract)
func (*NEP6Account) SetIsDefault ¶
func (a *NEP6Account) SetIsDefault(isDefault bool)
func (*NEP6Account) SetLabel ¶
func (a *NEP6Account) SetLabel(label *string)
func (*NEP6Account) SetLock ¶
func (a *NEP6Account) SetLock(lock bool)
func (*NEP6Account) VerifyPassword ¶
func (a *NEP6Account) VerifyPassword(password string) bool
func (*NEP6Account) WatchOnly ¶
func (a *NEP6Account) WatchOnly() bool
type NEP6Contract ¶
type NEP6Contract struct { Script string `json:"script"` Parameters []NEP6ParameterDescriptor `json:"parameters"` Deployed bool `json:"deployed"` // contains filtered or unexported fields }
func NewNEP6Contract ¶
func NewNEP6Contract(script []byte, paramList []sc.ContractParameterType, paramNames []string, isDeployed bool) (*NEP6Contract, error)
func (*NEP6Contract) GetScript ¶
func (c *NEP6Contract) GetScript() []byte
func (*NEP6Contract) GetScriptHash ¶
func (c *NEP6Contract) GetScriptHash() *helper.UInt160
func (*NEP6Contract) ToContract ¶
func (c *NEP6Contract) ToContract() (*sc.Contract, error)
type NEP6ParameterDescriptor ¶
type NEP6Wallet ¶
type NEP6Wallet struct { Name *string `json:"name"` Version string `json:"version"` Scrypt *ScryptParameters `json:"scrypt"` // readonly Accounts []NEP6Account `json:"accounts"` Extra interface{} `json:"extra"` // contains filtered or unexported fields }
NEP6Wallet represents a NEO (NEP-2, NEP-6) compliant wallet.
func NewNEP6Wallet ¶
func NewNEP6Wallet(path string, settings *helper.ProtocolSettings, name *string, scrypt *ScryptParameters) (*NEP6Wallet, error)
NewNEP6Wallet creates a NEO wallet.
func (*NEP6Wallet) CreateAccount ¶
func (w *NEP6Wallet) CreateAccount() (IAccount, error)
CreateAccount generates a new account for the end user and encrypts the private key with the password in the wallet.
func (*NEP6Wallet) CreateAccountWithContract ¶
func (*NEP6Wallet) CreateAccountWithPrivateKey ¶
func (w *NEP6Wallet) CreateAccountWithPrivateKey(privateKey []byte) (IAccount, error)
func (*NEP6Wallet) CreateAccountWithScriptHash ¶
func (w *NEP6Wallet) CreateAccountWithScriptHash(scriptHash *helper.UInt160) (IAccount, error)
func (*NEP6Wallet) DecryptKey ¶
func (w *NEP6Wallet) DecryptKey(nep2Key string) (*keys.KeyPair, error)
func (*NEP6Wallet) DeleteAccount ¶
func (w *NEP6Wallet) DeleteAccount(scriptHash *helper.UInt160) bool
func (*NEP6Wallet) GetAccountByPublicKey ¶
func (w *NEP6Wallet) GetAccountByPublicKey(pubKey *crypto.ECPoint) IAccount
func (*NEP6Wallet) GetAccountByScriptHash ¶
func (w *NEP6Wallet) GetAccountByScriptHash(scriptHash *helper.UInt160) IAccount
func (*NEP6Wallet) GetAccounts ¶
func (w *NEP6Wallet) GetAccounts() []IAccount
func (*NEP6Wallet) GetName ¶
func (w *NEP6Wallet) GetName() string
func (*NEP6Wallet) GetPath ¶
func (w *NEP6Wallet) GetPath() string
func (*NEP6Wallet) GetVersion ¶
func (w *NEP6Wallet) GetVersion() string
func (*NEP6Wallet) ImportFromNEP2 ¶
func (w *NEP6Wallet) ImportFromNEP2(nep2, passphrase string, N, R, P int) (IAccount, error)
Import account from Nep2Key
func (*NEP6Wallet) ImportFromWIF ¶
func (w *NEP6Wallet) ImportFromWIF(wif string) (IAccount, error)
Import account from WIF
func (*NEP6Wallet) JSON ¶
func (w *NEP6Wallet) JSON() ([]byte, error)
JSON outputs a pretty JSON representation of the wallet.
func (*NEP6Wallet) Lock ¶
func (w *NEP6Wallet) Lock()
func (*NEP6Wallet) Save ¶
func (w *NEP6Wallet) Save(path string) error
func (*NEP6Wallet) Unlock ¶
func (w *NEP6Wallet) Unlock(password string) error
func (*NEP6Wallet) VerifyPassword ¶
func (w *NEP6Wallet) VerifyPassword(password string) bool
type ScryptParameters ¶
ScryptParameters is a json-serializable container for scrypt KDF parameters.
func NewScryptParameters ¶
func NewScryptParameters(n int, r int, p int) *ScryptParameters
type WalletHelper ¶
type WalletHelper struct { Client rpc.IRpcClient Magic uint32 // contains filtered or unexported fields }
func NewWalletHelperFromContract ¶
func NewWalletHelperFromContract(rpc rpc.IRpcClient, contract *sc.Contract, pair *keys.KeyPair) (*WalletHelper, error)
func NewWalletHelperFromNEP2 ¶
func NewWalletHelperFromNEP2(rpc rpc.IRpcClient, nep2 string, passphrase string, N, R, P int) (*WalletHelper, error)
func NewWalletHelperFromPrivateKey ¶
func NewWalletHelperFromPrivateKey(rpc rpc.IRpcClient, priKey []byte) (*WalletHelper, error)
func NewWalletHelperFromWIF ¶
func NewWalletHelperFromWIF(rpc rpc.IRpcClient, wif string) (*WalletHelper, error)
Create a WalletHelper using your own private key, password is "" by default
func NewWalletHelperFromWallet ¶
func NewWalletHelperFromWallet(rpc rpc.IRpcClient, wlt *NEP6Wallet) *WalletHelper
func (*WalletHelper) CalculateNetworkFee ¶
func (w *WalletHelper) CalculateNetworkFee(trx *tx.Transaction) (uint64, error)
func (*WalletHelper) ClaimGas ¶
func (w *WalletHelper) ClaimGas(magic uint32) (string, error)
ClaimGas for NEP6Account
func (*WalletHelper) ExecuMakeTransaction ¶
func (w *WalletHelper) ExecuMakeTransaction(script []byte, cosigners []tx.Signer, attributes []tx.ITransactionAttribute, balanceGas []AccountAndBalance) (*tx.Transaction, error)
func (*WalletHelper) ExecuTransfer ¶
func (w *WalletHelper) ExecuTransfer(assetHash *helper.UInt160, toAddress string, amount *big.Int, magic uint32) (*tx.Transaction, error)
func (*WalletHelper) GetAccountAndBalance ¶
func (w *WalletHelper) GetAccountAndBalance(assetHash *helper.UInt160) ([]AccountAndBalance, error)
GetAccountAndBalance gets account and balance pair
func (*WalletHelper) GetBalanceFromAccount ¶
func (w *WalletHelper) GetBalanceFromAccount(assetHash *helper.UInt160, account *helper.UInt160) (*big.Int, error)
GetBalanceFromAccount is used to get balance of an asset of an account
func (*WalletHelper) GetBalanceFromWallet ¶
func (w *WalletHelper) GetBalanceFromWallet(assetHash *helper.UInt160, wlt *NEP6Wallet) (*big.Int, error)
GetBalanceFromWallet is used to get balance from all accounts inside the wallet
func (*WalletHelper) GetBlockHeight ¶
func (w *WalletHelper) GetBlockHeight() (uint32, error)
GetBlockHeight gets the current blockchain height via rpc
func (*WalletHelper) GetContractState ¶
func (w *WalletHelper) GetContractState(hash *helper.UInt160) (*models.RpcContractState, error)
func (*WalletHelper) GetGasConsumed ¶
GetGasConsumed runs a script in ApplicationEngine in test mode and returns gas consumed
func (*WalletHelper) GetUnClaimedGas ¶
func (w *WalletHelper) GetUnClaimedGas() (uint64, error)
GetUnClaimedGas gets the amount of unclaimed gas in the wallet
func (*WalletHelper) MakeTransaction ¶
func (w *WalletHelper) MakeTransaction(script []byte, cosigners []tx.Signer, attributes []tx.ITransactionAttribute, balanceGas []AccountAndBalance) (*tx.Transaction, error)
func (*WalletHelper) Sign ¶
func (w *WalletHelper) Sign(ctx *ContractParametersContext, magic uint32) (bool, error)
func (*WalletHelper) SignTransaction ¶
func (w *WalletHelper) SignTransaction(trx *tx.Transaction, magic uint32) (*tx.Transaction, error)