mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 16:31:29 +00:00
transaction.serialize_preimage: trivial clean-up
This commit is contained in:
parent
b4bf39ee92
commit
a14016275b
1 changed files with 5 additions and 5 deletions
|
@ -958,14 +958,13 @@ class Transaction:
|
||||||
s += script
|
s += script
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def serialize_preimage(self, i):
|
def serialize_preimage(self, txin_index: int) -> str:
|
||||||
nVersion = int_to_hex(self.version, 4)
|
nVersion = int_to_hex(self.version, 4)
|
||||||
nHashType = int_to_hex(1, 4)
|
nHashType = int_to_hex(1, 4) # SIGHASH_ALL
|
||||||
nLocktime = int_to_hex(self.locktime, 4)
|
nLocktime = int_to_hex(self.locktime, 4)
|
||||||
inputs = self.inputs()
|
inputs = self.inputs()
|
||||||
outputs = self.outputs()
|
outputs = self.outputs()
|
||||||
txin = inputs[i]
|
txin = inputs[txin_index]
|
||||||
# TODO: py3 hex
|
|
||||||
if self.is_segwit_input(txin):
|
if self.is_segwit_input(txin):
|
||||||
hashPrevouts = bh2u(sha256d(bfh(''.join(self.serialize_outpoint(txin) for txin in inputs))))
|
hashPrevouts = bh2u(sha256d(bfh(''.join(self.serialize_outpoint(txin) for txin in inputs))))
|
||||||
hashSequence = bh2u(sha256d(bfh(''.join(int_to_hex(txin.get('sequence', 0xffffffff - 1), 4) for txin in inputs))))
|
hashSequence = bh2u(sha256d(bfh(''.join(int_to_hex(txin.get('sequence', 0xffffffff - 1), 4) for txin in inputs))))
|
||||||
|
@ -977,7 +976,8 @@ class Transaction:
|
||||||
nSequence = int_to_hex(txin.get('sequence', 0xffffffff - 1), 4)
|
nSequence = int_to_hex(txin.get('sequence', 0xffffffff - 1), 4)
|
||||||
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType
|
preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType
|
||||||
else:
|
else:
|
||||||
txins = var_int(len(inputs)) + ''.join(self.serialize_input(txin, self.get_preimage_script(txin) if i==k else '') for k, txin in enumerate(inputs))
|
txins = var_int(len(inputs)) + ''.join(self.serialize_input(txin, self.get_preimage_script(txin) if txin_index==k else '')
|
||||||
|
for k, txin in enumerate(inputs))
|
||||||
txouts = var_int(len(outputs)) + ''.join(self.serialize_output(o) for o in outputs)
|
txouts = var_int(len(outputs)) + ''.join(self.serialize_output(o) for o in outputs)
|
||||||
preimage = nVersion + txins + txouts + nLocktime + nHashType
|
preimage = nVersion + txins + txouts + nLocktime + nHashType
|
||||||
return preimage
|
return preimage
|
||||||
|
|
Loading…
Add table
Reference in a new issue