コード例 #1
0
async def f():
    try:
        sh = bitcoin.address_to_scripthash(addr)
        hist = await network.get_history_for_scripthash(sh)
        print_msg(json_encode(hist))
    finally:
        stopping_fut.set_result(1)
コード例 #2
0
async def f():
    try:
        await network.interface.session.subscribe('blockchain.headers.subscribe', [], header_queue)
        # 3. wait for results
        while network.is_connected():
            header = await header_queue.get()
            print_msg(json_encode(header))
    finally:
        stopping_fut.set_result(1)
コード例 #3
0
async def f():
    try:

        def get_account_xpub(account_path):
            root_seed = bip39_to_seed(mnemonic, passphrase)
            root_node = BIP32Node.from_rootseed(root_seed, xtype="standard")
            account_node = root_node.subkey_at_private_derivation(account_path)
            account_xpub = account_node.to_xpub()
            return account_xpub

        active_accounts = await account_discovery(network, get_account_xpub)
        print_msg(json_encode(active_accounts))
    finally:
        stopping_fut.set_result(1)
コード例 #4
0
ファイル: console.py プロジェクト: garlicoin-project/garlium
    def exec_command(self, command):
        tmp_stdout = sys.stdout

        class stdoutProxy():
            def __init__(self, write_func):
                self.write_func = write_func
                self.skip = False

            def flush(self):
                pass

            def write(self, text):
                if not self.skip:
                    stripped_text = text.rstrip('\n')
                    self.write_func(stripped_text)
                    QtCore.QCoreApplication.processEvents()
                self.skip = not self.skip

        if type(self.namespace.get(command)) == type(lambda: None):
            self.appendPlainText(
                "'{}' is a function. Type '{}()' to use it in the Python console."
                .format(command, command))
            return

        sys.stdout = stdoutProxy(self.appendPlainText)
        try:
            try:
                # eval is generally considered bad practice. use it wisely!
                result = eval(command, self.namespace, self.namespace)
                if result is not None:
                    if self.is_json:
                        util.print_msg(util.json_encode(result))
                    else:
                        self.appendPlainText(repr(result))
            except SyntaxError:
                # exec is generally considered bad practice. use it wisely!
                exec(command, self.namespace, self.namespace)
        except SystemExit:
            self.close()
        except BaseException:
            traceback_lines = traceback.format_exc().split('\n')
            # Remove traceback mentioning this file, and a linebreak
            for i in (3, 2, 1, -1):
                traceback_lines.pop(i)
            self.appendPlainText('\n'.join(traceback_lines))
        sys.stdout = tmp_stdout
コード例 #5
0
from electrum_grlc.network import Network
from electrum_grlc.util import print_msg, json_encode, create_and_start_event_loop, log_exceptions
from electrum_grlc.simple_config import SimpleConfig

config = SimpleConfig()

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

# wait until connected
while not network.is_connected():
    time.sleep(1)
    print_msg("waiting for network to get connected...")

header_queue = asyncio.Queue()

@log_exceptions
async def f():
    try:
        await network.interface.session.subscribe('blockchain.headers.subscribe', [], header_queue)
        # 3. wait for results
        while network.is_connected():
            header = await header_queue.get()
            print_msg(json_encode(header))
    finally:
        stopping_fut.set_result(1)

# 2. send the subscription
コード例 #6
0
 def yes_no_question(self, msg):
     print_msg(msg)
     return raw_input() in 'yY'
コード例 #7
0
 async def _on_address_status(self, addr, status):
     print_msg(f"addr {addr}, status {status}")