예제 #1
0
파일: wallet.py 프로젝트: nondejus/wallets
async def ledger_sim_proxy():
    """
    Return an async proxy to the ledger sim instance running on 9868.
    """
    from chiasim.clients import ledger_sim
    from chiasim.remote.client import request_response_proxy

    reader, writer = await asyncio.open_connection(host="localhost", port=9868)
    proxy = request_response_proxy(reader, writer, ledger_sim.REMOTE_SIGNATURES)
    return proxy
예제 #2
0
def main(args=sys.argv):
    parser = argparse.ArgumentParser(description="Chia client.")

    parser.add_argument("-p", "--port", help="remote port", default=9868)
    parser.add_argument("host", help="remote host")
    parser.add_argument("function", help="function")
    parser.add_argument("arguments",
                        help="arguments (as json)",
                        type=json.loads)

    args = parser.parse_args(args=args[1:])

    init_logging()

    run = asyncio.get_event_loop().run_until_complete

    reader, writer = run(asyncio.open_connection(args.host, args.port))
    ledger_api = request_response_proxy(reader, writer)

    r = run(getattr(ledger_api, args.function)(**args.arguments))
    print(r)
예제 #3
0
async def proxy_for_unix_connection(path):
    reader, writer = await asyncio.open_unix_connection(path)
    return request_response_proxy(reader, writer, ledger_sim.REMOTE_SIGNATURES)
예제 #4
0
async def connect_to_ledger_sim(host="localhost", port=9868):
    reader, writer = await asyncio.open_connection(host, port)
    return request_response_proxy(reader, writer, REMOTE_SIGNATURES)
예제 #5
0
async def proxy_for_unix_connection(path):
    reader, writer = await asyncio.open_unix_connection(str(path))
    return request_response_proxy(reader, writer)