Merge remote-tracking branch 'origin/master' into next
This commit is contained in:
commit
3b56288a5e
@ -101,6 +101,7 @@ type FullNode interface {
|
|||||||
WalletSetDefault(context.Context, address.Address) error
|
WalletSetDefault(context.Context, address.Address) error
|
||||||
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
|
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
|
||||||
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
||||||
|
WalletDelete(context.Context, address.Address) error
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ type FullNodeStruct struct {
|
|||||||
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
|
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
|
||||||
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
||||||
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
||||||
|
WalletDelete func(context.Context, address.Address) error `perm:"write"`
|
||||||
|
|
||||||
ClientImport func(ctx context.Context, ref api.FileRef) (cid.Cid, error) `perm:"admin"`
|
ClientImport func(ctx context.Context, ref api.FileRef) (cid.Cid, error) `perm:"admin"`
|
||||||
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
||||||
@ -438,6 +439,10 @@ func (c *FullNodeStruct) WalletImport(ctx context.Context, ki *types.KeyInfo) (a
|
|||||||
return c.Internal.WalletImport(ctx, ki)
|
return c.Internal.WalletImport(ctx, ki)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) WalletDelete(ctx context.Context, addr address.Address) error {
|
||||||
|
return c.Internal.WalletDelete(ctx, addr)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
func (c *FullNodeStruct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
||||||
return c.Internal.MpoolGetNonce(ctx, addr)
|
return c.Internal.MpoolGetNonce(ctx, addr)
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ var log = logging.Logger("wallet")
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
KNamePrefix = "wallet-"
|
KNamePrefix = "wallet-"
|
||||||
|
KTrashPrefix = "trash-"
|
||||||
KDefault = "default"
|
KDefault = "default"
|
||||||
KTBLS = "bls"
|
KTBLS = "bls"
|
||||||
KTSecp256k1 = "secp256k1"
|
KTSecp256k1 = "secp256k1"
|
||||||
@ -230,6 +231,23 @@ func (w *Wallet) HasKey(addr address.Address) (bool, error) {
|
|||||||
return k != nil, nil
|
return k != nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *Wallet) DeleteKey(addr address.Address) error {
|
||||||
|
k, err := w.findKey(addr)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("failed to delete key %s : %w", addr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := w.keystore.Put(KTrashPrefix+k.Address.String(), k.KeyInfo); err != nil {
|
||||||
|
return xerrors.Errorf("failed to mark key %s as trashed: %w", addr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := w.keystore.Delete(KNamePrefix + k.Address.String()); err != nil {
|
||||||
|
return xerrors.Errorf("failed to delete key %s: %w", addr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type Key struct {
|
type Key struct {
|
||||||
types.KeyInfo
|
types.KeyInfo
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ var walletCmd = &cli.Command{
|
|||||||
walletSetDefault,
|
walletSetDefault,
|
||||||
walletSign,
|
walletSign,
|
||||||
walletVerify,
|
walletVerify,
|
||||||
|
walletDelete,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,3 +376,28 @@ var walletVerify = &cli.Command{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var walletDelete = &cli.Command{
|
||||||
|
Name: "delete",
|
||||||
|
Usage: "Delete an account from the wallet",
|
||||||
|
ArgsUsage: "<address> ",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
|
if !cctx.Args().Present() || cctx.NArg() != 1 {
|
||||||
|
return fmt.Errorf("must specify address to delete")
|
||||||
|
}
|
||||||
|
|
||||||
|
addr, err := address.NewFromString(cctx.Args().First())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.WalletDelete(ctx, addr)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
@ -800,9 +800,7 @@ func (a *StateAPI) StateMinerAvailableBalance(ctx context.Context, maddr address
|
|||||||
return types.EmptyInt, err
|
return types.EmptyInt, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: !!!! Use method that doesnt trigger additional state mutations, this is going to cause lots of objects to be created and written to disk
|
vested, err := st.CheckVestedFunds(as, ts.Height())
|
||||||
log.Warnf("calling inefficient unlock vested funds method, fixme")
|
|
||||||
vested, err := st.UnlockVestedFunds(as, ts.Height())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.EmptyInt, err
|
return types.EmptyInt, err
|
||||||
}
|
}
|
||||||
|
@ -76,3 +76,7 @@ func (a *WalletAPI) WalletExport(ctx context.Context, addr address.Address) (*ty
|
|||||||
func (a *WalletAPI) WalletImport(ctx context.Context, ki *types.KeyInfo) (address.Address, error) {
|
func (a *WalletAPI) WalletImport(ctx context.Context, ki *types.KeyInfo) (address.Address, error) {
|
||||||
return a.Wallet.Import(ki)
|
return a.Wallet.Import(ki)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *WalletAPI) WalletDelete(ctx context.Context, addr address.Address) error {
|
||||||
|
return a.Wallet.DeleteKey(addr)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user