Example #1
0
def eth_sendRawTransaction(raw_tx):
    global evm
    global transaction_contract_addresses

    print 'eth_sendRawTransaction'

    # Get a transaction object from the raw hash.
    tx = rlp.decode(strip_0x(raw_tx).decode("hex"), transactions.Transaction)

    print ""
    print "Raw Transaction Details:"
    print "  "
    print "  From:     " + "0x" + tx.sender.encode("hex")
    print "  To:       " + "0x" + tx.to.encode("hex")
    print "  Gas:      " + int_to_hex(tx.startgas)
    print "  GasPrice: " + int_to_hex(tx.gasprice)
    print "  Value:    " + int_to_hex(tx.value)
    print "  Data:     " + "0x" + tx.data.encode("hex")
    print ""

    (s, r) = processblock.apply_transaction(evm.block, tx)

    if not s:
        raise Exception("Transaction failed")

    if isContract(tx):
        contract_address = r
    else:
        contract_address = None

    tx_hash = "0x" + tx.hash.encode("hex")

    if contract_address != None:
        transaction_contract_addresses[tx_hash] = contract_address

    evm.mine()
    return tx_hash
Example #2
0
def eth_sendRawTransaction(raw_tx):
    global evm
    global transaction_contract_addresses

    print('eth_sendRawTransaction')

    # Get a transaction object from the raw hash.
    tx = rlp.decode(decode_hex(strip_0x(raw_tx)), transactions.Transaction)

    print("")
    print("Raw Transaction Details:")
    print("  ")
    print("  From:     " + "0x" + encode_hex(tx.sender))
    print("  To:       " + "0x" + encode_hex(tx.to))
    print("  Gas:      " + int_to_hex(tx.startgas))
    print("  GasPrice: " + int_to_hex(tx.gasprice))
    print("  Value:    " + int_to_hex(tx.value))
    print("  Data:     " + "0x" + encode_hex(tx.data))
    print("")

    (s, r) = processblock.apply_transaction(evm.block, tx)

    if not s:
        raise Exception("Transaction failed")

    if isContract(tx):
        contract_address = r
    else:
        contract_address = None

    tx_hash = "0x" + encode_hex(tx.hash)

    if contract_address != None:
        transaction_contract_addresses[tx_hash] = contract_address

    mine(evm)
    return tx_hash
Example #3
0
def eth_sendRawTransaction(raw_tx):
    global evm
    global transaction_contract_addresses

    print 'eth_sendRawTransaction'

    # Get a transaction object from the raw hash.
    tx = rlp.decode(strip_0x(raw_tx).decode("hex"), transactions.Transaction)

    print ""
    print "Raw Transaction Details:"
    print "  "
    print "  From:     " + "0x" + tx.sender.encode("hex")
    print "  To:       " + "0x" + tx.to.encode("hex")
    print "  Gas:      " + int_to_hex(tx.startgas)
    print "  GasPrice: " + int_to_hex(tx.gasprice)
    print "  Value:    " + int_to_hex(tx.value)
    print "  Data:     " + "0x" + tx.data.encode("hex")
    print ""

    (s, r) = processblock.apply_transaction(evm.block, tx)

    if not s:
        raise Exception("Transaction failed")

    if isContract(tx):
        contract_address = r
    else:
        contract_address = None

    tx_hash = "0x" + tx.hash.encode("hex")

    if contract_address != None:
        transaction_contract_addresses[tx_hash] = contract_address

    evm.mine()
    return tx_hash