Esempio n. 1
0
def test_all(server_db):

    # fund server
    for i in range(3):
        address = lib.get_funding_addresses([ASSET])[ASSET]
        rawtx = api.create_send(
            **{
                'source': FUNDING_ADDRESS,
                'destination': address,
                'asset': ASSET,
                'quantity': 1000000,
                'regular_dust_size': 1000000
            })
        api.sendrawtransaction(tx_hex=rawtx)

    # connect clients
    assert len(api.mph_connections()) == 0
    clients = []
    for i in range(3):
        bob_wif = util.gen_funded_wif(ASSET, 1000000, 1000000)
        client = Mph(util.MockAPI(auth_wif=bob_wif))
        client.connect(1000000, 65535, asset=ASSET)
        clients.append(client)

    connections = api.mph_connections()
    assert len(connections) == 3
    for connection in connections:
        jsonschema.validate(connection, CONNECTION_RESULT_SCHEMA)
        auth.verify_json(connection)
Esempio n. 2
0
 def wrapper(*args, **kwargs):
     kwargs = copy.deepcopy(kwargs)  # simulate http serialization
     if name in auth_methods:
         privkey = keys.wif_to_privkey(self.auth_wif)
         kwargs = auth.sign_json(kwargs, privkey)
     result = object.__getattribute__(api, name)(**kwargs)
     if name in auth_methods:
         auth.verify_json(result)
     return result
Esempio n. 3
0
def mph_sync(**kwargs):
    with etc.database_lock:
        auth.verify_json(kwargs)
        verify.sync_input(kwargs["handle"], kwargs["next_revoke_secret_hash"],
                          kwargs["pubkey"], kwargs.get("sends"),
                          kwargs.get("commit"), kwargs.get("revokes"))
        result, authwif = lib.sync_hub_connection(
            kwargs["handle"], kwargs["next_revoke_secret_hash"],
            kwargs.get("sends"), kwargs.get("commit"), kwargs.get("revokes"))
        return auth.sign_json(result, keys.wif_to_privkey(authwif))
Esempio n. 4
0
def mph_deposit(**kwargs):
    with etc.database_lock:
        auth.verify_json(kwargs)
        verify.deposit_input(kwargs["handle"], kwargs["deposit_script"],
                             kwargs["next_revoke_secret_hash"],
                             kwargs["pubkey"])
        result, authwif = lib.complete_connection(
            kwargs["handle"], kwargs["deposit_script"],
            kwargs["next_revoke_secret_hash"])
        return auth.sign_json(result, keys.wif_to_privkey(authwif))
Esempio n. 5
0
def mph_request(**kwargs):
    with etc.database_lock:
        auth.verify_json(kwargs)
        verify.request_input(kwargs["asset"], kwargs["pubkey"],
                             kwargs["spend_secret_hash"],
                             kwargs.get("hub_rpc_url"))
        result, authwif = lib.create_hub_connection(
            kwargs["asset"], kwargs["pubkey"], kwargs["spend_secret_hash"],
            kwargs.get("hub_rpc_url"))
        return auth.sign_json(result, keys.wif_to_privkey(authwif))