wallet

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Overview

Package wallet provides an encrypted-at-rest local keystore plus a signing facade for the three Filecoin signature types Lantern supports:

  • BLS (G1 pubkey, G2 sig) via crypto/sigs/bls (pure-Go gnark backend)
  • secp256k1 via crypto/sigs/secp (lifted from Lotus, pure-Go)
  • delegated (Ethereum-shaped f4 addresses) via crypto/sigs/delegated (lifted from Lotus, pure-Go)

Keystore on-disk format is compatible with Lotus' lib/keystore (one JSON file per key, AES-GCM-wrapped with a passphrase-derived key) so users can import/export to and from a Lotus install.

Subpackages:

  • wallet/keystore — disk-backed encrypted key store
  • wallet/mnemonic — BIP-39 mnemonic <-> seed

The top-level wallet package wires these together behind a small goroutine-safe Wallet type that the RPC handlers (WalletNew, WalletSign, WalletList, ...) call into.

No CGo. No filecoin-ffi.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDefault = errors.New("wallet: no default address set")

ErrNoDefault is returned when Default() is called with an empty wallet.

Functions

This section is empty.

Types

type KeyInfo

type KeyInfo = keystore.KeyInfo

KeyInfo is the Lotus-compatible export shape. Lotus uses {Type: string, PrivateKey: []byte (base64 JSON)}.

type KeyType

type KeyType string

KeyType is a stable string identifier for one of the three key types. Mirrors Lotus' lib/wallet/key.KeyType values so import/export with Lotus JSON KeyInfo files works.

const (
	KTBLS       KeyType = "bls"
	KTSecp256k1 KeyType = "secp256k1"
	KTDelegated KeyType = "delegated"
)

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

Wallet wraps an encrypted keystore and exposes Lotus-compatible operations.

func New

func New(_ context.Context, dir, passphrase string) (*Wallet, error)

New opens (or creates) a wallet at the given keystore directory.

func (*Wallet) Default

func (w *Wallet) Default(_ context.Context) (address.Address, error)

Default returns the default address, or ErrNoDefault if none is set.

func (*Wallet) Delete

func (w *Wallet) Delete(_ context.Context, addr address.Address) error

Delete removes addr's key from the store.

func (*Wallet) Export

func (w *Wallet) Export(_ context.Context, addr address.Address) (*KeyInfo, error)

Export returns a Lotus-compatible KeyInfo blob for backup/migration.

func (*Wallet) Has

func (w *Wallet) Has(_ context.Context, addr address.Address) (bool, error)

Has reports whether the wallet holds the private key for addr.

func (*Wallet) Import

func (w *Wallet) Import(_ context.Context, ki *KeyInfo) (address.Address, error)

Import inserts a Lotus KeyInfo, returns the derived address.

func (*Wallet) List

func (w *Wallet) List(_ context.Context) ([]address.Address, error)

List returns all addresses in the wallet.

func (*Wallet) NewAddress

func (w *Wallet) NewAddress(_ context.Context, kt KeyType) (address.Address, error)

NewAddress generates a new key of the requested type, stores it, and returns its address.

func (*Wallet) SetDefault

func (w *Wallet) SetDefault(_ context.Context, addr address.Address) error

SetDefault marks addr as the default address.

func (*Wallet) Sign

func (w *Wallet) Sign(_ context.Context, addr address.Address, msg []byte) (*gscrypto.Signature, error)

Sign signs raw bytes with addr's key. msg is hashed/encoded by the appropriate signer per Filecoin convention (BLS hash-to-G2, secp/keccak over blake2b, etc.).

func (*Wallet) SignatureType

func (w *Wallet) SignatureType(_ context.Context, addr address.Address) (gscrypto.SigType, error)

SignatureType reports the signature type for the key at addr (used by callers that need to pick BLS aggregate vs secp single-sig path).

Directories

Path Synopsis
Package keystore provides a disk-backed, passphrase-encrypted key store.
Package keystore provides a disk-backed, passphrase-encrypted key store.

Jump to

Keyboard shortcuts

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