mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-11 04:59:51 +00:00
transaction.py: (txin guess) fix some false positive matches of p2sh-segwit (#4336)
This commit is contained in:
parent
4eeb944b3c
commit
3337af0734
2 changed files with 17 additions and 0 deletions
|
@ -290,6 +290,11 @@ class TestTransaction(unittest.TestCase):
|
||||||
txid = 'c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369'
|
txid = 'c659729a7fea5071361c2c1a68551ca2bf77679b27086cc415adeeb03852e369'
|
||||||
self._run_naive_tests_on_tx(raw_tx, txid)
|
self._run_naive_tests_on_tx(raw_tx, txid)
|
||||||
|
|
||||||
|
def test_txid_regression_issue_4333(self):
|
||||||
|
raw_tx = '0100000001a300499298b3f03200c05d1a15aa111a33c769aff6fb355c6bf52ebdb58ca37100000000171600756161616161616161616161616161616161616151fdffffff01c40900000000000017a914001975d5f07f3391674416c1fcd67fd511d257ff871bc71300'
|
||||||
|
txid = '9b9f39e314662a7433aadaa5c94a2f1e24c7e7bf55fc9e1f83abd72be933eb95'
|
||||||
|
self._run_naive_tests_on_tx(raw_tx, txid)
|
||||||
|
|
||||||
|
|
||||||
# these transactions are from Bitcoin Core unit tests --->
|
# these transactions are from Bitcoin Core unit tests --->
|
||||||
# https://github.com/bitcoin/bitcoin/blob/11376b5583a283772c82f6d32d0007cdbf5b8ef0/src/test/data/tx_valid.json
|
# https://github.com/bitcoin/bitcoin/blob/11376b5583a283772c82f6d32d0007cdbf5b8ef0/src/test/data/tx_valid.json
|
||||||
|
|
|
@ -384,6 +384,15 @@ def parse_scriptSig(d, _bytes):
|
||||||
bh2u(_bytes))
|
bh2u(_bytes))
|
||||||
|
|
||||||
|
|
||||||
|
def _revise_txin_type_guess_for_txin(txin):
|
||||||
|
_type = txin.get('type', 'unknown')
|
||||||
|
# fix incorrect guess of p2sh-segwit
|
||||||
|
we_guessed_segwit_input_type = Transaction.is_segwit_inputtype(_type)
|
||||||
|
has_zero_witness = txin.get('witness', '00') in ('00', None)
|
||||||
|
if we_guessed_segwit_input_type and has_zero_witness:
|
||||||
|
txin['type'] = 'unknown'
|
||||||
|
|
||||||
|
|
||||||
def parse_redeemScript_multisig(redeem_script: bytes):
|
def parse_redeemScript_multisig(redeem_script: bytes):
|
||||||
dec2 = [ x for x in script_GetOp(redeem_script) ]
|
dec2 = [ x for x in script_GetOp(redeem_script) ]
|
||||||
try:
|
try:
|
||||||
|
@ -567,6 +576,9 @@ def deserialize(raw):
|
||||||
txin = d['inputs'][i]
|
txin = d['inputs'][i]
|
||||||
parse_witness(vds, txin)
|
parse_witness(vds, txin)
|
||||||
d['lockTime'] = vds.read_uint32()
|
d['lockTime'] = vds.read_uint32()
|
||||||
|
for i in range(n_vin):
|
||||||
|
txin = d['inputs'][i]
|
||||||
|
_revise_txin_type_guess_for_txin(txin)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue