Skip to content

A simple, high-level, and fully asynchronous JSON-RPC client library for JoinMarket

License

Notifications You must be signed in to change notification settings

PulpCattel/jmrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jmrpc (WIP)

A simple, high-level, and fully asynchronous JSON-RPC client library for JoinMarket.

Requirements

Installation

git clone https://github.com/PulpCattel/jmrpc
cd jmrpc
pip3 install -e .

Usage

from asyncio import run
from jmrpc import JmRpc

async def main() -> None:
    async with JmRpc() as jmrpc:
        response = await jmrpc.list_wallets()

if __name__ == '__main__':
    run(main())

JoinMarket server uses HTTPS, and by default this library (for now) looks for cert.pem file in /home/user/.joinmarket/ssl/.

For easier testing you may want to skip SSL cert verification, e.g.:

response = await jmrpc.list_wallets(ssl=False)

For more info see here.

response is a model representation of the response content from JoinMarket.

print(response['wallets'])
print(response.wallets)
print(response.dict)

Output:

['wallet.jmdat', 'wallet1.jmdat', 'wallet2.jmdat']
['wallet.jmdat', 'wallet1.jmdat', 'wallet2.jmdat']
{'wallets': ['wallet.jmdat', 'wallet1.jmdat', 'wallet2.jmdat']}

JoinMarket offers a websocket, which serves notifications to all authenticated clients.

from asyncio import run
from jmrpc import JmRpc

async def main() -> None:
    # Websocket automatically connected when using a context manager.
    async with JmRpc() as jmrpc:
        # Unlock and Create both automatically authenticate to the websocket.
        await jmrpc.unlock_wallet('wallet.jmdat', 'password')
        # Now we can wait for notifications.
        async for msg in jmrpc.ws_read():
            # Like the HTTP response, `msg` here is an object representation
            # of the data read from the websocket.
            print(msg)
            print(msg.dict)

if __name__ == '__main__':
    run(main())

About

A simple, high-level, and fully asynchronous JSON-RPC client library for JoinMarket

Topics

Resources

License

Stars

Watchers

Forks

Languages