예제 #1
0
def test_eth_sendRawTransaction(web3, wait_for_transaction, extra_accounts):
    private_key = mk_random_privkey()
    address = encode_address(privtoaddr(private_key))

    funding_txn_hash = web3.eth.sendTransaction({
        "from": web3.eth.coinbase,
        "to": address,
        "value": 10000000000000000,
    })
    wait_for_transaction(web3, funding_txn_hash)

    # ethereum-tester-client doesn't quite implement the
    # `sendRawTransaction` correctly because of how the underlying tester
    # evm works.  It needs to know about the address for this to work.
    web3.personal.importRawKey(private_key, "password")
    web3.personal.unlockAccount(address, "password")

    initial_balance = web3.eth.getBalance(extra_accounts[1])

    tx = Transaction(
        web3.eth.getTransactionCount(address),
        web3.eth.gasPrice,
        100000,
        extra_accounts[1],
        1234,
        '',
    )
    tx.sign(private_key)

    raw_tx = rlp.encode(tx)
    raw_tx_hex = encode_data(raw_tx)

    txn_hash = web3.eth.sendRawTransaction(raw_tx_hex)
    wait_for_transaction(web3, txn_hash)
    txn_receipt = web3.eth.getTransactionReceipt(txn_hash)

    after_balance = web3.eth.getBalance(extra_accounts[1])

    assert after_balance - initial_balance == 1234
예제 #2
0
def account_public_key(account_private_key):
    from ethereum.utils import privtoaddr
    return to_normalized_address(
        encode_address(privtoaddr(account_private_key)))
def account_public_key(account_private_key):
    from ethereum.utils import privtoaddr
    return to_normalized_address(encode_address(privtoaddr(account_private_key)))
예제 #4
0
def hex_accounts(accounts):
    return [encode_address(acct) for acct in accounts]
예제 #5
0
def account_public_key(account_private_key):
    from ethereum.utils import privtoaddr
    from testrpc.client.utils import encode_address
    return encode_address(privtoaddr(account_private_key))