From d4e8f4beb630d46cdc196df11dcf57540f0bec71 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Tue, 23 May 2017 15:07:20 +0200 Subject: [PATCH] Set sequence to MAXINT-1 to fix locktime (per bauerj) --- lib/transaction.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/transaction.py b/lib/transaction.py index 1006431dd..3fb6471ba 100644 --- a/lib/transaction.py +++ b/lib/transaction.py @@ -686,11 +686,11 @@ class Transaction: # Script length, script, sequence s += var_int(len(script)/2) s += script - s += int_to_hex(txin.get('sequence', 0xffffffff), 4) + s += int_to_hex(txin.get('sequence', 0xffffffff - 1), 4) return s def set_rbf(self, rbf): - nSequence = 0xffffffff - (2 if rbf else 0) + nSequence = 0xffffffff - (2 if rbf else 1) for txin in self.inputs(): txin['sequence'] = nSequence @@ -716,12 +716,12 @@ class Transaction: txin = inputs[i] if self.is_segwit_input(txin): hashPrevouts = Hash(''.join(self.serialize_outpoint(txin) for txin in inputs).decode('hex')).encode('hex') - hashSequence = Hash(''.join(int_to_hex(txin.get('sequence', 0xffffffff), 4) for txin in inputs).decode('hex')).encode('hex') + hashSequence = Hash(''.join(int_to_hex(txin.get('sequence', 0xffffffff - 1), 4) for txin in inputs).decode('hex')).encode('hex') hashOutputs = Hash(''.join(self.serialize_output(o) for o in outputs).decode('hex')).encode('hex') outpoint = self.serialize_outpoint(txin) scriptCode = push_script(self.get_preimage_script(txin)) amount = int_to_hex(txin['value'], 8) - nSequence = int_to_hex(txin.get('sequence', 0xffffffff), 4) + 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)) @@ -780,7 +780,7 @@ class Transaction: return self.input_value() - self.output_value() def is_final(self): - return not any([x.get('sequence', 0xffffffff) < 0xffffffff - 1 for x in self.inputs()]) + return not any([x.get('sequence', 0xffffffff - 1) < 0xffffffff - 1 for x in self.inputs()]) @profiler def estimated_size(self):