tfind_pay_to_pubkey_address - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 3d1fa1e27f06ac8b2f5db5a04e4333fc39a83a84 DIR parent 66f7a6d28ea7e890f67b4da16836cd66412c4123 HTML Author: ThomasV <thomasv@gitorious> Date: Sat, 28 Mar 2015 20:53:49 +0100 find_pay_to_pubkey_address Diffstat: M gui/qt/transaction_dialog.py | 9 +++++++-- M lib/wallet.py | 32 +++++++++++++++---------------- 2 files changed, 22 insertions(+), 19 deletions(-) --- DIR diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py t@@ -216,10 +216,15 @@ class TxDialog(QDialog): if x.get('is_coinbase'): cursor.insertText('coinbase') else: - _hash = x.get('prevout_hash') - cursor.insertText(_hash[0:8] + '...' + _hash[-8:] + ":%d"%x.get('prevout_n'), ext) + prevout_hash = x.get('prevout_hash') + prevout_n = x.get('prevout_n') + cursor.insertText(prevout_hash[0:8] + '...' + prevout_hash[-8:] + ":%d"%prevout_n, ext) cursor.insertText('\t') addr = x.get('address') + if addr == "(pubkey)": + _addr = self.wallet.find_pay_to_pubkey_address(prevout_hash, prevout_n) + if _addr: + addr = _addr cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) cursor.insertBlock() DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -588,6 +588,13 @@ class Abstract_Wallet(object): status += tx_hash + ':%d:' % height return hashlib.sha256( status ).digest().encode('hex') + def find_pay_to_pubkey_address(self, prevout_hash, prevout_n): + dd = self.txo.get(prevout_hash, {}) + for addr, l in dd.items(): + for n, v, is_cb in l: + if n == prevout_n: + return addr + def add_transaction(self, tx_hash, tx, tx_height): is_coinbase = tx.inputs[0].get('prevout_hash') == '0'*64 with self.transaction_lock: t@@ -595,10 +602,17 @@ class Abstract_Wallet(object): self.txi[tx_hash] = d = {} for txi in tx.inputs: addr = txi.get('address') - if addr and self.is_mine(addr): + if not txi.get('is_coinbase'): prevout_hash = txi['prevout_hash'] prevout_n = txi['prevout_n'] ser = prevout_hash + ':%d'%prevout_n + if addr == "(pubkey)": + addr = self.find_pay_to_pubkey_address(prevout_hash, prevout_n) + if addr: + print_error("found pay-to-pubkey address:", addr) + else: + self.reverse_txo[ser] = tx_hash + if addr and self.is_mine(addr): dd = self.txo.get(prevout_hash, {}) for n, v, is_cb in dd.get(addr, []): if n == prevout_n: t@@ -608,22 +622,6 @@ class Abstract_Wallet(object): break else: self.reverse_txo[ser] = tx_hash - elif addr == "(pubkey)": - prevout_hash = txi['prevout_hash'] - prevout_n = txi['prevout_n'] - ser = prevout_hash + ':%d'%prevout_n - dd = self.txo.get(prevout_hash, {}) - found = False - for _addr, l in dd.items(): - for n, v, is_cb in l: - if n == prevout_n: - print_error("found pay-to-pubkey address:", _addr) - if d.get(_addr) is None: - d[_addr] = [] - d[_addr].append((ser, v)) - found = True - if not found: - self.reverse_txo[ser] = tx_hash # add outputs self.txo[tx_hash] = d = {}