Hold wallet map lock until wallet has been added (or an error happens)
This commit is contained in:
parent
2e42efef53
commit
94d4bd28ae
1 changed files with 2 additions and 4 deletions
|
@ -664,14 +664,14 @@ func CreateEncryptedWallet(reply chan []byte, msg *btcjson.Message) {
|
|||
}
|
||||
|
||||
// Does this wallet already exist?
|
||||
wallets.RLock()
|
||||
wallets.Lock()
|
||||
if w := wallets.m[wname]; w != nil {
|
||||
e := WalletInvalidAccountName
|
||||
e.Message = "Wallet already exists."
|
||||
ReplyError(reply, msg.Id, &e)
|
||||
return
|
||||
}
|
||||
wallets.RUnlock()
|
||||
defer wallets.Unlock()
|
||||
|
||||
var net btcwire.BitcoinNet
|
||||
if cfg.MainNet {
|
||||
|
@ -700,9 +700,7 @@ func CreateEncryptedWallet(reply chan []byte, msg *btcjson.Message) {
|
|||
// connected to btcd.
|
||||
bw.Track()
|
||||
|
||||
wallets.Lock()
|
||||
wallets.m[wname] = bw
|
||||
wallets.Unlock()
|
||||
ReplySuccess(reply, msg.Id, nil)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue