From 6e20de7c4a00543deacc64cd16c91d6ec9d1df65 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 4 Sep 2013 20:38:57 -0400 Subject: [PATCH] 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. --- sockets.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sockets.go b/sockets.go index f3ef9c5..73576df 100644 --- a/sockets.go +++ b/sockets.go @@ -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,