Beispiel #1
0
async def fetch():
    # WIF private keys
    keys = ["cVks5KCc8BBVhWnTJSLjr5odLbNrWK9UY4KprciJJ9dqiDBenhzr"]

    # Convert them to addresses
    addrs = [wallet.key_to_address(key) for key in keys]
    print("Our addresses:", addrs)

    async with nym_proxy.NymProxy(9001) as nym:
        nym_address = await nym.details()

        multi = multipart.Multipart(nym)

        blockchain_request = {
            "command": "fetch_history",
            "addrs": addrs,
            "return-recipient": nym_address
        }
        print("Sending:", blockchain_request)

        nym_server_address = "AGdb5ZwZBpazKysh9ijCwgzCVRYcvadEhvaxQ3mkBnur"
        await multi.send(blockchain_request, nym_server_address)

        history = await multi.receive()
        display_history(history)
Beispiel #2
0
async def fetch():
    # WIF private keys
    keys = ["cVks5KCc8BBVhWnTJSLjr5odLbNrWK9UY4KprciJJ9dqiDBenhzr"]

    # Convert them to addresses
    addrs = [wallet.key_to_address(key) for key in keys]
    print("Our addresses:", addrs)

    uri = "ws://85.90.245.20:8765"
    async with websockets.connect(uri) as websocket:
        #await websocket.send(name)
        #greeting = await websocket.recv()

        multi = multipart.Multipart(websocket)

        blockchain_request = {
            "command": "fetch_history",
            "addrs": addrs,
            "return-recipient": "none"
        }
        print("Sending:", blockchain_request)

        await multi.send(blockchain_request)

        history = await multi.receive()
        display_history(history)
Beispiel #3
0
def GenerateMultipartFormDataCTAndBodyFromDict(fields):

    m = multipart.Multipart()

    for (name, value) in fields.items():

        m.field(name, HydrusData.ToByteString(value))

    return m.get()
Beispiel #4
0
async def accept():
    async with nym_proxy.NymProxy(9001) as nym:
        print("Server address =", await nym.details())

        multi = multipart.Multipart(nym)

        while True:
            message = await multi.receive()
            await process(message, multi)
            await asyncio.sleep(0.1)
Beispiel #5
0
async def broadcast(tx_data):
    async with nym_proxy.NymProxy(9001) as nym:
        multi = multipart.Multipart(nym)

        request = {"command": "broadcast", "tx_data": tx_data}

        nym_server_address = "kauuj71-RPvETjz8FMQugnsNSDJ8033E4lNS_anMFD0="
        await multi.send(request, nym_server_address)

        print("Sent.")
        await asyncio.sleep(4)
Beispiel #6
0
async def broadcast(tx_data):
    uri = "ws://localhost:8765"
    async with websockets.connect(uri) as websocket:
        multi = multipart.Multipart(websocket)

        request = {"command": "broadcast", "tx_data": tx_data}

        await multi.send(request)

        print("Sent.")
        await asyncio.sleep(4)
Beispiel #7
0
async def accept(websocket, path):
    multi = multipart.Multipart(websocket)

    while True:
        try:
            message = await multi.receive()
            await process(message, multi)
        except websockets.exceptions.ConnectionClosedOK:
            print("Websocket closed. Exiting...")
            return

        await asyncio.sleep(0.1)
    def post(self, path, body):
        """Send a POST request to the Ning API."""
        if 'file' in body:
            mp = multipart.Multipart()
            mp.attach(
                multipart.FilePart({'name': 'file'}, body['file'],
                                   body['content_type']))
            for k, v in body.items():
                if k != 'file' and k != 'content_type':
                    mp.attach(multipart.Part({'name': k}, v))
            return self.call("Photo",
                             method="POST",
                             token=self.token,
                             headers={'Content-Type': mp.header()[1]},
                             body=str(mp))

        elif 'bin' in body:
            mp = multipart.Multipart()
            mp.attach(
                multipart.Part({
                    'name': 'file',
                    'filename': 'file'
                }, body['bin'], body['content_type']))

            for k, v in body.items():
                if k != 'bin' and k != 'content_type':
                    mp.attach(multipart.Part({'name': k}, v))
            return self.call("Photo",
                             method="POST",
                             token=self.token,
                             headers={'Content-Type': mp.header()[1]},
                             body=str(mp))

        else:
            return self.call(path,
                             method="POST",
                             token=self.token,
                             body=urllib.urlencode(body))