Documentation ¶
Index ¶
- Constants
- Variables
- func ActSigType(typ KeyType) crypto.SigType
- type Driver
- type Key
- type KeyInfo
- type KeyType
- type KeystoreWallet
- func (w *KeystoreWallet) Balance(ctx context.Context, addr address.Address) (fil.BigInt, error)
- func (w *KeystoreWallet) DefaultAddress() address.Address
- func (w *KeystoreWallet) ExportKey(_ context.Context, addr address.Address) (*KeyInfo, error)
- func (w *KeystoreWallet) ImportKey(_ context.Context, k *KeyInfo) (address.Address, error)
- func (w *KeystoreWallet) List() ([]address.Address, error)
- func (w *KeystoreWallet) NewKey(ctx context.Context, kt KeyType) (address.Address, error)
- func (w *KeystoreWallet) SetDefaultAddress(addr address.Address) error
- func (w *KeystoreWallet) Sign(ctx context.Context, addr address.Address, msg []byte) (*crypto.Signature, error)
- func (w *KeystoreWallet) Signers() map[KeyType]Signer
- func (w *KeystoreWallet) Transfer(ctx context.Context, from address.Address, to address.Address, amount string) error
- func (w *KeystoreWallet) Verify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) (bool, error)
- type Option
- type Signer
Constants ¶
const ( KNamePrefix = "wallet-" KDefault = "default" )
Variables ¶
var ErrNoAPI = fmt.Errorf("no filecoin api connected")
Functions ¶
func ActSigType ¶
ActSigType converts a key type to a Filecoin signature type
Types ¶
type Driver ¶
type Driver interface { NewKey(context.Context, KeyType) (address.Address, error) DefaultAddress() address.Address SetDefaultAddress(address.Address) error List() ([]address.Address, error) ImportKey(context.Context, *KeyInfo) (address.Address, error) ExportKey(context.Context, address.Address) (*KeyInfo, error) Sign(context.Context, address.Address, []byte) (*crypto.Signature, error) Verify(context.Context, address.Address, []byte, *crypto.Signature) (bool, error) Balance(context.Context, address.Address) (fil.BigInt, error) Transfer(ctx context.Context, from address.Address, to address.Address, amount string) error Signers() map[KeyType]Signer }
Driver is a lightweight interface to control any available keychain and interact with blockchains
type Key ¶
Key adds the public key and address on top of the private key
func NewKeyFromKeyInfo ¶
NewKeyFromKeyInfo adds public key and address to private key
func NewKeyFromLibp2p ¶
NewKeyFromLibp2p converts a libp2p crypto private key interface into a Key
type KeyInfo ¶
type KeyInfo struct { KType KeyType `json:"Type"` // Had to name it KType as Type() is used already PrivateKey []byte // contains filtered or unexported fields }
KeyInfo stores info about a private key
type KeystoreWallet ¶
type KeystoreWallet struct {
// contains filtered or unexported fields
}
KeystoreWallet wraps an IPFS keystore
func (*KeystoreWallet) DefaultAddress ¶
func (w *KeystoreWallet) DefaultAddress() address.Address
DefaultAddress of the wallet used for receiving payments as provider and paying when retrieving
func (*KeystoreWallet) ExportKey ¶
func (w *KeystoreWallet) ExportKey(_ context.Context, addr address.Address) (*KeyInfo, error)
ExportKey to a private key and key type from an address in the wallet
func (*KeystoreWallet) ImportKey ¶
func (w *KeystoreWallet) ImportKey(_ context.Context, k *KeyInfo) (address.Address, error)
ImportKey in the wallet from a private key and key type
func (*KeystoreWallet) List ¶
func (w *KeystoreWallet) List() ([]address.Address, error)
List all the addresses in the wallet
func (*KeystoreWallet) NewKey ¶
func (w *KeystoreWallet) NewKey(ctx context.Context, kt KeyType) (address.Address, error)
NewKey generates a brand new key for the given type in our wallet and returns the address
func (*KeystoreWallet) SetDefaultAddress ¶
func (w *KeystoreWallet) SetDefaultAddress(addr address.Address) error
SetDefaultAddress for receiving and sending payments as provider or client
func (*KeystoreWallet) Sign ¶
func (w *KeystoreWallet) Sign(ctx context.Context, addr address.Address, msg []byte) (*crypto.Signature, error)
Sign a message with the key associated with the given address. Generates a valid Filecoin signature
func (*KeystoreWallet) Signers ¶
func (w *KeystoreWallet) Signers() map[KeyType]Signer
Signers returns all the signers registered for this wallet
func (*KeystoreWallet) Transfer ¶
func (w *KeystoreWallet) Transfer(ctx context.Context, from address.Address, to address.Address, amount string) error
Transfer from an address in our wallet to any given address FIL amount is passed as a human readable string this methods blocks execution until the transaction was seen on chain
type Option ¶
type Option func(kw *KeystoreWallet)
Option is an optional configuration of the wallet
func WithConfidence ¶
WithConfidence sets the number of epochs before we accept a message as confirmed
type Signer ¶
type Signer interface { GenPrivate() ([]byte, error) ToPublic(pk []byte) ([]byte, error) Sign(pk []byte, msg []byte) ([]byte, error) Verify(sig []byte, a address.Address, msg []byte) error }
Signer encapsulates methods for a given key
func KeyTypeSig ¶
KeyTypeSig selects the signer based on key type