mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
fix #4099: serialisation of txns with negative version number
This commit is contained in:
parent
87aee10047
commit
a6841cbd5f
2 changed files with 8 additions and 0 deletions
|
@ -144,6 +144,9 @@ def rev_hex(s):
|
|||
|
||||
def int_to_hex(i, length=1):
|
||||
assert isinstance(i, int)
|
||||
if i < 0:
|
||||
# two's complement
|
||||
i = pow(256, length) + i
|
||||
s = hex(i)[2:].rstrip('L')
|
||||
s = "0"*(2*length - len(s)) + s
|
||||
return rev_hex(s)
|
||||
|
|
|
@ -265,6 +265,11 @@ class TestTransaction(unittest.TestCase):
|
|||
txid = 'f570d5d1e965ee61bcc7005f8fefb1d3abbed9d7ddbe035e2a68fa07e5fc4a0d'
|
||||
self._run_naive_tests_on_tx(raw_tx, txid)
|
||||
|
||||
def test_txid_negative_version_num(self):
|
||||
raw_tx = 'f0b47b9a01ecf5e5c3bbf2cf1f71ecdc7f708b0b222432e914b394e24aad1494a42990ddfc000000008b483045022100852744642305a99ad74354e9495bf43a1f96ded470c256cd32e129290f1fa191022030c11d294af6a61b3da6ed2c0c296251d21d113cfd71ec11126517034b0dcb70014104a0fe6e4a600f859a0932f701d3af8e0ecd4be886d91045f06a5a6b931b95873aea1df61da281ba29cadb560dad4fc047cf47b4f7f2570da4c0b810b3dfa7e500ffffffff0240420f00000000001976a9147eeacb8a9265cd68c92806611f704fc55a21e1f588ac05f00d00000000001976a914eb3bd8ccd3ba6f1570f844b59ba3e0a667024a6a88acff7f0000'
|
||||
txid = 'c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369'
|
||||
self._run_naive_tests_on_tx(raw_tx, txid)
|
||||
|
||||
|
||||
# these transactions are from Bitcoin Core unit tests --->
|
||||
# https://github.com/bitcoin/bitcoin/blob/11376b5583a283772c82f6d32d0007cdbf5b8ef0/src/test/data/tx_valid.json
|
||||
|
|
Loading…
Add table
Reference in a new issue