Exemple #1
0
 def wrapper(*args, **kwargs):
     kwargs = copy.deepcopy(kwargs)  # simulate http serialization
     if name in auth_methods:
         kwargs = auth.sign_json(kwargs, self.auth_wif)
     result = object.__getattribute__(api, name)(**kwargs)
     if name in auth_methods:
         auth.verify_json(result)
     return result
Exemple #2
0
 def wrapper(*args, **kwargs):
     kwargs = copy.deepcopy(kwargs)  # simulate http serialization
     if name in auth_methods:
         kwargs = auth.sign_json(kwargs, self.auth_wif)
     result = object.__getattribute__(api, name)(**kwargs)
     if name in auth_methods:
         auth.verify_json(result)
     return result
Exemple #3
0
def mph_close(**kwargs):
    with etc.database_lock:
        auth.verify_json(kwargs)
        verify.close_input(
            kwargs["handle"],
            kwargs["pubkey"],
            kwargs.get("spend_secret"),
        )
        result, authwif = lib.close_connection(
            kwargs["handle"],
            kwargs.get("spend_secret"),
        )
        return auth.sign_json(result, authwif)
Exemple #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, authwif)
Exemple #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, authwif)
Exemple #6
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, authwif)
def mph_sync(**kwargs):
    auth.verify_json(kwargs)
    auth_wif = "cT9pEqELRn5v67hJmmmYQmPnsuezJeup7CqQiJBUTZnLLoxdydAb"
    return auth.sign_json({"foo": "bar"}, auth_wif)
 def test_sign_verify_json(self):
     auth_wif = keys.generate_wif()
     signed_json_data = auth.sign_json({"foo": "bar"}, auth_wif)
     valid = auth.verify_json(signed_json_data)
     self.assertTrue(valid)
 def func():
     auth_wif = keys.generate_wif()
     data = {"foo": "bar", "pubkey": "invalid"}
     signed_json_data = auth.sign_json(data, auth_wif)
     auth.verify_json(signed_json_data)