wallet

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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 DecryptAccount

func DecryptAccount(encryptedWIF, passphrase string) (*Account, error)

DecryptAccount decrypts the encryptedWIF with the given passphrase and return the decrypted Account.

func NewAccount

func NewAccount() (*Account, error)

NewAccount creates a new Account with a random generated PrivateKey.

func NewAccountFromWIF

func NewAccountFromWIF(wif string) (*Account, error)

NewAccountFromWIF creates a new Account from the given WIF.

func (*Account) Encrypt

func (a *Account) Encrypt(passphrase string) error

Encrypt encrypts the wallet's PrivateKey with the given passphrase under the NEP-2 standard.

type Contract

type Contract struct {
	// Script hash of the contract deployed on the blockchain.
	Script util.Uint160 `json:"script"`

	// A list of parameters used deploying this contract.
	Parameters []interface{} `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.

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 interface{} `json:"extra"`
	// contains filtered or unexported fields
}

Wallet represents a NEO (NEP-2, NEP-6) compliant wallet.

func NewWallet

func NewWallet(location string) (*Wallet, error)

NewWallet creates a new NEO wallet at the given location.

func NewWalletFromFile

func NewWalletFromFile(path string) (*Wallet, error)

NewWalletFromFile creates a Wallet from the given wallet file path

func (*Wallet) AddAccount

func (w *Wallet) AddAccount(acc *Account)

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

func (w *Wallet) CreateAccount(name, passphrase string) error

CreateAccount generates a new account for the end user and encrypts the private key with the given passphrase.

func (*Wallet) JSON

func (w *Wallet) JSON() ([]byte, error)

JSON outputs a pretty JSON representation of the wallet.

func (*Wallet) Path

func (w *Wallet) Path() string

Path returns the location of the wallet on the filesystem.

func (*Wallet) Save

func (w *Wallet) Save() error

Save saves the wallet data. It's the internal io.ReadWriter that is responsible for saving the data. This can be a buffer, file, etc..

Jump to

Keyboard shortcuts

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