From: ThomasV Date: Wed, 29 Jan 2014 15:27:04 +0000 (+0100) Subject: address.get_proof, utxo.get_address X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=commitdiff_plain;h=f758aa692b0f6eb5826afe30b013f98aa77ad5ba address.get_proof, utxo.get_address --- diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 18117fa..28e87c8 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -490,10 +490,10 @@ class BlockchainProcessor(Processor): error = str(e) + ': ' + address print_log("error:", error) - elif method == 'blockchain.address.get_path': + elif method == 'blockchain.address.get_proof': try: address = str(params[0]) - result = self.storage.get_address_path(address) + result = self.storage.get_proof(address) except BaseException, e: error = str(e) + ': ' + address print_log("error:", error) @@ -506,12 +506,22 @@ class BlockchainProcessor(Processor): error = str(e) + ': ' + address print_log("error:", error) + elif method == 'blockchain.utxo.get_address': + try: + txid = str(params[0]) + pos = int(params[1]) + txi = (txid + int_to_hex(pos, 4)).decode('hex') + result = self.storage.get_address(txi) + except BaseException, e: + error = str(e) + print_log("error:", error, txid, pos) + elif method == 'blockchain.block.get_header': if cache_only: result = -1 else: try: - height = params[0] + height = int(params[0]) result = self.get_header(height) except BaseException, e: error = str(e) + ': %d' % height @@ -522,7 +532,7 @@ class BlockchainProcessor(Processor): result = -1 else: try: - index = params[0] + index = int(params[0]) result = self.get_chunk(index) except BaseException, e: error = str(e) + ': %d' % index diff --git a/backends/bitcoind/storage.py b/backends/bitcoind/storage.py index 36f1366..7658b49 100644 --- a/backends/bitcoind/storage.py +++ b/backends/bitcoind/storage.py @@ -68,10 +68,13 @@ class Storage(object): return hash_160_to_bc_address(addr) - def get_address_path(self, addr): + def get_proof(self, addr): key = self.address_to_key(addr) - p = self.get_path(key) - p.append(key) + i = self.db_utxo.iterator(start=key) + k, _ = i.next() + + p = self.get_path(k) + p.append(k) out = [] for item in p: