commit 3d1fa1e27f06ac8b2f5db5a04e4333fc39a83a84
parent 66f7a6d28ea7e890f67b4da16836cd66412c4123
Author: ThomasV <thomasv@gitorious>
Date: Sat, 28 Mar 2015 20:53:49 +0100
find_pay_to_pubkey_address
Diffstat:
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py
@@ -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()
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -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:
@@ -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:
@@ -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 = {}