示例#1
0
def test_p2p_by_travel_rule():
    sender = context.generate(1)
    receiver = context.generate(2)
    faucet = testnet.Faucet(sender.jsonrpc_client)
    faucet.mint(sender.auth_key().hex(), 2_000_000_000,
                sender.config.gas_currency_code)
    faucet.mint(receiver.auth_key().hex(), 1_000,
                receiver.config.gas_currency_code)
    receiver.reset_dual_attestation_info()

    reference_id = "reference_id"
    amount = 1_800_000_000
    metadata, sig_msg = txnmetadata.travel_rule(
        reference_id,
        sender.config.vasp_account_address(),
        amount,
    )
    metadata_signature = receiver.config.compliance_private_key().sign(sig_msg)
    txn = sender.p2p_by_travel_rule(
        receiver.config.vasp_address,
        testnet.TEST_CURRENCY_CODE,
        amount,
        metadata,
        metadata_signature,
    )

    assert txn
    assert txn.transaction.sender.lower() == sender.config.vasp_address
    script = txn.transaction.script
    assert script.receiver.lower() == receiver.config.vasp_address
    assert script.amount == amount
    assert script.metadata_signature == metadata_signature.hex()

    metadata = diem_types.Metadata.bcs_deserialize(
        bytes.fromhex(script.metadata))
    assert isinstance(metadata, diem_types.Metadata__TravelRuleMetadata)
    assert metadata.value.value.off_chain_reference_id == reference_id
示例#2
0
def main():
    wallet_ctx = context.generate(1)
    wallet_ctx.config.base_url = VASP_BASE_URL

    setup_wallet(wallet_ctx)
示例#3
0
        encoding=serialization.Encoding.Raw,
        format=serialization.PrivateFormat.Raw,
        encryption_algorithm=serialization.NoEncryption(),
    ).hex()


ENV_FILE_NAME = os.getenv("ENV_FILE_NAME", ".env")
print(f"env file name: {ENV_FILE_NAME}")

GW_PORT = int(os.getenv("GW_PORT", 8080))
GW_OFFCHAIN_SERVICE_PORT = int(os.getenv("GW_OFFCHAIN_SERVICE_PORT", 8091))
VASP_BASE_URL = os.getenv("VASP_BASE_URL", "http://localhost:8091")
LIQUIDITY_SERVICE_HOST = os.getenv("LIQUIDITY_SERVICE_HOST", "liquidity")
LIQUIDITY_SERVICE_PORT = int(os.getenv("LIQUIDITY_SERVICE_PORT", 5000))

ctx = context.generate(1)
ctx.config.base_url = VASP_BASE_URL
faucet = testnet.Faucet(ctx.jsonrpc_client)

print("Mint currencies to wallet account")
faucet.mint(ctx.auth_key().hex(), 1_000_000, "Coin1")
print("Reset wallet account dual attestation info")
ctx.reset_dual_attestation_info()


execution_dir_path = os.getcwd()
wallet_env_file_path = os.path.join(execution_dir_path, "backend", ENV_FILE_NAME)
liquidity_env_file_path = os.path.join(execution_dir_path, "liquidity", ENV_FILE_NAME)

print(f"Creating {wallet_env_file_path}")
示例#4
0
def lrw2() -> offchain_business.LRW:
    return offchain_business.LRW(context.generate(2))