示例#1
0
 def create_transaction(self, node, coin, to_address, amount):
     outputs = {to_address: amount}
     rawtx = node.createrawtransaction([coin], outputs)
     tx = CTransaction()
     f = BytesIO(hex_str_to_bytes(rawtx))
     tx.deserialize(f)
     tx.nVersion = 2
     return tx
示例#2
0
 def create_transaction(self, node, coinbase, to_address, amount):
     from_txid = node.getblock(coinbase)['tx'][0]
     inputs = [{"txid": from_txid, "vout": 0}]
     outputs = {to_address: amount}
     rawtx = node.createrawtransaction(inputs, outputs)
     tx = CTransaction().deserialize(rawtx)
     tx.nVersion = 2
     return tx
示例#3
0
 def create_transaction(self, node, coinbase, to_address, amount):
     from_txid = node.getblock(coinbase)['tx'][0]
     inputs = [{ "txid" : from_txid, "vout" : 0}]
     outputs = { to_address : amount }
     rawtx = node.createrawtransaction(inputs, outputs)
     tx = CTransaction()
     f = cStringIO.StringIO(unhexlify(rawtx))
     tx.deserialize(f)
     tx.nVersion = 2
     return tx
示例#4
0
 def test_submitbranchblockinfo(self):
     '''
     submitbranchblockinfo "CTransaction hex data"
     Include branch block data to a transaction, then send to main chain
     :return:
     '''
     self.log.info(sys._getframe().f_code.co_name)
     txid = self.node0.sendtoaddress(self.node0.getnewaddress(), 1)
     tx_hex = self.node0.getrawtransaction(txid)
     assert_raises_rpc_error(-32602, 'Invalid transaction data',
                             self.node0.submitbranchblockinfo, tx_hex)
     assert_raises_rpc_error(
         -32602, 'This rpc api can not be called in branch chain',
         self.snode0.submitbranchblockinfo, tx_hex)
     tx = CTransaction()
     tx.nVersion = 9
     tx.rehash()
     assert_raises_rpc_error(-4, 'DecodeHexTx tx hex fail',
                             self.node0.submitbranchblockinfo, tx.hash)