From ad1864e431901528cebadf8075cec26cc09b79f9 Mon Sep 17 00:00:00 2001 From: Daniel Krol Date: Mon, 13 Jun 2022 20:42:56 -0400 Subject: [PATCH] Simple interface to LBRY SDK --- test_client/test_client.py | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test_client/test_client.py b/test_client/test_client.py index 317731e..c216278 100755 --- a/test_client/test_client.py +++ b/test_client/test_client.py @@ -7,6 +7,53 @@ CURRENT_VERSION = 1 WalletState = namedtuple('WalletState', ['sequence', 'encrypted_wallet']) +class LBRYSDK(): + # TODO - error checking + @staticmethod + def get_wallet(wallet_id, password): + response = requests.post('http://localhost:5279', json.dumps({ + "method": "sync_apply", + "params": { + "password": password, + "wallet_id": wallet_id, + }, + })) + return response.json()['result']['data'] + + # TODO - error checking + @staticmethod + def update_wallet(wallet_id, password, data): + response = requests.post('http://localhost:5279', json.dumps({ + "method": "sync_apply", + "params": { + "data": data, + "password": password, + "wallet_id": wallet_id, + }, + })) + return response.json()['result']['data'] + + # TODO - error checking + @staticmethod + def set_preference(key, value): + response = requests.post('http://localhost:5279', json.dumps({ + "method": "preference_set", + "params": { + "key": key, + "value": value, + }, + })) + return response.json()['result'] + + # TODO - error checking + @staticmethod + def get_preferences(): + response = requests.post('http://localhost:5279', json.dumps({ + "method": "preference_get", + "params": {}, + })) + return response.json()['result'] + class WalletSync(): BASE_URL = 'http://localhost:8090' AUTH_URL = BASE_URL + '/auth/full'