From 94d4bd28ae4ff02136d4aa2cc9bf9afc050b2d1f Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Tue, 8 Oct 2013 19:36:44 -0400 Subject: [PATCH] Hold wallet map lock until wallet has been added (or an error happens) --- cmdmgr.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmdmgr.go b/cmdmgr.go index bce083a..24e0d72 100644 --- a/cmdmgr.go +++ b/cmdmgr.go @@ -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) }