From b75f8d795aaaae46435efb824b36a2d3886d4519 Mon Sep 17 00:00:00 2001 From: thomasv Date: Sun, 15 Sep 2013 11:19:48 +0200 Subject: [PATCH] new command: getrawtransaction --- electrum | 2 +- gui/gui_classic/main_window.py | 2 +- lib/commands.py | 9 +++++++-- lib/network.py | 3 ++- lib/verifier.py | 2 -- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/electrum b/electrum index a731e4a..dd02ac0 100755 --- a/electrum +++ b/electrum @@ -356,7 +356,7 @@ if __name__ == '__main__': wallet.update_password(seed, password, new_password) else: - cmd_runner = Commands(wallet, interface) + cmd_runner = Commands(wallet, network) func = eval('cmd_runner.' + cmd) cmd_runner.password = password try: diff --git a/gui/gui_classic/main_window.py b/gui/gui_classic/main_window.py index 57b3944..8e19d70 100644 --- a/gui/gui_classic/main_window.py +++ b/gui/gui_classic/main_window.py @@ -1285,7 +1285,7 @@ class ElectrumWindow(QMainWindow): console.updateNamespace({'wallet' : self.wallet, 'network' : self.network, 'gui':self}) console.updateNamespace({'util' : util, 'bitcoin':bitcoin}) - c = commands.Commands(self.wallet, self.network.interface, lambda: self.console.set_json(True)) + c = commands.Commands(self.wallet, self.network, lambda: self.console.set_json(True)) methods = {} def mkfunc(f, method): return lambda *args: apply( f, (method, args, self.password_dialog )) diff --git a/lib/commands.py b/lib/commands.py index db11eb7..35db962 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -53,6 +53,7 @@ register_command('getbalance', 0, 1, False, False, 'Return the balance register_command('getaddressbalance', 1, 1, False, False, 'Return the balance of an address', 'getbalance
') register_command('getaddresshistory', 1, 1, False, False, 'Return the transaction history of an address', 'getaddresshistory
') register_command('getconfig', 1, 1, False, True, 'Return a configuration variable', 'getconfig ', config_options) +register_command('getrawtransaction', 1, 2, False, False, 'Retrieve a transaction', 'getrawtransaction ') register_command('getseed', 0, 0, True, True, 'Print the generation seed of your wallet.') register_command('help', 0, 1, False, True, 'Prints this help') register_command('history', 0, 0, False, False, 'Returns the transaction history of your wallet') @@ -81,9 +82,9 @@ register_command('verifymessage', 3,-1, False, True, 'Verifies a signatu class Commands: - def __init__(self, wallet, interface, callback = None): + def __init__(self, wallet, network, callback = None): self.wallet = wallet - self.interface = interface + self.network = network self._callback = callback self.password = None @@ -324,4 +325,8 @@ class Commands: if options_syntax: print_msg("options:\n" + options_syntax) return None + def getrawtransaction(self, tx_hash, height = 0): + height = int(height) + return self.network.retrieve_transaction(tx_hash, height) + diff --git a/lib/network.py b/lib/network.py index 81b476e..a1b0f8a 100644 --- a/lib/network.py +++ b/lib/network.py @@ -182,7 +182,8 @@ class Network(threading.Thread): def retrieve_transaction(self, tx_hash, tx_height=0): import transaction r = self.interface.synchronous_get([ ('blockchain.transaction.get',[tx_hash, tx_height]) ])[0] - return transaction.Transaction(r) + if r: + return transaction.Transaction(r) def parse_servers(self, result): diff --git a/lib/verifier.py b/lib/verifier.py index e4b8346..e2509bb 100644 --- a/lib/verifier.py +++ b/lib/verifier.py @@ -35,7 +35,6 @@ class TxVerifier(threading.Thread): self.blockchain = network.blockchain self.interface = network.interface self.transactions = {} # requested verifications (with height sent by the requestor) - #self.interface.register_channel('txverifier') self.verified_tx = storage.get('verified_tx3',{}) # height, timestamp of verified transactions self.merkle_roots = storage.get('merkle_roots',{}) # hashed by me self.lock = threading.Lock() @@ -92,7 +91,6 @@ class TxVerifier(threading.Thread): def stop(self): with self.lock: self.running = False - #self.interface.poke('verifier') def is_running(self): with self.lock: return self.running -- 1.7.1