wallet: Move key.go into separate pkg to avoid import loops
This commit is contained in:
parent
d48b629b46
commit
6afb43afbb
@ -47,7 +47,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
)
|
)
|
||||||
@ -240,7 +240,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
|
|||||||
return cid.Undef, fmt.Errorf("failed to marshal proposal: %w", err)
|
return cid.Undef, fmt.Errorf("failed to marshal proposal: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sig, err := sigs.Sign(wallet.ActSigType(preseal.DealClientKey.Type), preseal.DealClientKey.PrivateKey, buf)
|
sig, err := sigs.Sign(key.ActSigType(preseal.DealClientKey.Type), preseal.DealClientKey.PrivateKey, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, fmt.Errorf("failed to sign proposal: %w", err)
|
return cid.Undef, fmt.Errorf("failed to sign proposal: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package wallet
|
package key
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
@ -14,6 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls" // enable bls signatures
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls" // enable bls signatures
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp" // enable secp signatures
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp" // enable secp signatures
|
||||||
@ -28,7 +29,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LocalWallet struct {
|
type LocalWallet struct {
|
||||||
keys map[address.Address]*Key
|
keys map[address.Address]*key.Key
|
||||||
keystore types.KeyStore
|
keystore types.KeyStore
|
||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
@ -41,15 +42,15 @@ type Default interface {
|
|||||||
|
|
||||||
func NewWallet(keystore types.KeyStore) (*LocalWallet, error) {
|
func NewWallet(keystore types.KeyStore) (*LocalWallet, error) {
|
||||||
w := &LocalWallet{
|
w := &LocalWallet{
|
||||||
keys: make(map[address.Address]*Key),
|
keys: make(map[address.Address]*key.Key),
|
||||||
keystore: keystore,
|
keystore: keystore,
|
||||||
}
|
}
|
||||||
|
|
||||||
return w, nil
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func KeyWallet(keys ...*Key) *LocalWallet {
|
func KeyWallet(keys ...*key.Key) *LocalWallet {
|
||||||
m := make(map[address.Address]*Key)
|
m := make(map[address.Address]*key.Key)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
m[key.Address] = key
|
m[key.Address] = key
|
||||||
}
|
}
|
||||||
@ -68,10 +69,10 @@ func (w *LocalWallet) WalletSign(ctx context.Context, addr address.Address, msg
|
|||||||
return nil, xerrors.Errorf("signing using key '%s': %w", addr.String(), types.ErrKeyInfoNotFound)
|
return nil, xerrors.Errorf("signing using key '%s': %w", addr.String(), types.ErrKeyInfoNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sigs.Sign(ActSigType(ki.Type), ki.PrivateKey, msg)
|
return sigs.Sign(key.ActSigType(ki.Type), ki.PrivateKey, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *LocalWallet) findKey(addr address.Address) (*Key, error) {
|
func (w *LocalWallet) findKey(addr address.Address) (*key.Key, error) {
|
||||||
w.lk.Lock()
|
w.lk.Lock()
|
||||||
defer w.lk.Unlock()
|
defer w.lk.Unlock()
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ func (w *LocalWallet) findKey(addr address.Address) (*Key, error) {
|
|||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("getting from keystore: %w", err)
|
return nil, xerrors.Errorf("getting from keystore: %w", err)
|
||||||
}
|
}
|
||||||
k, err = NewKey(ki)
|
k, err = key.NewKey(ki)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("decoding from keystore: %w", err)
|
return nil, xerrors.Errorf("decoding from keystore: %w", err)
|
||||||
}
|
}
|
||||||
@ -149,7 +150,7 @@ func (w *LocalWallet) WalletImport(ctx context.Context, ki *types.KeyInfo) (addr
|
|||||||
w.lk.Lock()
|
w.lk.Lock()
|
||||||
defer w.lk.Unlock()
|
defer w.lk.Unlock()
|
||||||
|
|
||||||
k, err := NewKey(*ki)
|
k, err := key.NewKey(*ki)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, xerrors.Errorf("failed to make key: %w", err)
|
return address.Undef, xerrors.Errorf("failed to make key: %w", err)
|
||||||
}
|
}
|
||||||
@ -203,7 +204,7 @@ func (w *LocalWallet) GetDefault() (address.Address, error) {
|
|||||||
return address.Undef, xerrors.Errorf("failed to get default key: %w", err)
|
return address.Undef, xerrors.Errorf("failed to get default key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
k, err := NewKey(ki)
|
k, err := key.NewKey(ki)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, xerrors.Errorf("failed to read default key from keystore: %w", err)
|
return address.Undef, xerrors.Errorf("failed to read default key from keystore: %w", err)
|
||||||
}
|
}
|
||||||
@ -237,7 +238,7 @@ func (w *LocalWallet) WalletNew(ctx context.Context, typ types.KeyType) (address
|
|||||||
w.lk.Lock()
|
w.lk.Lock()
|
||||||
defer w.lk.Unlock()
|
defer w.lk.Unlock()
|
||||||
|
|
||||||
k, err := GenerateKey(typ)
|
k, err := key.GenerateKey(typ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-storage/storage"
|
"github.com/filecoin-project/specs-storage/storage"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
|
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs"
|
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
@ -36,7 +36,7 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("preseal")
|
var log = logging.Logger("preseal")
|
||||||
|
|
||||||
func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.SectorNumber, sectors int, sbroot string, preimage []byte, key *types.KeyInfo, fakeSectors bool) (*genesis.Miner, *types.KeyInfo, error) {
|
func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.SectorNumber, sectors int, sbroot string, preimage []byte, ki *types.KeyInfo, fakeSectors bool) (*genesis.Miner, *types.KeyInfo, error) {
|
||||||
mid, err := address.IDFromAddress(maddr)
|
mid, err := address.IDFromAddress(maddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@ -84,14 +84,14 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect
|
|||||||
sealedSectors = append(sealedSectors, preseal)
|
sealedSectors = append(sealedSectors, preseal)
|
||||||
}
|
}
|
||||||
|
|
||||||
var minerAddr *wallet.Key
|
var minerAddr *key.Key
|
||||||
if key != nil {
|
if ki != nil {
|
||||||
minerAddr, err = wallet.NewKey(*key)
|
minerAddr, err = key.NewKey(*ki)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
minerAddr, err = wallet.GenerateKey(types.KTBLS)
|
minerAddr, err = key.GenerateKey(types.KTBLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDeals(m *genesis.Miner, k *wallet.Key, maddr address.Address, ssize abi.SectorSize) error {
|
func createDeals(m *genesis.Miner, k *key.Key, maddr address.Address, ssize abi.SectorSize) error {
|
||||||
for i, sector := range m.Sectors {
|
for i, sector := range m.Sectors {
|
||||||
label, err := market8.NewLabelFromString(fmt.Sprintf("%d", i))
|
label, err := market8.NewLabelFromString(fmt.Sprintf("%d", i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||||
"github.com/filecoin-project/lotus/node/modules"
|
"github.com/filecoin-project/lotus/node/modules"
|
||||||
@ -317,7 +318,7 @@ var keyinfoInfoCmd = &cli.Command{
|
|||||||
case types.KTSecp256k1, types.KTBLS:
|
case types.KTSecp256k1, types.KTBLS:
|
||||||
kio.Type = keyInfo.Type
|
kio.Type = keyInfo.Type
|
||||||
|
|
||||||
key, err := wallet.NewKey(keyInfo)
|
key, err := key.NewKey(keyInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -402,7 +403,7 @@ var keyinfoNewCmd = &cli.Command{
|
|||||||
|
|
||||||
break
|
break
|
||||||
case types.KTSecp256k1, types.KTBLS:
|
case types.KTSecp256k1, types.KTBLS:
|
||||||
key, err := wallet.GenerateKey(keyType)
|
key, err := key.GenerateKey(keyType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ActorType string
|
type ActorType string
|
||||||
@ -26,7 +26,7 @@ type PreSeal struct {
|
|||||||
CommD cid.Cid
|
CommD cid.Cid
|
||||||
SectorID abi.SectorNumber
|
SectorID abi.SectorNumber
|
||||||
Deal market8.DealProposal
|
Deal market8.DealProposal
|
||||||
DealClientKey *wallet.Key
|
DealClientKey *key.Key
|
||||||
ProofType abi.RegisteredSealProof
|
ProofType abi.RegisteredSealProof
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/filecoin-project/lotus/markets/storageadapter"
|
"github.com/filecoin-project/lotus/markets/storageadapter"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
@ -41,7 +41,7 @@ func TestPublishDealsBatching(t *testing.T) {
|
|||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
publisherKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
publisherKey, err := key.GenerateKey(types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
opts := node.Options(
|
opts := node.Options(
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/filecoin-project/lotus/markets/storageadapter"
|
"github.com/filecoin-project/lotus/markets/storageadapter"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
@ -42,7 +42,7 @@ func TestDealsRetryLackOfFunds(t *testing.T) {
|
|||||||
// Allow 8MB sectors
|
// Allow 8MB sectors
|
||||||
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
||||||
|
|
||||||
publishStorageDealKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
publishStorageDealKey, err := key.GenerateKey(types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
opts := node.Options(
|
opts := node.Options(
|
||||||
@ -118,7 +118,7 @@ func TestDealsRetryLackOfFunds_blockInPublishDeal(t *testing.T) {
|
|||||||
// Allow 8MB sectors
|
// Allow 8MB sectors
|
||||||
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
||||||
|
|
||||||
publishStorageDealKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
publishStorageDealKey, err := key.GenerateKey(types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
opts := node.Options(
|
opts := node.Options(
|
||||||
@ -191,7 +191,7 @@ func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) {
|
|||||||
// Allow 8MB sectors
|
// Allow 8MB sectors
|
||||||
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
||||||
|
|
||||||
publishStorageDealKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
publishStorageDealKey, err := key.GenerateKey(types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
opts := node.Options(
|
opts := node.Options(
|
||||||
|
@ -42,7 +42,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-worker/sealworker"
|
"github.com/filecoin-project/lotus/cmd/lotus-worker/sealworker"
|
||||||
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
|
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
|
||||||
@ -183,7 +183,7 @@ func (n *Ensemble) FullNode(full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
|||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
key, err := wallet.GenerateKey(types.KTBLS)
|
key, err := key.GenerateKey(types.KTBLS)
|
||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
|
|
||||||
if !n.bootstrapped && !options.balance.IsZero() {
|
if !n.bootstrapped && !options.balance.IsZero() {
|
||||||
@ -256,7 +256,7 @@ func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeO
|
|||||||
genm.PeerId = peerId
|
genm.PeerId = peerId
|
||||||
|
|
||||||
// create an owner key, and assign it some FIL.
|
// create an owner key, and assign it some FIL.
|
||||||
ownerKey, err = wallet.NewKey(*k)
|
ownerKey, err = key.NewKey(*k)
|
||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
|
|
||||||
genacc := genesis.Actor{
|
genacc := genesis.Actor{
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EnsembleOpt func(opts *ensembleOpts) error
|
type EnsembleOpt func(opts *ensembleOpts) error
|
||||||
|
|
||||||
type genesisAccount struct {
|
type genesisAccount struct {
|
||||||
key *wallet.Key
|
key *key.Key
|
||||||
initialBalance abi.TokenAmount
|
initialBalance abi.TokenAmount
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func MockProofs() EnsembleOpt {
|
|||||||
|
|
||||||
// RootVerifier specifies the key to be enlisted as the verified registry root,
|
// RootVerifier specifies the key to be enlisted as the verified registry root,
|
||||||
// as well as the initial balance to be attributed during genesis.
|
// as well as the initial balance to be attributed during genesis.
|
||||||
func RootVerifier(key *wallet.Key, balance abi.TokenAmount) EnsembleOpt {
|
func RootVerifier(key *key.Key, balance abi.TokenAmount) EnsembleOpt {
|
||||||
return func(opts *ensembleOpts) error {
|
return func(opts *ensembleOpts) error {
|
||||||
opts.verifiedRoot.key = key
|
opts.verifiedRoot.key = key
|
||||||
opts.verifiedRoot.initialBalance = balance
|
opts.verifiedRoot.initialBalance = balance
|
||||||
@ -56,7 +56,7 @@ func RootVerifier(key *wallet.Key, balance abi.TokenAmount) EnsembleOpt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Account sets up an account at genesis with the specified key and balance.
|
// Account sets up an account at genesis with the specified key and balance.
|
||||||
func Account(key *wallet.Key, balance abi.TokenAmount) EnsembleOpt {
|
func Account(key *key.Key, balance abi.TokenAmount) EnsembleOpt {
|
||||||
return func(opts *ensembleOpts) error {
|
return func(opts *ensembleOpts) error {
|
||||||
opts.accounts = append(opts.accounts, genesisAccount{
|
opts.accounts = append(opts.accounts, genesisAccount{
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestFullNode represents a full node enrolled in an Ensemble.
|
// TestFullNode represents a full node enrolled in an Ensemble.
|
||||||
@ -27,7 +27,7 @@ type TestFullNode struct {
|
|||||||
// ListenAddr is the address on which an API server is listening, if an
|
// ListenAddr is the address on which an API server is listening, if an
|
||||||
// API server is created for this Node.
|
// API server is created for this Node.
|
||||||
ListenAddr multiaddr.Multiaddr
|
ListenAddr multiaddr.Multiaddr
|
||||||
DefaultKey *wallet.Key
|
DefaultKey *key.Key
|
||||||
|
|
||||||
options nodeOpts
|
options nodeOpts
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
@ -72,7 +72,7 @@ type TestMiner struct {
|
|||||||
ListenAddr multiaddr.Multiaddr
|
ListenAddr multiaddr.Multiaddr
|
||||||
|
|
||||||
ActorAddr address.Address
|
ActorAddr address.Address
|
||||||
OwnerKey *wallet.Key
|
OwnerKey *key.Key
|
||||||
MineOne func(context.Context, miner.MineReq) error
|
MineOne func(context.Context, miner.MineReq) error
|
||||||
Stop func(context.Context) error
|
Stop func(context.Context) error
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/storage-sealing/sealiface"
|
"github.com/filecoin-project/lotus/extern/storage-sealing/sealiface"
|
||||||
@ -31,7 +31,7 @@ type nodeOpts struct {
|
|||||||
lite bool
|
lite bool
|
||||||
sectors int
|
sectors int
|
||||||
rpc bool
|
rpc bool
|
||||||
ownerKey *wallet.Key
|
ownerKey *key.Key
|
||||||
extraNodeOpts []node.Option
|
extraNodeOpts []node.Option
|
||||||
|
|
||||||
subsystems MinerSubsystem
|
subsystems MinerSubsystem
|
||||||
@ -165,7 +165,7 @@ func ThroughRPC() NodeOpt {
|
|||||||
|
|
||||||
// OwnerAddr sets the owner address of a miner. Only relevant when creating
|
// OwnerAddr sets the owner address of a miner. Only relevant when creating
|
||||||
// a miner.
|
// a miner.
|
||||||
func OwnerAddr(wk *wallet.Key) NodeOpt {
|
func OwnerAddr(wk *key.Key) NodeOpt {
|
||||||
return func(opts *nodeOpts) error {
|
return func(opts *nodeOpts) error {
|
||||||
opts.ownerKey = wk
|
opts.ownerKey = wk
|
||||||
return nil
|
return nil
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/filecoin-project/lotus/node/impl"
|
"github.com/filecoin-project/lotus/node/impl"
|
||||||
)
|
)
|
||||||
@ -35,13 +35,13 @@ func TestVerifiedClientTopUp(t *testing.T) {
|
|||||||
|
|
||||||
test := func(nv network.Version, shouldWork bool) func(*testing.T) {
|
test := func(nv network.Version, shouldWork bool) func(*testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
rootKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
rootKey, err := key.GenerateKey(types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
verifierKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
verifierKey, err := key.GenerateKey(types.KTSecp256k1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
verifiedClientKey, err := wallet.GenerateKey(types.KTBLS)
|
verifiedClientKey, err := key.GenerateKey(types.KTBLS)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
bal, err := types.ParseFIL("100fil")
|
bal, err := types.ParseFIL("100fil")
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
||||||
)
|
)
|
||||||
@ -24,7 +24,7 @@ func TestRoundtrip(t *testing.T) {
|
|||||||
Type: types.KTBLS,
|
Type: types.KTBLS,
|
||||||
PrivateKey: pk,
|
PrivateKey: pk,
|
||||||
}
|
}
|
||||||
k, err := wallet.NewKey(ki)
|
k, err := key.NewKey(ki)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
p := []byte("potato")
|
p := []byte("potato")
|
||||||
|
@ -13,13 +13,13 @@ import (
|
|||||||
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
|
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
|
||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PreSeal(spt abi.RegisteredSealProof, maddr address.Address, sectors int) (*genesis.Miner, *types.KeyInfo, error) {
|
func PreSeal(spt abi.RegisteredSealProof, maddr address.Address, sectors int) (*genesis.Miner, *types.KeyInfo, error) {
|
||||||
k, err := wallet.GenerateKey(types.KTBLS)
|
k, err := key.GenerateKey(types.KTBLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
"github.com/filecoin-project/lotus/chain/beacon"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/metrics"
|
"github.com/filecoin-project/lotus/metrics"
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
@ -36,11 +36,11 @@ type LotusNode struct {
|
|||||||
FullApi api.FullNode
|
FullApi api.FullNode
|
||||||
MinerApi api.StorageMiner
|
MinerApi api.StorageMiner
|
||||||
StopFn node.StopFunc
|
StopFn node.StopFunc
|
||||||
Wallet *wallet.Key
|
Wallet *key.Key
|
||||||
MineOne func(context.Context, miner.MineReq) error
|
MineOne func(context.Context, miner.MineReq) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *LotusNode) setWallet(ctx context.Context, walletKey *wallet.Key) error {
|
func (n *LotusNode) setWallet(ctx context.Context, walletKey *key.Key) error {
|
||||||
_, err := n.FullApi.WalletImport(ctx, &walletKey.KeyInfo)
|
_, err := n.FullApi.WalletImport(ctx, &walletKey.KeyInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
)
|
)
|
||||||
@ -44,7 +44,7 @@ func PrepareClient(t *TestEnvironment) (*LotusClient, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first create a wallet
|
// first create a wallet
|
||||||
walletKey, err := wallet.GenerateKey(types.KTBLS)
|
walletKey, err := key.GenerateKey(types.KTBLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
genesis_chain "github.com/filecoin-project/lotus/chain/gen/genesis"
|
genesis_chain "github.com/filecoin-project/lotus/chain/gen/genesis"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
@ -78,7 +78,7 @@ func PrepareMiner(t *TestEnvironment) (*LotusMiner, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first create a wallet
|
// first create a wallet
|
||||||
walletKey, err := wallet.GenerateKey(types.KTBLS)
|
walletKey, err := key.GenerateKey(types.KTBLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user