electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit a14016275b028bb53e9a2151bb27bdb84d063d07
parent b4bf39ee9268c6c453333490c01439a1ddd750ab
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon,  8 Jul 2019 05:58:57 +0200

transaction.serialize_preimage: trivial clean-up

Diffstat:
Melectrum/transaction.py | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/electrum/transaction.py b/electrum/transaction.py @@ -958,14 +958,13 @@ class Transaction: s += script return s - def serialize_preimage(self, i): + def serialize_preimage(self, txin_index: int) -> str: 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) inputs = self.inputs() outputs = self.outputs() - txin = inputs[i] - # TODO: py3 hex + txin = inputs[txin_index] if self.is_segwit_input(txin): 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)))) @@ -977,7 +976,8 @@ class Transaction: nSequence = int_to_hex(txin.get('sequence', 0xffffffff - 1), 4) preimage = nVersion + hashPrevouts + hashSequence + outpoint + scriptCode + amount + nSequence + hashOutputs + nLocktime + nHashType 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) preimage = nVersion + txins + txouts + nLocktime + nHashType return preimage