Пример #1
0
    def __init__(self, timestamper, coinbaser, value, flags, height, data):
        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)

        # 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, timestamper, coinbaser, 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]

        tx_out = halfnode.CTxOut()
        tx_out.nValue = value
        tx_out.scriptPubKey = coinbaser.get_script_pubkey()

        self.nTime = ntime  # Coinbase timestamp
        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)
Пример #3
0
    def __init__(self,
                 timestamper,
                 coinbaser,
                 value,
                 flags,
                 height,
                 commitment=None,
                 data='',
                 ntime=None):
        super(CoinbaseTransaction, 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_REWARD == 'POS' and ntime != None:
            self.nTime = ntime

        if settings.COINDAEMON_TX != False:
            self.strTxComment = 'http://github.com/nullivex'

        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)
Пример #4
0
    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)
Пример #5
0
        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)
Пример #6
0
    def __init__(self, timestamper, coinbaser, values, flags, height, commitment, data):
        super(CoinbaseTransactionPOW, self).__init__()
        log.debug("Got to CoinBaseTX(POW)")
        #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 = values[0]['nValue']
        tx_out.scriptPubKey = coinbaser.get_script_pubkey()

        self.vin.append(tx_in)
        self.vout.append(tx_out)

        values.pop(-1)
        log.debug("values: %s", values)
        values.pop(0)

        for value in values:
            tx_out = halfnode.CTxOut()
            tx_out.nValue = value['nValue']
            tx_out.scriptPubKey = binascii.unhexlify(value['scriptPubKey'])
            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(CoinbaseTransactionPOW, self).serialize().split(self.extranonce_placeholder)
Пример #7
0
    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)