n = 0
h = self.wallet.history.get(address,[])
for item in h:
- if not item['is_in'] : n=n+1
+ if not item['is_input'] : n=n+1
tx = "None" if n==0 else "%d"%n
self.recv_list.append((address, label, tx ))
tx_hash = tx['tx_hash']
if tx['height']:
conf = self.wallet.blocks - tx['height'] + 1
- time_str = datetime.datetime.fromtimestamp( tx['nTime']).isoformat(' ')[:-3]
+ time_str = datetime.datetime.fromtimestamp( tx['timestamp']).isoformat(' ')[:-3]
conf_icon = gtk.STOCK_APPLY
else:
conf = 0
if tx['height']:
conf = self.wallet.blocks - tx['height'] + 1
- time_str = datetime.datetime.fromtimestamp( tx['nTime']).isoformat(' ')[:-3]
+ time_str = datetime.datetime.fromtimestamp( tx['timestamp']).isoformat(' ')[:-3]
else:
conf = 0
time_str = 'pending'
tx_hash = tx['tx_hash']
if tx['height']:
conf = self.wallet.blocks - tx['height'] + 1
- time_str = datetime.datetime.fromtimestamp( tx['nTime']).isoformat(' ')[:-3]
+ time_str = datetime.datetime.fromtimestamp( tx['timestamp']).isoformat(' ')[:-3]
icon = QIcon(":icons/confirmed.png")
else:
conf = 0
n = 0
h = self.wallet.history.get(address,[])
for item in h:
- if not item['is_in'] : n=n+1
+ if not item['is_input'] : n=n+1
tx = "None" if n==0 else "%d"%n
item = QTreeWidgetItem( [ address, label, tx] )
item.setFont(0, QFont('monospace'))
DEFAULT_SERVERS = ['electrum.bitcoins.sk','ecdsa.org','electrum.novit.ro'] # list of default servers
+def old_to_new(s):
+ s = s.replace("'blk_hash'", "'block_hash'")
+ s = s.replace("'pos'", "'index'")
+ s = s.replace("'nTime'", "'timestamp'")
+ s = s.replace("'is_in'", "'is_input'")
+ s = s.replace("'raw_scriptPubKey'","'raw_output_script'")
+ return s
+
+
class Interface:
def __init__(self, host, port):
self.host = host
method = c.get('method',None)
if not method:
return
-
+
if error:
print "received error:", c, method, params
else:
def get_history(self, address):
- self.send([('address.get_history', [address] )])
+ self.send([('blockchain.address.get_history', [address] )])
def poll(self):
self.send([('session.poll', [])])
self.rtime = time.time() - t1
self.is_connected = True
+ if cmd == 'h':
+ out = old_to_new(out)
+
if cmd in[ 'peers','h','poll']:
out = ast.literal_eval( out )
-
class HttpInterface(PollingInterface):
def start(self):
traceback.print_exc(file=sys.stdout)
self.is_connected = False
+ # push None so that the getting thread exits its loop
self.responses.put(None)
def send(self, messages):
self.s.send( out )
def get_history(self, addr):
- self.send([('address.get_history', [addr])])
+ self.send([('blockchain.address.get_history', [addr])])
self.addresses_waiting_for_history.append(addr)
def start(self):
f.close()
except:
return
+ data = interface.old_to_new(data)
try:
d = ast.literal_eval( data )
self.seed_version = d.get('seed_version')
h = self.history.get(addr)
if h is None: continue
for item in h:
- if item.get('raw_scriptPubKey'):
+ if item.get('raw_output_script'):
coins.append( (addr,item))
- coins = sorted( coins, key = lambda x: x[1]['nTime'] )
+ coins = sorted( coins, key = lambda x: x[1]['timestamp'] )
inputs = []
for c in coins:
addr, item = c
v = item.get('value')
total += v
- inputs.append((addr, v, item['tx_hash'], item['pos'], item['raw_scriptPubKey'], None, None) )
+ inputs.append((addr, v, item['tx_hash'], item['index'], item['raw_output_script'], None, None) )
fee = self.fee*len(inputs) if fixed_fee is None else fixed_fee
if total >= amount + fee: break
else:
def get_tx_history(self):
lines = self.tx_history.values()
- lines = sorted(lines, key=operator.itemgetter("nTime"))
+ lines = sorted(lines, key=operator.itemgetter("timestamp"))
return lines
def update_tx_history(self):
else:
line['value'] += tx['value']
if line['height'] == 0:
- line['nTime'] = 1e12
+ line['timestamp'] = 1e12
self.update_tx_labels()
def update_tx_labels(self):
response = self.interface.responses.get(True,100000000000) # workaround so that it can be keyboard interrupted
self.handle_response(response)
+
def start_interface(self):
if self.protocol == 'n':
InterfaceClass = NativeInterface