Example #1
0
import sys
import asyncio

from electrum_zcash.network import filter_protocol, Network
from electrum_zcash.util import create_and_start_event_loop, log_exceptions
from electrum_zcash.simple_config import SimpleConfig

try:
    rawtx = sys.argv[1]
except:
    print("usage: txbroadcast rawtx")
    sys.exit(1)

config = SimpleConfig()

loop, stopping_fut, loop_thread = create_and_start_event_loop()
network = Network(config)
network.start()


@log_exceptions
async def f():
    try:
        peers = await network.get_peers()
        peers = filter_protocol(peers)
        results = await network.send_multiple_requests(
            peers, 'blockchain.transaction.broadcast', [rawtx])
        for server, resp in results.items():
            print(f"result: server={server}, response={resp}")
    finally:
        stopping_fut.set_result(1)
 def setUp(self):
     super().setUp()
     self.asyncio_loop, self._stop_loop, self._loop_thread = create_and_start_event_loop(
     )
     self.config = SimpleConfig({'electrum_path': self.electrum_path})
Example #3
0
 def setUp(self):
     super().setUp()
     self.asyncio_loop, self._stop_loop, self._loop_thread = util.create_and_start_event_loop()
Example #4
0
from electrum_zcash.network import Network
from electrum_zcash.util import print_msg, create_and_start_event_loop
from electrum_zcash.synchronizer import SynchronizerBase
from electrum_zcash.simple_config import SimpleConfig

try:
    addr = sys.argv[1]
except Exception:
    print("usage: watch_address <zcash_address>")
    sys.exit(1)

config = SimpleConfig()

# start network
loop = create_and_start_event_loop()[0]
network = Network(config)
network.start()


class Notifier(SynchronizerBase):
    def __init__(self, network):
        SynchronizerBase.__init__(self, network)
        self.watched_addresses = set()
        self.watch_queue = asyncio.Queue()

    async def main(self):
        # resend existing subscriptions if we were restarted
        for addr in self.watched_addresses:
            await self._add_address(addr)
        # main loop