vault

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 20 Imported by: 33

Documentation

Index

Constants

View Source
const (
	WalletIVLength        = 16
	WalletMasterKeyLength = 32
	WalletFileName        = "wallet.dat"
)
View Source
const (
	WalletStoreVersion = "0.0.1"
)

Variables

This section is empty.

Functions

func MakeCommitTransaction

func MakeCommitTransaction(wallet Wallet, sigChain []byte) (*transaction.Transaction, error)

func MakeDeleteNameTransaction

func MakeDeleteNameTransaction(wallet Wallet, name string) (*transaction.Transaction, error)

func MakeIssueTransaction

func MakeIssueTransaction(wallet Wallet, assetID Uint256, address string, value string) (*transaction.Transaction, error)

func MakePrepaidTransaction

func MakePrepaidTransaction(wallet Wallet, assetID Uint256, value, rates string) (*transaction.Transaction, error)

func MakeRegTransaction

func MakeRegTransaction(wallet Wallet, name string, value string) (*transaction.Transaction, error)

func MakeRegisterNameTransaction

func MakeRegisterNameTransaction(wallet Wallet, name string) (*transaction.Transaction, error)

func MakeTransferTransaction

func MakeTransferTransaction(wallet Wallet, assetID Uint256, batchOut ...BatchOut) (*transaction.Transaction, error)

func MakeWithdrawTransaction

func MakeWithdrawTransaction(wallet Wallet, assetID Uint256, value string) (*transaction.Transaction, error)

Types

type Account

type Account struct {
	PrivateKey  []byte
	PublicKey   *crypto.PubKey
	ProgramHash Uint160
}

func NewAccount

func NewAccount() (*Account, error)

func NewAccountWithPrivatekey

func NewAccountWithPrivatekey(privateKey []byte) (*Account, error)

func (*Account) PrivKey

func (a *Account) PrivKey() []byte

func (*Account) PubKey

func (a *Account) PubKey() *crypto.PubKey

type AccountData

type AccountData struct {
	Address             string
	ProgramHash         string
	PrivateKeyEncrypted string
	ContractData        string
}

type BatchOut

type BatchOut struct {
	Address string
	Value   string
}

type HeaderData

type HeaderData struct {
	PasswordHash string
	IV           string
	MasterKey    string
	Version      string
}

type VaultStore

type VaultStore interface {
	GetUnspentsFromProgramHash(programHash Uint160) (map[Uint256][]*transaction.UTXOUnspent, error)
}
var Store VaultStore

type Wallet

type Wallet interface {
	Sign(context *ct.ContractContext) error
	GetAccount(pubKey *crypto.PubKey) (*Account, error)
	GetDefaultAccount() (*Account, error)
	GetUnspent() (map[Uint256][]*transaction.UTXOUnspent, error)
}

func GetWallet

func GetWallet() Wallet

type WalletData

type WalletData struct {
	HeaderData
	AccountData
}

type WalletImpl

type WalletImpl struct {
	*WalletStore
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(path string, password []byte, needAccount bool) (*WalletImpl, error)

func OpenWallet

func OpenWallet(path string, password []byte) (*WalletImpl, error)

func RecoverWallet

func RecoverWallet(path string, password []byte, privateKeyHex string) (*WalletImpl, error)

func (*WalletImpl) ChangePassword

func (w *WalletImpl) ChangePassword(oldPassword []byte, newPassword []byte) bool

func (*WalletImpl) CreateAccount

func (w *WalletImpl) CreateAccount(privateKey []byte) error

func (*WalletImpl) GetAccount

func (w *WalletImpl) GetAccount(pubKey *crypto.PubKey) (*Account, error)

func (*WalletImpl) GetContract

func (w *WalletImpl) GetContract() (*ct.Contract, error)

func (*WalletImpl) GetDefaultAccount

func (w *WalletImpl) GetDefaultAccount() (*Account, error)

func (*WalletImpl) GetUnspent

func (w *WalletImpl) GetUnspent() (map[Uint256][]*transaction.UTXOUnspent, error)

func (*WalletImpl) Sign

func (w *WalletImpl) Sign(context *ct.ContractContext) error

type WalletStore

type WalletStore struct {
	sync.RWMutex

	Path string
	Data WalletData
}

func LoadStore

func LoadStore(fullPath string) (*WalletStore, error)

func NewStore

func NewStore(fullPath string) (*WalletStore, error)

func (*WalletStore) SaveAccountData

func (s *WalletStore) SaveAccountData(programHash []byte, encryptedPrivateKey []byte, contract []byte) error

func (*WalletStore) SaveBasicData

func (s *WalletStore) SaveBasicData(version, iv, masterKey, passwordHash []byte) error

Jump to

Keyboard shortcuts

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