Skip to content

Commit

Permalink
Open and return wallet from CreateNewWallet.
Browse files Browse the repository at this point in the history
This fixes a dcrwallet-specific bug introduced by
4b64adf which removed the call to
wallet.Open from wallet.Loader.CreateNewWallet, replacing the wallet
pointer with nil, and removes the addition of a call to close the
wallet database.  The introduction of a nil pointer caused runtime
panics when executing Loader callbacks that dereferenced the wallet
pointer, and by the caller who would dereference the return value.

This makes the LoaderService.CreateNewWallet RPC useful again.
  • Loading branch information
jrick committed Apr 22, 2016
1 parent 823bddb commit b28ae9a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions wallet/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,20 @@ func (l *Loader) CreateNewWallet(pubPassphrase, privPassphrase, seed []byte) (*W
return nil, err
}

l.onLoaded(nil, db)
db.Close()
return nil, nil
// Open the newly-created wallet.
so := l.stakeOptions
w, err := Open(db, pubPassphrase, nil, so.VoteBits, so.StakeMiningEnabled,
so.BalanceToMaintain, so.AddressReuse, so.RollbackTest,
so.PruneTickets, so.TicketAddress, so.TicketMaxPrice,
so.TicketBuyFreq, so.PoolAddress, so.PoolFees, l.addrIdxScanLen,
l.autoRepair, l.chainParams)
if err != nil {
return nil, err
}
w.Start()

l.onLoaded(w, db)
return w, nil
}

var errNoConsole = errors.New("db upgrade requires console access for additional input")
Expand Down

0 comments on commit b28ae9a

Please sign in to comment.