Add password authentication

master
dsc 3 years ago
parent db857d981c
commit df6d4ed158

@ -24,7 +24,18 @@ import asyncio
from wowlet_ws_client.client import WowletWSClient
wowlet = WowletWSClient(host="127.0.0.1", port=42069, debug=True)
wowlet = WowletWSClient(
host="127.0.0.1", port=1234, password="sekrit", debug=True)
@wowlet.event("passwordIncorrect")
async def on_password_incorrect(data):
print(data)
@wowlet.event("passwordSuccess")
async def on_password_success(data):
print(data)
@wowlet.event("walletList")
@ -63,7 +74,9 @@ async def on_transaction_commited(data):
async def main():
await wowlet.connect()
await asyncio.sleep(2)
await asyncio.sleep(3)
await wowlet.authenticate()
await asyncio.sleep(3)
await wowlet.open_wallet("/home/user/Wownero/wallets/wstest.keys", "test")

@ -12,9 +12,10 @@ from wowlet_ws_client import WowletState, decorator_parametrized, WALLET_OPERATI
class WowletWSClient:
def __init__(self, host: str = "127.0.0.1", port: int = 42069, debug: bool = False):
def __init__(self, host: str = "127.0.0.1", port: int = 42069, password: str = None, debug: bool = False):
self.host = host
self.port = port
self.password = password
self.ses = aiohttp.ClientSession()
self.debug = debug
@ -178,6 +179,14 @@ class WowletWSClient:
self._ws = await self.ses.ws_connect(f"ws://{self.host}:{self.port}")
self._loop_task = asyncio.create_task(self.loop())
async def authenticate(self):
return await self.send(json.dumps({
"cmd": "password",
"data": {
"password": self.password
}
}).encode())
async def send(self, data: bytes) -> None:
return await self._ws.send_bytes(data)

Loading…
Cancel
Save