tzeromq/history4: Mitigate bug when duplicate transactions appear. - obelisk - Electrum server using libbitcoin as its backend HTML git clone https://git.parazyd.org/obelisk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit cfe0a0a83174c3c6630a321b8932c253119fade4 DIR parent 4eb88b8f6066b303e804ad0212645dae3d6ae124 HTML Author: parazyd <parazyd@dyne.org> Date: Mon, 19 Apr 2021 11:35:14 +0200 zeromq/history4: Mitigate bug when duplicate transactions appear. This is not a very efficient solution, but it's the best I can do now. I also added the problematic scripthash in the test suite. Diffstat: M obelisk/zeromq.py | 9 ++++++++- M tests/test_electrum_protocol.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) --- DIR diff --git a/obelisk/zeromq.py b/obelisk/zeromq.py t@@ -380,7 +380,14 @@ class Client: correlated_points = Client.__correlate(points) # self.log.debug("history points: %s", points) # self.log.debug("history correlated: %s", correlated_points) - return error_code, self._sort_correlated_points(correlated_points) + + # BUG: In libbitcoin v4 sometimes transactions mess up and double + # The following is not a very efficient solution + correlated = [ + i for n, i in enumerate(correlated_points) + if i not in correlated_points[n + 1:] + ] + return error_code, self._sort_correlated_points(correlated) @staticmethod def _sort_correlated_points(points): DIR diff --git a/tests/test_electrum_protocol.py b/tests/test_electrum_protocol.py t@@ -140,6 +140,7 @@ async def test_scripthash_get_balance(protocol, writer, method): params = [ ["c036b0ff3ad79662cd517cd5fe1fa0af07377b9262d16f276f11ced69aaa6921"], ["92dd1eb7c042956d3dd9185a58a2578f61fee91347196604540838ccd0f8c08c"], + ["b97b504af8fcf94a47d3ae5a346d38220f0751732d9b89a413568bfbf4b36ec6"], ] for i in params: expect = get_expect(method, i) t@@ -150,6 +151,7 @@ async def test_scripthash_get_balance(protocol, writer, method): async def test_scripthash_get_history(protocol, writer, method): params = [ ["c036b0ff3ad79662cd517cd5fe1fa0af07377b9262d16f276f11ced69aaa6921"], + ["b97b504af8fcf94a47d3ae5a346d38220f0751732d9b89a413568bfbf4b36ec6"], ] for i in params: expect = get_expect(method, i) t@@ -161,6 +163,7 @@ async def test_scripthash_listunspent(protocol, writer, method): params = [ ["c036b0ff3ad79662cd517cd5fe1fa0af07377b9262d16f276f11ced69aaa6921"], ["92dd1eb7c042956d3dd9185a58a2578f61fee91347196604540838ccd0f8c08c"], + ["b97b504af8fcf94a47d3ae5a346d38220f0751732d9b89a413568bfbf4b36ec6"], ] for i in params: # Blockstream is broken here and doesn't return in ascending order.