obelisk

Electrum server using libbitcoin as its backend
git clone https://git.parazyd.org/obelisk
Log | Files | Refs | README | LICENSE

commit eec7afe359164f0bb0aab3df1a46c90e21c1dceb
parent 6bdd6ef5754fa88ddcb3736fbd9acd8a37db2e58
Author: parazyd <parazyd@dyne.org>
Date:   Mon, 19 Apr 2021 10:56:29 +0200

zeromq/fetch_balance: Return a tuple of confirmed/unconfirmed.

Diffstat:
Mobelisk/protocol.py | 3+--
Mobelisk/zeromq.py | 19+++++++++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/obelisk/protocol.py b/obelisk/protocol.py @@ -354,8 +354,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 self.log.debug("Got error: %s", repr(_ec)) return JsonRPCError.internalerror() - # TODO: confirmed/unconfirmed, see what's happening in libbitcoin - ret = {"confirmed": data, "unconfirmed": 0} + ret = {"confirmed": data[0], "unconfirmed": data[1]} return {"result": ret} async def scripthash_get_history(self, writer, query): # pylint: disable=W0613 diff --git a/obelisk/zeromq.py b/obelisk/zeromq.py @@ -401,8 +401,23 @@ class Client: return error_code, None utxo = Client.__receives_without_spends(history) - return error_code, functools.reduce( - lambda accumulator, point: accumulator + point["value"], utxo, 0) + + return error_code, ( + # confirmed + functools.reduce( + lambda accumulator, point: accumulator + point["value"] + if point["received"]["height"] != 4294967295 else 0, + utxo, + 0, + ), + # unconfirmed + functools.reduce( + lambda accumulator, point: accumulator + point["value"] + if point["received"]["height"] == 4294967295 else 0, + utxo, + 0, + ), + ) async def fetch_utxo(self, scripthash): """Find UTXO for given scripthash"""