From 46619fbb8d24ce222d8ec31e8b757d87d85e696a Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 3 Nov 2020 03:00:18 -0500 Subject: [PATCH] Correctly delete the default wallet address --- chain/wallet/wallet.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chain/wallet/wallet.go b/chain/wallet/wallet.go index 33fa3135e..46ff92861 100644 --- a/chain/wallet/wallet.go +++ b/chain/wallet/wallet.go @@ -305,6 +305,18 @@ func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) er 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 }