Remote wallet backends

This commit is contained in:
Łukasz Magiera
2020-09-05 21:39:09 +02:00
parent f90cfda2e6
commit 780f6dba34
14 changed files with 360 additions and 12 deletions
+5 -1
View File
@@ -40,6 +40,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/chain/wallet/remotewallet"
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
@@ -235,7 +236,7 @@ func Online() Option {
Override(new(*store.ChainStore), modules.ChainStore),
Override(new(*stmgr.StateManager), stmgr.NewStateManager),
Override(new(*wallet.LocalWallet), wallet.NewWallet),
Override(new(wallet.Wallet), From(new(*wallet.LocalWallet))),
Override(new(api.WalletAPI), From(new(*wallet.LocalWallet))),
Override(new(wallet.Default), From(new(*wallet.LocalWallet))),
Override(new(dtypes.ChainGCLocker), blockstore.NewGCLocker),
@@ -419,6 +420,9 @@ func ConfigFullNode(c interface{}) Option {
If(cfg.Metrics.HeadNotifs,
Override(HeadMetricsKey, metrics.SendHeadNotifs(cfg.Metrics.Nickname)),
),
If(cfg.Wallet.RemoteBackend != "",
Override(new(api.WalletAPI), remotewallet.SetupRemoteWallet(cfg.Wallet.RemoteBackend)),
),
)
}
+5
View File
@@ -22,6 +22,7 @@ type FullNode struct {
Common
Client Client
Metrics Metrics
Wallet Wallet
}
// // Common
@@ -105,6 +106,10 @@ type Client struct {
IpfsUseForRetrieval bool
}
type Wallet struct {
RemoteBackend string
}
func defCommon() Common {
return Common{
API: API{
+3 -2
View File
@@ -10,6 +10,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
@@ -21,7 +22,7 @@ type WalletAPI struct {
StateManager *stmgr.StateManager
Default wallet.Default
wallet.Wallet
api.WalletAPI
}
func (a *WalletAPI) WalletBalance(ctx context.Context, addr address.Address) (types.BigInt, error) {
@@ -50,7 +51,7 @@ func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, ms
if err != nil {
return nil, xerrors.Errorf("failed to resolve ID address: %w", keyAddr)
}
return a.Wallet.WalletSignMessage(ctx, keyAddr, msg)
return a.WalletAPI.WalletSignMessage(ctx, keyAddr, msg)
}
func (a *WalletAPI) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) bool {
+9
View File
@@ -44,6 +44,7 @@ const (
FullNode RepoType = iota
StorageMiner
Worker
Wallet
)
func defConfForType(t RepoType) interface{} {
@@ -54,6 +55,8 @@ func defConfForType(t RepoType) interface{} {
return config.DefaultStorageMiner()
case Worker:
return &struct{}{}
case Wallet:
return &struct{}{}
default:
panic(fmt.Sprintf("unknown RepoType(%d)", int(t)))
}
@@ -87,6 +90,12 @@ func (fsr *FsRepo) Exists() (bool, error) {
notexist := os.IsNotExist(err)
if notexist {
err = nil
_, err = os.Stat(filepath.Join(fsr.path, fsKeystore))
notexist = os.IsNotExist(err)
if notexist {
err = nil
}
}
return !notexist, err
}