Skip to content

Commit

Permalink
close db if error while loading wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Jan 14, 2025
1 parent 3bf5f9a commit 9a6339f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func LoadWallet(config Config) (*Wallet, error) {
return nil, fmt.Errorf("InitStorage: %v", err)
}

isErr := true
defer func() {
// close db if an error happened
if isErr {
db.Close()
}
}()

seed := db.GetSeed()
if len(seed) == 0 {
// create and save new seed if none existed previously
Expand Down Expand Up @@ -138,6 +146,7 @@ func LoadWallet(config Config) (*Wallet, error) {
}
}

isErr = false
return wallet, nil
}

Expand Down

0 comments on commit 9a6339f

Please sign in to comment.