Correctly delete the default wallet address

This commit is contained in:
Aayush Rajasekaran 2020-11-03 03:00:18 -05:00
parent a5c05f87f1
commit 46619fbb8d

View File

@ -305,6 +305,18 @@ func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) er
delete(w.keys, addr) delete(w.keys, addr)
def, err := w.GetDefault()
if err != nil {
return xerrors.Errorf("getting default address: %w", err)
}
if def == addr {
err = w.SetDefault(address.Undef)
if err != nil {
return xerrors.Errorf("unsetting default address: %w", err)
}
}
return nil return nil
} }