swapper-org / NodeChain

Nodechain is a service that allows you to create nodes on a blockchain and connect to them natively through APIs. The goal is to allow the user to build their own nodes natively without having to rely on external services.
MIT License
7 stars 5 forks source link

Fix unconfirmed balances in getBalance #137

Closed phoenix-web3 closed 2 years ago

phoenix-web3 commented 2 years ago

Description

Electrum has been updated with this piece of code:

async def get_balance_for_scripthash(self, sh: str) -> dict:
        if not is_hash256_str(sh):
            raise Exception(f"{repr(sh)} is not a scripthash")
        # do request
        res = await self.session.send_request('blockchain.scripthash.get_balance', [sh])
        # check response
        assert_dict_contains_field(res, field_name='confirmed')
        assert_dict_contains_field(res, field_name='unconfirmed')
        assert_non_negative_integer(res['confirmed'])
        assert_integer(res['unconfirmed'])
        return res

This change fix the bug that causes getBalance to fail for transactions with negative unconfirmed balance

Thanks to @coval3nte

Fixes #76 (issue)

Issue #110 will be marked as wontfix

Dependencies (if any)

Type of change

Related PR or Docs PR

Good practices to consider