コード例 #1
0
ファイル: history_list.py プロジェクト: mikakzm/electrum-ltc
 def do_export_history(self, file_name, is_csv):
     hist = self.wallet.get_detailed_history(fx=self.parent.fx)
     txns = hist['transactions']
     lines = []
     if is_csv:
         for item in txns:
             lines.append([item['txid'],
                           item.get('label', ''),
                           item['confirmations'],
                           item['bc_value'],
                           item.get('fiat_value', ''),
                           item.get('fee', ''),
                           item.get('fiat_fee', ''),
                           item['date']])
     with open(file_name, "w+", encoding='utf-8') as f:
         if is_csv:
             import csv
             transaction = csv.writer(f, lineterminator='\n')
             transaction.writerow(["transaction_hash",
                                   "label",
                                   "confirmations",
                                   "value",
                                   "fiat_value",
                                   "fee",
                                   "fiat_fee",
                                   "timestamp"])
             for line in lines:
                 transaction.writerow(line)
         else:
             from electrum_ltc.util import json_encode
             f.write(json_encode(txns))
コード例 #2
0
 def do_export_history(self, wallet, fileName, is_csv):
     history = self.transactions
     lines = []
     for item in history:
         if is_csv:
             lines.append([
                 item['txid'],
                 item.get('label', ''), item['confirmations'],
                 item['value'], item['date']
             ])
         else:
             lines.append(item)
     with open(fileName, "w+", encoding='utf-8') as f:
         if is_csv:
             import csv
             transaction = csv.writer(f, lineterminator='\n')
             transaction.writerow([
                 "transaction_hash", "label", "confirmations", "value",
                 "timestamp"
             ])
             for line in lines:
                 transaction.writerow(line)
         else:
             from electrum_ltc.util import json_encode
             f.write(json_encode(history))
コード例 #3
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)
コード例 #4
0
ファイル: get_history.py プロジェクト: thrasher-/electrum-ltc
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)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
ファイル: console.py プロジェクト: woodcoin-core/electrum-ltc
    def runCommand(self):
        command = self.getCommand()
        self.addToHistory(command)

        command = self.getConstruct(command)

        if 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(
                    "'%s' is a function. Type '%s()' to use it in the Python console."
                    % (command, command))
                self.newPrompt()
                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 != 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 in self.namespace
            except SystemExit:
                self.close()
            except Exception:
                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
        self.newPrompt()
        self.set_json(False)
コード例 #8
0
ファイル: console.py プロジェクト: thrasher-/electrum-ltc
    def runCommand(self):
        command = self.getCommand()
        self.addToHistory(command)

        command = self.getConstruct(command)

        if 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))
                self.newPrompt()
                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 != 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
        self.newPrompt()
        self.set_json(False)
コード例 #9
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)
コード例 #10
0
#!/usr/bin/env python3

# A simple script that connects to a server and displays block headers

import time
from .. import SimpleConfig, Network
from electrum_ltc.util import print_msg, json_encode

# start network
c = SimpleConfig()
network = Network(c)
network.start()

# wait until connected
while network.is_connecting():
    time.sleep(0.1)

if not network.is_connected():
    print_msg("daemon is not connected")
    sys.exit(1)

# 2. send the subscription
callback = lambda response: print_msg(json_encode(response.get('result')))
network.send([('server.version', ["block_headers script", "1.2"])], callback)
network.subscribe_to_headers(callback)

# 3. wait for results
while network.is_connected():
    time.sleep(1)
コード例 #11
0
#!/usr/bin/env python3

import sys
from .. import Network
from electrum_ltc.util import json_encode, print_msg
from electrum_ltc import bitcoin

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

n = Network()
n.start()
_hash = bitcoin.address_to_scripthash(addr)
h = n.get_history_for_scripthash(_hash)
print_msg(json_encode(h))