Fix panic in wallet export when key is not found
This commit is contained in:
parent
651522cbaa
commit
4fa6afad13
@ -141,6 +141,9 @@ func (w *LocalWallet) WalletExport(ctx context.Context, addr address.Address) (*
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to find key to export: %w", err)
|
return nil, xerrors.Errorf("failed to find key to export: %w", err)
|
||||||
}
|
}
|
||||||
|
if k == nil {
|
||||||
|
return nil, xerrors.Errorf("key not found")
|
||||||
|
}
|
||||||
|
|
||||||
return &k.KeyInfo, nil
|
return &k.KeyInfo, nil
|
||||||
}
|
}
|
||||||
@ -274,6 +277,9 @@ func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to delete key %s : %w", addr, err)
|
return xerrors.Errorf("failed to delete key %s : %w", addr, err)
|
||||||
}
|
}
|
||||||
|
if k == nil {
|
||||||
|
return nil // already not there
|
||||||
|
}
|
||||||
|
|
||||||
if err := w.keystore.Put(KTrashPrefix+k.Address.String(), k.KeyInfo); err != nil {
|
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)
|
return xerrors.Errorf("failed to mark key %s as trashed: %w", addr, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user