示例#1
0
def test_create_transaction_signing():
    client = EpochClient()

    new_keypair = KeyPair.generate()
    receiver_address = new_keypair.get_address()

    keypair = KeyPair.read_from_dir('/home/tom/data/aeternity/epoch/_build/dev1/rel/epoch/data/aecore/keys/', 'secret')

    transaction = client.create_spend_transaction(receiver_address, 10)
    signed_transaction, b58signature = keypair.sign_transaction(transaction)
    result = client.send_signed_transaction(signed_transaction)
    assert result == {}

    current_block = client.get_latest_block()
    # make sure this works for very short block times
    client.wait_for_next_block(polling_interval=0.01)
    next_block = client.get_latest_block()
    # find the transaction that is the spend transaction we just submitted
    spend_tx = next(tx for tx in next_block.transactions if type(tx.tx) == SpendTx)
    assert spend_tx.signatures[0] == b58signature
示例#2
0
        sys.exit(1)
    keypair.save_to_folder(path)
    address = keypair.get_address()
    print('You wallet has been generated:')
    print('Address: %s' % address)
    print('Saved to: %s' % path)
elif main_arg == 'wallet':
    wallet_path = args[2]
    keypair = read_keypair(wallet_path)
    print('Address: %s' % keypair.get_address())
elif main_arg == 'inspect':
    inspect_what = args[1]
    if inspect_what == 'block':
        block_id = args[2]
        if block_id == 'latest':
            block = client.get_latest_block()
        elif block_id.startswith('bh$'):
            block = client.get_block_by_hash(block_id)
        else:
            block = client.get_block_by_height(block_id)
        print(block)
    elif inspect_what == 'transaction' or inspect_what == 'tx':
        transaction_hash = args[2]
        if not transaction_hash.startswith('th$'):
            stderr('A transaction hash must start with "th$"')
            sys.exit(1)
        transaction = client.get_transaction_by_transaction_hash(
            transaction_hash)
        print(transaction)
    else:
        stderr('Can only inspect `block`.')