X-Git-Url: https://git.novaco.in/?p=stratum-mining.git;a=blobdiff_plain;f=lib%2Fcoinbasetx.py;h=8953106c3dbdd0b746f531535af2e4f6341dfd1c;hp=11c7e36ace20786546805d8f2c2e4704a7ac4b5d;hb=679245b565edcb2a03d865df3c08e86c0d6f402d;hpb=8a7474eb0eefdbc68e9b57371a68c25f33427f0d diff --git a/lib/coinbasetx.py b/lib/coinbasetx.py index 11c7e36..8953106 100644 --- a/lib/coinbasetx.py +++ b/lib/coinbasetx.py @@ -7,16 +7,16 @@ class CoinbaseTransaction(halfnode.CTransaction): '''Construct special transaction used for coinbase tx. It also implements quick serialization using pre-cached scriptSig template.''' - + extranonce_type = '>Q' extranonce_placeholder = struct.pack(extranonce_type, int('f000000ff111111f', 16)) extranonce_size = struct.calcsize(extranonce_type) def __init__(self, timestamper, coinbaser, value, flags, height, data): super(CoinbaseTransaction, self).__init__() - + #self.extranonce = 0 - + if len(self.extranonce_placeholder) != self.extranonce_size: raise Exception("Extranonce placeholder don't match expected length!") @@ -28,22 +28,22 @@ class CoinbaseTransaction(halfnode.CTransaction): chr(self.extranonce_size), util.ser_string(coinbaser.get_coinbase_data() + data) ) - + tx_in.scriptSig = tx_in._scriptSig_template[0] + self.extranonce_placeholder + tx_in._scriptSig_template[1] - + tx_out = halfnode.CTxOut() tx_out.nValue = value tx_out.scriptPubKey = coinbaser.get_script_pubkey() - + self.vin.append(tx_in) self.vout.append(tx_out) - + # Two parts of serialized coinbase, just put part1 + extranonce + part2 to have final serialized tx self._serialized = super(CoinbaseTransaction, self).serialize().split(self.extranonce_placeholder) def set_extranonce(self, extranonce): if len(extranonce) != self.extranonce_size: raise Exception("Incorrect extranonce size") - + (part1, part2) = self.vin[0]._scriptSig_template - self.vin[0].scriptSig = part1 + extranonce + part2 \ No newline at end of file + self.vin[0].scriptSig = part1 + extranonce + part2