diff --git a/chain/wallet/wallet.go b/chain/wallet/wallet.go index 925547ea802..1f3329498cf 100644 --- a/chain/wallet/wallet.go +++ b/chain/wallet/wallet.go @@ -272,6 +272,7 @@ func (w *LocalWallet) WalletHas(ctx context.Context, addr address.Address) (bool func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) error { k, err := w.findKey(addr) + if err != nil { return xerrors.Errorf("failed to delete key %s : %w", addr, err) } @@ -279,6 +280,9 @@ func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) er return nil // already not there } + w.lk.Lock() + defer w.lk.Unlock() + 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) } @@ -295,6 +299,8 @@ func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) er // TODO: Does this always error in the not-found case? Just ignoring an error return for now. _ = w.keystore.Delete(KNamePrefix + tAddr) + delete(w.keys, addr) + return nil }