Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
fix(kwallet): empty wallet key query
Browse files Browse the repository at this point in the history
When querying a key in an empty kwallet wallet, we receive the following error:
```
Error: unexpected end of JSON input
```
This is because the `k.wallet.ReadEntry` returns empty bytes and no error. Hence we should handle a case for empty bytes.

Reference: cosmos/cosmos-sdk#9562
  • Loading branch information
tomtau committed Jul 12, 2021
1 parent 0cfb890 commit 4fc1291
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (k *kwalletKeyring) Get(key string) (Item, error) {
if err != nil {
return Item{}, err
}
if len(data) == 0 {
return Item{}, ErrKeyNotFound
}


item := Item{}
err = json.Unmarshal(data, &item)
Expand Down

0 comments on commit 4fc1291

Please sign in to comment.