Begin tracking newly created wallets against btcd.
This commit is contained in:
parent
ed98256553
commit
2789502ec9
3 changed files with 20 additions and 4 deletions
2
cmd.go
2
cmd.go
|
@ -73,7 +73,7 @@ func main() {
|
||||||
log.Info("Unable to connect to btcd. Retrying in 5 seconds.")
|
log.Info("Unable to connect to btcd. Retrying in 5 seconds.")
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
log.Info(err.Error())
|
log.Error(err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
cmdmgr.go
18
cmdmgr.go
|
@ -336,10 +336,22 @@ func CreateEncryptedWallet(reply chan []byte, msg []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
wallets.Lock()
|
// Grab a new unique sequence number for tx notifications in new blocks.
|
||||||
wallets.m[wname] = &BtcWallet{
|
seq.Lock()
|
||||||
Wallet: w,
|
n := seq.n
|
||||||
|
seq.n++
|
||||||
|
seq.Unlock()
|
||||||
|
|
||||||
|
bw := &BtcWallet{
|
||||||
|
Wallet: w,
|
||||||
|
NewBlockTxSeqN: n,
|
||||||
}
|
}
|
||||||
|
// TODO(jrick): only begin tracking wallet if btcwallet is already
|
||||||
|
// connected to btcd.
|
||||||
|
bw.Track()
|
||||||
|
|
||||||
|
wallets.Lock()
|
||||||
|
wallets.m[wname] = bw
|
||||||
wallets.Unlock()
|
wallets.Unlock()
|
||||||
ReplySuccess(reply, v["id"], nil)
|
ReplySuccess(reply, v["id"], nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ var (
|
||||||
// Messages sent to this channel are sent to each connected frontend.
|
// Messages sent to this channel are sent to each connected frontend.
|
||||||
frontendNotificationMaster = make(chan []byte, 100)
|
frontendNotificationMaster = make(chan []byte, 100)
|
||||||
|
|
||||||
|
// replyHandlers maps between a sequence number (passed as part of
|
||||||
|
// the JSON Id field) and a function to handle a reply or notification
|
||||||
|
// from btcd. As requests are received, this map is checked for a
|
||||||
|
// handler function to route the reply to.
|
||||||
replyHandlers = struct {
|
replyHandlers = struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
m map[uint64]func(interface{}) bool
|
m map[uint64]func(interface{}) bool
|
||||||
|
|
Loading…
Reference in a new issue