From 581ff276105c48959091eb0388417a6b633c4b4d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 10 Nov 2014 15:36:51 -0800 Subject: [PATCH] fix leveldb traversal. --- src/bitcoindjs.cc | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 8a61ff79..1b3c7cfe 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -5739,21 +5739,38 @@ read_addr(const std::string addr) { continue; } - if (cur == NULL) { - head->ctx = ctx; - uint256 hash(((CMerkleTx)ctx).hashBlock.GetHex()); - head->blockhash = hash; - head->next = NULL; - cur = head; - } else { - ctx_list *item = new ctx_list(); - item->ctx = ctx; - uint256 hash(((CMerkleTx)ctx).hashBlock.GetHex()); - item->blockhash = hash; - item->next = NULL; - cur->next = item; - cur = item; + for (unsigned int vo = 0; vo < ctx.vout.size(); vo++) { + const CTxOut& txout = ctx.vout[vo]; + const CScript& scriptPubKey = txout.scriptPubKey; + int nRequired; + txnouttype type; + vector addresses; + if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { + continue; + } + BOOST_FOREACH(const CTxDestination& address, addresses) { + if (CBitcoinAddress(address).ToString() != addr) { + continue; + } + if (cur == NULL) { + head->ctx = ctx; + uint256 hash(((CMerkleTx)ctx).hashBlock.GetHex()); + head->blockhash = hash; + head->next = NULL; + cur = head; + } else { + ctx_list *item = new ctx_list(); + item->ctx = ctx; + uint256 hash(((CMerkleTx)ctx).hashBlock.GetHex()); + item->blockhash = hash; + item->next = NULL; + cur->next = item; + cur = item; + } + goto found; + } } +found: } }