Documentation
¶
Index ¶
- func CountLegacyKeys(db *gorm.DB) int64
- func DropPrivateKeyColumn(db *gorm.DB) error
- func GetKeystoreDir() string
- func GetOrCreateActor(ctx context.Context, db *gorm.DB, lotusClient jsonrpc.RPCClient, ...) (*model.Actor, error)
- func HasPrivateKeyColumn(db *gorm.DB) bool
- func SignWithWallet(ks keystore.KeyStore, wallet model.Wallet, msg []byte) (*crypto.Signature, error)
- type DefaultHandler
- func (DefaultHandler) AttachHandler(ctx context.Context, db *gorm.DB, preparationID string, ...) (*model.Preparation, error)
- func (DefaultHandler) DetachHandler(ctx context.Context, db *gorm.DB, preparationID string, ...) (*model.Preparation, error)
- func (DefaultHandler) ImportKeystoreHandler(ctx context.Context, db *gorm.DB, ks keystore.KeyStore, ...) (*model.Wallet, error)
- func (DefaultHandler) ListAttachedHandler(ctx context.Context, db *gorm.DB, preparationID string) ([]model.Wallet, error)
- func (DefaultHandler) ListHandler(ctx context.Context, db *gorm.DB) ([]model.Wallet, error)
- func (DefaultHandler) RemoveHandler(ctx context.Context, db *gorm.DB, ks keystore.KeyStore, address string) error
- type ExportKeysResult
- type Handler
- type ImportKeystoreRequest
- type MockWallet
- func (m *MockWallet) AttachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)
- func (m *MockWallet) DetachHandler(ctx context.Context, db *gorm.DB, preparation string, wallet string) (*model.Preparation, error)
- func (m *MockWallet) ImportKeystoreHandler(ctx context.Context, db *gorm.DB, ks keystore.KeyStore, ...) (*model.Wallet, error)
- func (m *MockWallet) ListAttachedHandler(ctx context.Context, db *gorm.DB, preparation string) ([]model.Wallet, error)
- func (m *MockWallet) ListHandler(ctx context.Context, db *gorm.DB) ([]model.Wallet, error)
- func (m *MockWallet) RemoveHandler(ctx context.Context, db *gorm.DB, ks keystore.KeyStore, address string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountLegacyKeys ¶ added in v1.0.0
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
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
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) ListHandler ¶ added in v0.4.0
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.
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 MockWallet ¶ added in v0.5.0
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)