Exemplo n.º 1
0
def generate(index: int) -> typing.Tuple[LocalAccount, Config]:
    port = 5000 + index
    base_url = f"http://localhost:{port}/api/offchain"
    account = LocalAccount.generate()
    conf = Config(
        wallet_custody_account_name=f"wallet{index}",
        vasp_compliance_key=utils.private_key_bytes(
            Ed25519PrivateKey.generate()).hex(),
        vasp_address=account.account_address.to_hex(),
        base_url=base_url,
        json_rpc_url=testnet.JSON_RPC_URL,
        chain_id=testnet.CHAIN_ID.to_int(),
        gas_currency_code=testnet.TEST_CURRENCY_CODE,
    )
    return (account, conf)
Exemplo n.º 2
0
def test_from_private_key_hex():
    account = LocalAccount.generate()
    hex_key = utils.private_key_bytes(account.private_key).hex()
    new_account = LocalAccount.from_private_key_hex(hex_key)
    assert utils.private_key_bytes(new_account.private_key).hex() == hex_key
Exemplo n.º 3
0
    """)

    exit()

compliance_private_key = Ed25519PrivateKey.generate()

GW_PORT = os.getenv("GW_PORT", 8080)
ENV_FILE_NAME = os.getenv("ENV_FILE_NAME", ".env")
LIQUIDITY_SERVICE_HOST = os.getenv("LIQUIDITY_SERVICE_HOST", "liquidity")
LIQUIDITY_SERVICE_PORT = os.getenv("LIQUIDITY_SERVICE_PORT", 5000)
JSON_RPC_URL = os.getenv("JSON_RPC_URL", "https://testnet.diem.com/v1")
FAUCET_URL = os.getenv("FAUCET_URL", "https://testnet.diem.com/mint")
CHAIN_ID = int(os.getenv("CHAIN_ID", testnet.CHAIN_ID.value))
OFFCHAIN_SERVICE_PORT: int = int(os.getenv("OFFCHAIN_SERVICE_PORT", 8091))
VASP_BASE_URL = os.getenv("VASP_BASE_URL", "http://0.0.0.0:8091")
VASP_COMPLIANCE_KEY = utils.private_key_bytes(compliance_private_key).hex()
VASP_PUBLIC_KEY_BYTES = utils.public_key_bytes(compliance_private_key.public_key())

wallet_account = LocalAccount.generate()

execution_dir_path = os.getcwd()
wallet_env_file_path = os.path.join(execution_dir_path, "vasp/backend", ENV_FILE_NAME)

print(f"Creating {wallet_env_file_path}")

# setup merchant wallet
with open(wallet_env_file_path, "w") as dotenv:
    private_keys = {f"{wallet_account_name}": get_private_key_hex(wallet_account.private_key)}
    wallet_custody_private_keys = json.dumps(private_keys, separators=(',', ':'))
    dotenv.write(f"GW_PORT={GW_PORT}\n")
    dotenv.write(f"WALLET_CUSTODY_ACCOUNT_NAME={wallet_account_name}\n")