Interpret btcd:blockconnected hash as string.

btcd was changed to send the block hash for new block notifications as
a big endian string, so type assert as a string and convert to a
btcwire.ShaHash.
This commit is contained in:
Josh Rickmar 2013-09-04 20:38:57 -04:00
parent 79d1491ac4
commit 6e20de7c4a

View file

@ -268,11 +268,16 @@ func ProcessBtcdNotificationReply(b []byte) {
switch idStr {
case "btcd:blockconnected":
result := m["result"].(map[string]interface{})
hash := new(btcwire.ShaHash)
copy(hash[:], UnmangleJsonByteSlice(result["hash"].([]interface{})))
hashBE := m["hash"].(string)
hash, err := btcwire.NewShaHashFromStr(hashBE)
if err != nil {
log.Error("btcd:blockconnected handler: Invalid hash string")
return
}
height := int64(result["height"].(float64))
// TODO(jrick): update TxStore and UtxoStore with new hash
_ = hash
var id interface{} = "btcwallet:newblockchainheight"
msgRaw := &btcjson.Reply{
Result: height,