Example #1
0
def get_aeternity():
    """get the epoch client and the genesis keypair from config"""
    # configure epoch client in case we need it

    epoch = EpochClient(configs=Config(external_host=epoch_node,
                                       internal_host=f"{epoch_node}/internal",
                                       secure_connection=True))

    logging.info(f"using node at {epoch_node}")

    # load the genesis keypair
    gp = bar_wallet_address
    gk = bar_wallet_private
    main_wallet = KeyPair.from_public_private_key_strings(gp, gk)

    return epoch, main_wallet
Example #2
0
def test_create_transaction_signing():
    client = EpochClient()
    # generate a new keypair
    new_keypair = KeyPair.generate()
    receiver_address = new_keypair.get_address()
    # get the test keypair
    keypair = KeyPair.from_public_private_key_strings(PUBLIC_KEY, PRIVATE_KEY)
    # create a spend transaction
    transaction = client.create_spend_transaction(PUBLIC_KEY, receiver_address,
                                                  321)
    signed_transaction, b58signature = keypair.sign_transaction(transaction)
    # post the transaction
    result = client.send_signed_transaction(signed_transaction)
    assert result is not None
    assert result.tx_hash is not None
    print(result)

    # make sure this works for very short block times
    client.wait_for_next_block(polling_interval=0.01)
    spend_tx = client.get_transaction_by_transaction_hash(result.tx_hash,
                                                          tx_encoding='json')
    assert spend_tx.transaction['signatures'][0] == b58signature
import logging
import os
from aeternity.config import Config
from aeternity.signing import KeyPair

logging.getLogger("requests").setLevel(logging.DEBUG)
logging.getLogger("urllib3").setLevel(logging.DEBUG)

PUBLIC_KEY = os.environ.get('WALLET_PUB')
PRIVATE_KEY = os.environ.get('WALLET_PRIV')
NODE_URL = os.environ.get('TEST_URL')
NODE_URL_INTERNAL = os.environ.get('TEST_INTERNAL_URL')
EPOCH_VERSION = '0.18.0'
# set the key folder as environment variables
KEYPAIR = KeyPair.from_public_private_key_strings(PUBLIC_KEY, PRIVATE_KEY)

Config.set_defaults(
    Config(external_url=NODE_URL, internal_url=NODE_URL_INTERNAL))