Notify all frontends of new accounts.
When a new account (wallet) is created with the createencryptedwallet JSON method, all frontends, including the one requesting the wallet, must be notified of this new account and its balance (probably zero). This removes the need for frontends to poll and check for any new accounts.
This commit is contained in:
parent
b2263ba6f5
commit
68cbb4192c
1 changed files with 9 additions and 3 deletions
12
cmdmgr.go
12
cmdmgr.go
|
@ -696,22 +696,28 @@ func CreateEncryptedWallet(reply chan []byte, msg *btcjson.Message) {
|
|||
return
|
||||
}
|
||||
|
||||
// Grab a new unique sequence number for tx notifications in new blocks.
|
||||
n := <-NewJSONID
|
||||
// Create a new account, with a new JSON ID for transaction
|
||||
// notifications.
|
||||
bw := &BtcWallet{
|
||||
Wallet: wlt,
|
||||
name: wname,
|
||||
dirty: true,
|
||||
NewBlockTxSeqN: n,
|
||||
NewBlockTxSeqN: <-NewJSONID,
|
||||
}
|
||||
// TODO(jrick): only begin tracking wallet if btcwallet is already
|
||||
// connected to btcd.
|
||||
bw.Track()
|
||||
|
||||
wallets.m[wname] = bw
|
||||
|
||||
// Write new wallet to disk.
|
||||
if err := bw.writeDirtyToDisk(); err != nil {
|
||||
log.Errorf("cannot sync dirty wallet: %v", err)
|
||||
}
|
||||
|
||||
// Notify all frontends of this new account, and its balance.
|
||||
NotifyBalances(frontendNotificationMaster)
|
||||
|
||||
ReplySuccess(reply, msg.Id, nil)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue