Skip to content

Commit

Permalink
Namecoin / AuxPoW: Remove unused stub_get_address_from_output_script.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Jul 4, 2018
1 parent 62c0119 commit fb60f94
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/auxpow.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,22 @@ def hex_to_int(s):
def fast_txid(tx):
return bh2u(Hash(tx.raw_bytes)[::-1])

def fast_tx_deserialize(tx):
def stub_get_address_from_output_script(_bytes, *, net=None):
return TYPE_SCRIPT, ''

def stub_parse_output(vds, i):
vds.read_int64() # d['value']
vds.read_bytes(vds.read_compact_size()) # scriptPubKey
return {'type': TYPE_SCRIPT, 'address': None, 'value': 0}
# Used by fast_tx_deserialize
def stub_parse_output(vds, i):
vds.read_int64() # d['value']
vds.read_bytes(vds.read_compact_size()) # scriptPubKey
return {'type': TYPE_SCRIPT, 'address': None, 'value': 0}

# This is equivalent to tx.deserialize(), but doesn't parse outputs.
def fast_tx_deserialize(tx):
# Monkeypatch output address parsing with a stub, since we only care about
# inputs.
real_get_address_from_output_script = transaction.get_address_from_output_script
real_parse_output = transaction.parse_output
transaction.get_address_from_output_script = stub_get_address_from_output_script
transaction.parse_output = stub_parse_output

result = tx.deserialize()

# Restore the real output address parser.
transaction.get_address_from_output_script = real_get_address_from_output_script
transaction.parse_output = real_parse_output

return result

0 comments on commit fb60f94

Please sign in to comment.