Defer closing files when reading saved wallet.
This commit is contained in:
parent
3d6ad329d0
commit
42274b143f
1 changed files with 3 additions and 0 deletions
3
cmd.go
3
cmd.go
|
@ -136,6 +136,7 @@ func OpenWallet(cfg *config, account string) (*BtcWallet, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
defer wfile.Close()
|
||||
if txfile, err = os.Open(txfilepath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if txfile, err = os.Create(txfilepath); err != nil {
|
||||
|
@ -145,6 +146,7 @@ func OpenWallet(cfg *config, account string) (*BtcWallet, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
defer txfile.Close()
|
||||
if utxofile, err = os.Open(utxofilepath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if utxofile, err = os.Create(utxofilepath); err != nil {
|
||||
|
@ -154,6 +156,7 @@ func OpenWallet(cfg *config, account string) (*BtcWallet, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
defer utxofile.Close()
|
||||
|
||||
wlt := new(wallet.Wallet)
|
||||
if _, err = wlt.ReadFrom(wfile); err != nil {
|
||||
|
|
Loading…
Reference in a new issue