Exemplo n.º 1
0
    def create_transaction(self, inputs, op_return_value):
        fee = tx_utils.calculate_tx_fee(self.tx_cost_constants, len(inputs),
                                        V2_NUM_OUTPUTS)
        transaction = tx_utils.create_trx(op_return_value, fee,
                                          self.issuing_address, [], inputs)

        return transaction
Exemplo n.º 2
0
 def test_create_trx(self):
     tx_input = Spendable(200, '18eKkAWyU9kvRNHPKxnZb6wwtPMrNmRRRA',
                          h2b('8443b07464c762d7fb404ea918a5ac9b3618d5cd6a0c5ea6e4dd5d7bbe28b154'), 0)
     tx_outs = [tx_utils.create_transaction_output('mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', 0.0000275)]
     tx = tx_utils.create_trx('TEST'.encode('utf-8'), 3, 'mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', tx_outs, tx_input)
     hextx = hexlify(tx.serialize())
     self.assertEquals(hextx,
                       '01000000018443b07464c762d7fb404ea918a5ac9b3618d5cd6a0c5ea6e4dd5d7bbe28b1540000000000ffffffff0300000000000000001976a914072a22e5913cd939904c46bbd0bc56755543384b88acc5000000000000001976a914072a22e5913cd939904c46bbd0bc56755543384b88ac0000000000000000066a045445535400000000')
    def create_transaction(self, tx_cost_constants, issuing_address, inputs, op_return_value):
        fee = tx_utils.calculate_tx_fee(tx_cost_constants, len(inputs), V2_NUM_OUTPUTS)
        transaction = tx_utils.create_trx(
            op_return_value,
            fee,
            issuing_address,
            [],
            inputs)

        return transaction
Exemplo n.º 4
0
    def create_transaction(self, last_input, op_return_value):
        total = self.calculate_cost_for_certificate_batch()
        transaction = tx_utils.create_trx(
            op_return_value,
            total,
            self.issuing_address,
            [],
            last_input)

        return transaction
Exemplo n.º 5
0
 def test_create_trx(self):
     bitcoin.SelectParams('testnet')
     b = h2b('8443b07464c762d7fb404ea918a5ac9b3618d5cd6a0c5ea6e4dd5d7bbe28b154')
     tx_input = Spendable(200, b'18eKkAWyU9kvRNHPKxnZb6wwtPMrNmRRRA',
                          b, 0)
     tx_outs = [tx_utils.create_transaction_output('mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', 0.0000275)]
     tx = tx_utils.create_trx('TEST'.encode('utf-8'), 3, 'mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', tx_outs, [tx_input])
     hextx = b2h(tx.serialize())
     self.assertEquals(hextx,
                       '01000000018443b07464c762d7fb404ea918a5ac9b3618d5cd6a0c5ea6e4dd5d7bbe28b1540000000000ffffffff0300000000000000001976a914072a22e5913cd939904c46bbd0bc56755543384b88acc5000000000000001976a914072a22e5913cd939904c46bbd0bc56755543384b88ac0000000000000000066a045445535400000000')
Exemplo n.º 6
0
    def test_verify_transaction(self):
        tx_input = Spendable(200, '18eKkAWyU9kvRNHPKxnZb6wwtPMrNmRRRA',
                             h2b('8443b07464c762d7fb404ea918a5ac9b3618d5cd6a0c5ea6e4dd5d7bbe28b154'), 0)
        tx_outs = [tx_utils.create_transaction_output('mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', 0.0000275)]
        op_return_val = h2b('e9cee71ab932fde863338d08be4de9dfe39ea049bdafb342ce659ec5450b69ae')
        tx = tx_utils.create_trx(op_return_val, 3, 'mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', tx_outs, tx_input)

        hextx = hexlify(tx.serialize())

        tx_utils.verify_transaction(hextx, hexlify(op_return_val))
Exemplo n.º 7
0
    def test_verify_transaction(self):
        bitcoin.SelectParams('testnet')
        b = h2b('8443b07464c762d7fb404ea918a5ac9b3618d5cd6a0c5ea6e4dd5d7bbe28b154')
        tx_input = Spendable(200, b'18eKkAWyU9kvRNHPKxnZb6wwtPMrNmRRRA', b, 0)
        tx_outs = [tx_utils.create_transaction_output('mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', 0.0000275)]
        op_return_val = h2b('e9cee71ab932fde863338d08be4de9dfe39ea049bdafb342ce659ec5450b69ae')
        tx = tx_utils.create_trx(op_return_val, 3, 'mgAqW5ZCnEp7fjvpj8RUL3WxsBy8rcDcCi', tx_outs, [tx_input])

        hextx = b2h(tx.serialize())

        tx_utils.verify_transaction(hextx, b2h(op_return_val))
Exemplo n.º 8
0
    def create_transaction(self, inputs, op_return_value):
        tx_outs = self.build_recipient_tx_outs()
        tx_outs.append(
            tx_utils.create_transaction_output(
                self.revocation_address,
                self.tx_cost_constants.get_minimum_output_coin()))

        total = self.estimate_cost_for_certificate_batch()
        transaction = tx_utils.create_trx(op_return_value, total,
                                          self.issuing_address, tx_outs,
                                          inputs)

        return transaction
Exemplo n.º 9
0
    def create_transactions(self, revocation_address):
        """
        Create the batch Bitcoin transaction
        :param revocation_address:
        :return:
        """
        self.tree.make_tree()

        spendables = self.connector.get_unspent_outputs(self.issuing_address)
        if not spendables:
            error_message = 'No money to spend at address {}'.format(
                self.issuing_address)
            logging.error(error_message)
            raise InsufficientFundsError(error_message)

        last_input = spendables[-1]

        op_return_value = unhexlify(self.tree.get_merkle_root())

        tx_outs = self.build_recipient_tx_outs()
        tx_outs.append(
            tx_utils.create_transaction_output(
                revocation_address,
                self.tx_cost_constants.get_minimum_output_coin()))

        transaction = tx_utils.create_trx(op_return_value, self.total,
                                          self.issuing_address, tx_outs,
                                          last_input)

        transaction_data = TransactionData(
            uid=self.batch_id,
            tx=transaction,
            tx_input=last_input,
            op_return_value=hexlify(op_return_value),
            batch_metadata=self.batch_metadata)

        return [transaction_data]