wallet

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0, MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountLegacyKeys added in v1.0.0

func CountLegacyKeys(db *gorm.DB) int64

counts actors that still have a non-empty private_key in the database. returns 0 if the column has been dropped.

func DropPrivateKeyColumn added in v1.0.0

func DropPrivateKeyColumn(db *gorm.DB) error

drops the private_key column from the actors table. caller is responsible for confirming this is desired.

func GetKeystoreDir added in v1.0.0

func GetKeystoreDir() string

returns default keystore directory path TODO: make configurable via config file

func GetOrCreateActor added in v1.0.0

func GetOrCreateActor(
	ctx context.Context,
	db *gorm.DB,
	lotusClient jsonrpc.RPCClient,
	wallet *model.Wallet,
) (*model.Actor, error)

lazy actor lookup and creation for a wallet workflow: import wallet offline → fund externally → first deal queries on-chain actor returns existing actor if wallet.ActorID already set, otherwise queries lotus and creates record

func HasPrivateKeyColumn added in v1.0.0

func HasPrivateKeyColumn(db *gorm.DB) bool

func SignWithWallet added in v1.0.0

func SignWithWallet(ks keystore.KeyStore, wallet model.Wallet, msg []byte) (*crypto.Signature, error)

loads private key from keystore and signs a filecoin message

Types

type DefaultHandler added in v0.4.0

type DefaultHandler struct{}

func (DefaultHandler) AttachHandler added in v0.4.0

func (DefaultHandler) AttachHandler(
	ctx context.Context,
	db *gorm.DB,
	preparationID string,
	walletAddressOrID string,
) (*model.Preparation, error)

attaches wallet to preparation for deal-making accepts wallet address or wallet ID

func (DefaultHandler) DetachHandler added in v0.4.0

func (DefaultHandler) DetachHandler(
	ctx context.Context,
	db *gorm.DB,
	preparationID string,
	walletAddressOrID string,
) (*model.Preparation, error)

detaches wallet from preparation accepts wallet address or ID

func (DefaultHandler) ImportKeystoreHandler added in v1.0.0

func (DefaultHandler) ImportKeystoreHandler(
	ctx context.Context,
	db *gorm.DB,
	ks keystore.KeyStore,
	request ImportKeystoreRequest,
) (*model.Wallet, error)

imports wallet by saving private key to keystore and creating wallet record does not require actor to exist on-chain - wallet can be imported offline uses external keystore instead of storing keys in database

func (DefaultHandler) ListAttachedHandler added in v0.4.0

func (DefaultHandler) ListAttachedHandler(
	ctx context.Context,
	db *gorm.DB,
	preparationID string,
) ([]model.Wallet, error)

func (DefaultHandler) ListHandler added in v0.4.0

func (DefaultHandler) ListHandler(
	ctx context.Context,
	db *gorm.DB,
) ([]model.Wallet, error)

ListHandler retrieves a list of all the wallets stored in the database.

Parameters:

  • ctx: The context for database transactions and other operations.
  • db: A pointer to the gorm.DB instance representing the database connection.

Returns:

  • A slice containing all Wallet models from the database.
  • An error, if any occurred during the database fetch operation.

func (DefaultHandler) RemoveHandler added in v0.4.0

func (DefaultHandler) RemoveHandler(
	ctx context.Context,
	db *gorm.DB,
	ks keystore.KeyStore,
	address string,
) error

removes wallet record and keystore file does not remove the associated actor — actors may be shared or tracked independently

type ExportKeysResult added in v1.0.0

type ExportKeysResult struct {
	Exported int      // actors whose keys were saved to keystore + wallet record created
	Skipped  int      // actors whose wallet already exists (by address match)
	Errors   []string // actors that failed (logged but don't abort)
}

ExportKeysResult reports what export-keys did for each actor

func ExportKeysHandler added in v1.0.0

func ExportKeysHandler(
	ctx context.Context,
	db *gorm.DB,
	ks keystore.KeyStore,
) (*ExportKeysResult, error)

exports private keys from the legacy Actor.PrivateKey column into the filesystem keystore, creating Wallet records where needed. idempotent -- skips actors whose address already has a Wallet record. does not delete Actor.PrivateKey; caller decides when to drop the column.

type Handler added in v0.4.0

type Handler interface {
	ImportKeystoreHandler(
		ctx context.Context,
		db *gorm.DB,
		ks keystore.KeyStore,
		request ImportKeystoreRequest,
	) (*model.Wallet, error)
	AttachHandler(
		ctx context.Context,
		db *gorm.DB,
		preparation string,
		wallet string,
	) (*model.Preparation, error)
	DetachHandler(
		ctx context.Context,
		db *gorm.DB,
		preparation string,
		wallet string,
	) (*model.Preparation, error)
	ListHandler(
		ctx context.Context,
		db *gorm.DB,
	) ([]model.Wallet, error)
	ListAttachedHandler(
		ctx context.Context,
		db *gorm.DB,
		preparation string,
	) ([]model.Wallet, error)
	RemoveHandler(
		ctx context.Context,
		db *gorm.DB,
		ks keystore.KeyStore,
		address string,
	) error
}
var Default Handler = &DefaultHandler{}

type ImportKeystoreRequest added in v1.0.0

type ImportKeystoreRequest struct {
	PrivateKey string `json:"privateKey"` // lotus wallet export format
	Name       string `json:"name"`       // optional human-readable name
}

type MockWallet added in v0.5.0

type MockWallet struct {
	mock.Mock
}

func (*MockWallet) AttachHandler added in v0.5.0

func (m *MockWallet) AttachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)

func (*MockWallet) DetachHandler added in v0.5.0

func (m *MockWallet) DetachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)

func (*MockWallet) ImportKeystoreHandler added in v1.0.0

func (m *MockWallet) ImportKeystoreHandler(ctx context.Context, db *gorm.DB, ks keystore.KeyStore, request ImportKeystoreRequest) (*model.Wallet, error)

func (*MockWallet) ListAttachedHandler added in v0.5.0

func (m *MockWallet) ListAttachedHandler(ctx context.Context, db *gorm.DB, preparation string) ([]model.Wallet, error)

func (*MockWallet) ListHandler added in v0.5.0

func (m *MockWallet) ListHandler(ctx context.Context, db *gorm.DB) ([]model.Wallet, error)

func (*MockWallet) RemoveHandler added in v0.5.0

func (m *MockWallet) RemoveHandler(ctx context.Context, db *gorm.DB, ks keystore.KeyStore, address string) error

Jump to

Keyboard shortcuts

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