def __init__(self, timestamper, coinbaser, value, flags, height, commitment, 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!") tx_in = halfnode.CTxIn() tx_in.prevout.hash = 0L tx_in.prevout.n = 2**32-1 tx_in._scriptSig_template = ( util.ser_number(height) + binascii.unhexlify(flags) + util.ser_number(int(timestamper.time())) + \ 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) if(commitment): txout_commitment = halfnode.CTxOut() txout_commitment.nValue = 0 txout_commitment.scriptPubKey = commitment self.vout.append(txout_commitment) # 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 __init__(self, timestamper, coinbaser, value, flags, height, commitment=None, data='', ntime=None): super(CoinbaseTransaction, self).__init__() log.debug("Got to CoinBaseTX") if len(self.extranonce_placeholder) != self.extranonce_size: raise Exception( "Extranonce placeholder don't match expected length!") tx_in = halfnode.CTxIn() tx_in.prevout.hash = 0L tx_in.prevout.n = 2**32 - 1 tx_in._scriptSig_template = ( util.ser_number(height) + binascii.unhexlify( flags) + util.ser_number(int(timestamper.time())) + \ 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() if settings.COINDAEMON_REWARD == 'POS' and ntime is not None: self.nTime = ntime if settings.COINDAEMON_TX: self.strTxComment = "http://github.com/mrouhi13/stratum-mining" self.vin.append(tx_in) self.vout.append(tx_out) if commitment: txout_commitment = halfnode.CTxOut() txout_commitment.nValue = 0 txout_commitment.scriptPubKey = commitment self.vout.append(txout_commitment) # 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 __init__(self, timestamper, reward_coinbaser, value, flags, height, data, ntime, coinbase_payload, masternodes): super(CoinbaseTransaction, self).__init__() # self.extranonce = 0 if len(self.extranonce_placeholder) != self.extranonce_size: raise Exception( "Extranonce placeholder don't match expected length!") tx_in = halfnode.CTxIn() tx_in.prevout.hash = 0L tx_in.prevout.n = 2**32 - 1 tx_in._scriptSig_template = ( util.ser_number(height) + binascii.unhexlify(flags) + util.ser_number(int(timestamper.time())) + \ chr(self.extranonce_size), util.ser_string(reward_coinbaser.get_coinbase_data() + data) ) tx_in.scriptSig = tx_in._scriptSig_template[ 0] + self.extranonce_placeholder + tx_in._scriptSig_template[1] # coinbase self.nVersion = 3 self.nType = 5 self.nTime = ntime self.vin.append(tx_in) for masternode in masternodes: master_coinbaser = coinbaser.SimpleCoinbaser( None, masternode['payee']) tx_out = halfnode.CTxOut() tx_out.nValue = masternode['amount'] tx_out.scriptPubKey = master_coinbaser.get_script_pubkey() self.vout.append(tx_out) value -= masternode['amount'] assert (value > 0, "coinbase reward <= 0") tx_out = halfnode.CTxOut() tx_out.nValue = value tx_out.scriptPubKey = reward_coinbaser.get_script_pubkey() self.vout.append(tx_out) # for dashcoin self.vExtraPayload = binascii.unhexlify(coinbase_payload) # 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 __init__(self, timestamper, coinbaser, value, charity_value, flags, height, data, ntime): super(CoinbaseTransaction, self).__init__() #self.extranonce = 0 if len(self.extranonce_placeholder) != self.extranonce_size: raise Exception( "Extranonce placeholder don't match expected length!") tx_in = halfnode.CTxIn() tx_in.prevout.hash = 0L tx_in.prevout.n = 2**32 - 1 tx_in._scriptSig_template = ( util.ser_number(height) + binascii.unhexlify(flags) + util.ser_number(int(timestamper.time())) + \ 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] # EMC2 Charity Address Requirement charity_value += int(settings.EXTRA_DONATION) if charity_value > value: charity_value = value tx_out_charity = halfnode.CTxOut() tx_out_charity.nValue = charity_value tx_out_charity.scriptPubKey = util.getCharityScript() tx_out = halfnode.CTxOut() tx_out.nValue = value tx_out.scriptPubKey = coinbaser.get_script_pubkey() self.nTime = ntime if settings.COINDAEMON_SHA256_TX == 'yes': self.strTxComment = "" self.vin.append(tx_in) self.vout.append(tx_out_charity) 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 __init__(self, timestamper, coinbaser, value, flags, height, data, rewards): super(CoinbaseTransactionPOW, self).__init__() log.debug("Got to CoinBaseTX") #self.extranonce = 0 if len(self.extranonce_placeholder) != self.extranonce_size: raise Exception( "Extranonce placeholder don't match expected length!") tx_in = halfnode.CTxIn() tx_in.prevout.hash = 0L tx_in.prevout.n = 2**32 - 1 tx_in._scriptSig_template = ( util.ser_number(height) + binascii.unhexlify(flags) + util.ser_number(int(timestamper.time())) + \ 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() if settings.COINDAEMON_TX == 'yes': self.strTxComment = "http://github.com/ahmedbodi/stratum-mining" self.vin.append(tx_in) self.vout.append(tx_out) if rewards is not None: for key, val in rewards.items(): tx_out = halfnode.CTxOut() tx_out.nValue = val tx_out.scriptPubKey = util.script_to_address(key) self.vout.append(tx_out) # Two parts of serialized coinbase, just put part1 + extranonce + part2 to have final serialized tx self._serialized = super(CoinbaseTransactionPOW, self).serialize().split( self.extranonce_placeholder)
def __init__(self, coinbasers_value, total_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!") tx_in = halfnode.CTxIn() tx_in.prevout.hash = 0L tx_in.prevout.n = 2**32 - 1 tx_in._scriptSig_template = ( util.ser_number(height) + binascii.unhexlify(flags) + util.ser_number(int(time.time())) + \ chr(self.extranonce_size), # util.ser_string(coinbaser.get_coinbase_data() + data) util.ser_string(data) ) tx_in.scriptSig = tx_in._scriptSig_template[ 0] + self.extranonce_placeholder + tx_in._scriptSig_template[1] self.vin.append(tx_in) total_value_share = sum([x[1] for x in coinbasers_value]) used_value = 0 for coinbaser, value in coinbasers_value: tx_out = halfnode.CTxOut() current_value = total_value * value / total_value_share tx_out.nValue = current_value used_value += current_value tx_out.scriptPubKey = coinbaser.get_script_pubkey() self.vout.append(tx_out) if used_value < total_value: self.vout[0].nValue += total_value - used_value # 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)