Documentation ¶
Index ¶
- Constants
- Variables
- func NewAddress(w *Wallet, p address.Protocol) (address.Address, error)
- type Backend
- type DSBackend
- func (backend *DSBackend) Addresses() []address.Address
- func (backend *DSBackend) GetKeyInfo(addr address.Address) (*crypto.KeyInfo, error)
- func (backend *DSBackend) HasAddress(addr address.Address) bool
- func (backend *DSBackend) ImportKey(ki *crypto.KeyInfo) error
- func (backend *DSBackend) NewAddress(protocol address.Protocol) (address.Address, error)
- func (backend *DSBackend) SignBytes(data []byte, addr address.Address) (*crypto.Signature, error)
- type Importer
- type MsgMeta
- type MsgType
- type Wallet
- func (w *Wallet) Addresses() []address.Address
- func (w *Wallet) Backends(kind reflect.Type) []Backend
- func (w *Wallet) Export(addrs []address.Address) ([]*crypto.KeyInfo, error)
- func (w *Wallet) Find(addr address.Address) (Backend, error)
- func (w *Wallet) GetPubKeyForAddress(addr address.Address) ([]byte, error)
- func (w *Wallet) HasAddress(a address.Address) bool
- func (w *Wallet) Import(kinfos ...*crypto.KeyInfo) ([]address.Address, error)
- func (w *Wallet) NewKeyInfo() (*crypto.KeyInfo, error)
- func (w *Wallet) SignBytes(data []byte, addr address.Address) (*crypto.Signature, error)
- func (w *Wallet) WalletSign(ctx context.Context, addr address.Address, msg []byte, meta MsgMeta) (*crypto.Signature, error)
Constants ¶
const ( MTUnknown = "unknown" // Signing message CID. MsgMeta.Extra contains raw cbor message bytes MTChainMsg = "message" // Signing a blockheader. signing raw cbor block bytes (MsgMeta.Extra is empty) MTBlock = "block" // Signing a deal proposal. signing raw cbor proposal bytes (MsgMeta.Extra is empty) MTDealProposal = "dealproposal" )
Variables ¶
var DSBackendType = reflect.TypeOf(&DSBackend{})
DSBackendType is the reflect type of the DSBackend.
var ErrKeyInfoNotFound = fmt.Errorf("key info not found")
Functions ¶
func NewAddress ¶
NewAddress creates a new account address on the default wallet backend.
Types ¶
type Backend ¶
type Backend interface { // Addresses returns a list of all accounts currently stored in this backend. Addresses() []address.Address // Contains returns true if this backend stores the passed in address. HasAddress(addr address.Address) bool // Sign cryptographically signs data with the private key associated with an address. SignBytes(data []byte, addr address.Address) (*crypto.Signature, error) // GetKeyInfo will return the keyinfo associated with address `addr` // iff backend contains the addr. GetKeyInfo(addr address.Address) (*crypto.KeyInfo, error) }
Backend is the interface to represent different storage backends that can contain many addresses.
type DSBackend ¶
type DSBackend struct {
// contains filtered or unexported fields
}
DSBackend is a wallet backend implementation for storing addresses in a datastore.
func NewDSBackend ¶
NewDSBackend constructs a new backend using the passed in datastore.
func (*DSBackend) Addresses ¶
func (backend *DSBackend) Addresses() []address.Address
Addresses returns a list of all addresses that are stored in this backend.
func (*DSBackend) GetKeyInfo ¶
GetKeyInfo will return the private & public keys associated with address `addr` iff backend contains the addr.
func (*DSBackend) HasAddress ¶
HasAddress checks if the passed in address is stored in this backend. Safe for concurrent access.
func (*DSBackend) NewAddress ¶
NewAddress creates a new address and stores it. Safe for concurrent access.
type Importer ¶
type Importer interface { // ImportKey imports the key described by the given keyinfo // into the backend ImportKey(ki *crypto.KeyInfo) error }
Importer is a specialization of a wallet backend that can import new keys into its permanent storage. Disk backed wallets can do this, hardware wallets generally cannot.
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
wallet manages the locally stored addresses.
func (*Wallet) Addresses ¶
func (w *Wallet) Addresses() []address.Address
Addresses retrieves all stored addresses. Safe for concurrent access. Always sorted in the same order.
func (*Wallet) Find ¶
Find searches through all backends and returns the one storing the passed in address. Safe for concurrent access.
func (*Wallet) GetPubKeyForAddress ¶
GetPubKeyForAddress returns the public key in the keystore associated with the given address.
func (*Wallet) HasAddress ¶
HasAddress checks if the given address is stored. Safe for concurrent access.
func (*Wallet) NewKeyInfo ¶
NewKeyInfo creates a new KeyInfo struct in the wallet backend and returns it