Skip to content

Commit

Permalink
use tx_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Dec 7, 2024
1 parent b43512b commit 828b5d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions counterparty-core/counterpartycore/lib/deserialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def read_transaction(vds, use_txid=True):
data = vds.input[start_pos : vds.read_cursor]

transaction["tx_hash"] = ib2h(double_hash(data))
transaction["tx_id"] = transaction["tx_hash"]
if transaction["segwit"]:
hash_data = data[:4] + data[6:offset_before_tx_witnesses] + data[-4:]
transaction["tx_id"] = ib2h(double_hash(hash_data))
Expand Down
6 changes: 3 additions & 3 deletions counterparty-core/counterpartycore/lib/gettxinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class SighashFlagError(Exception):


def check_signatures_sighash_flag(decoded_tx):
if decoded_tx["tx_hash"] in SIGHASH_FLAG_TRANSACTION_WHITELIST:
if decoded_tx["tx_id"] in SIGHASH_FLAG_TRANSACTION_WHITELIST:
return

script_sig = decoded_tx["vin"][0]["script_sig"]
Expand All @@ -247,15 +247,15 @@ def check_signatures_sighash_flag(decoded_tx):
flags = collect_sighash_flags(script_sig, witnesses)

if len(flags) == 0:
error = f"impossible to determine SIGHASH flag for transaction {decoded_tx['tx_hash']}"
error = f"impossible to determine SIGHASH flag for transaction {decoded_tx['tx_id']}"
logger.debug(error)
raise SighashFlagError(error)

# first input must be signed with SIGHASH_ALL or SIGHASH_ALL|SIGHASH_ANYONECANPAY
authorized_flags = [b"\x01", b"\x81"]
for flag in flags:
if flag not in authorized_flags:
error = f"invalid SIGHASH flag for transaction {decoded_tx['tx_hash']}"
error = f"invalid SIGHASH flag for transaction {decoded_tx['tx_id']}"
logger.debug(error)
raise SighashFlagError(error)

Expand Down

0 comments on commit 828b5d8

Please sign in to comment.