Browse Source

Merge branch 'master' of git://gitorious.org/electrum/electrum

283
thomasv 13 years ago
parent
commit
4a884cc8d9
  1. 22
      client/electrum
  2. 11
      client/gui.py
  3. 12
      client/wallet.py

22
client/electrum

@ -21,13 +21,14 @@ import re, sys, getpass
from optparse import OptionParser
from wallet import Wallet
from interface import Interface
from decimal import Decimal
# URL decode
_ud = re.compile('%([0-9a-hA-H]{2})', re.MULTILINE)
urldecode = lambda x: _ud.sub(lambda m: chr(int(m.group(1), 16)), x)
from wallet import format_satoshis
if __name__ == '__main__':
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'gui', 'mktx','seed','import','signmessage','verifymessage','list']
@ -110,7 +111,7 @@ if __name__ == '__main__':
host = raw_input("server (default:%s):"%wallet.interface.host)
port = raw_input("port (default:%d):"%wallet.interface.port)
fee = raw_input("fee (default:%f):"%(wallet.fee*1e-8))
fee = raw_input("fee (default:%s):"%( str(Decimal(wallet.fee)/100000000)) )
if fee: wallet.fee = float(fee)
if host: wallet.interface.host = host
if port: wallet.interface.port = int(port)
@ -223,16 +224,16 @@ if __name__ == '__main__':
if addrs == []:
c, u = wallet.get_balance()
if u:
print c*1e-8, u*1e-8
print Decimal( c ) / 100000000 , Decimal( u ) / 100000000
else:
print c*1e-8
print Decimal( c ) / 100000000
else:
for addr in addrs:
c, u = wallet.get_addr_balance(addr)
if u:
print "%s %s, %s" % (addr, c*1e-8, u*1e-8)
print "%s %s, %s" % (addr, str(Decimal(c)/100000000), str(Decimal(u)/100000000))
else:
print "%s %s" % (addr, c*1e-8)
print "%s %s" % (addr, str(Decimal(c)/100000000))
elif cmd in [ 'contacts']:
for addr in wallet.addressbook:
@ -257,7 +258,7 @@ if __name__ == '__main__':
for item in h:
if item['is_in']: ni += 1
else: no += 1
b = "%d %d %f"%(no, ni, wallet.get_addr_balance(addr)[0]*1e-8)
b = "%d %d %s"%(no, ni, str(Decimal(wallet.get_addr_balance(addr)[0])/100000000))
else: b=''
if options.show_keys:
pk = wallet.get_private_key2(addr, password)
@ -269,9 +270,8 @@ if __name__ == '__main__':
b = 0
for line in lines:
import datetime
v = 1.*line['value']/1e8
v = line['value']
b += v
v_str = "%f"%v if v<0 else "+%f"%v
try:
time_str = datetime.datetime.fromtimestamp( line['nTime'])
except:
@ -281,8 +281,8 @@ if __name__ == '__main__':
if not label: label = line['tx_hash']
else: label = label + ' '*(64 - len(label) )
print time_str, " ", label, " ", v_str, " ", "%f"%b
print "# balance: ", b
print time_str , " " + label + " " + format_satoshis(v)+ " "+ format_satoshis(b)
print "# balance: ", format_satoshis(b)
elif cmd == 'label':
try:

11
client/gui.py

@ -28,12 +28,7 @@ from decimal import Decimal
gtk.gdk.threads_init()
APP_NAME = "Electrum"
def format_satoshis(x):
s = str( Decimal(x) /100000000 )
if not '.' in s: s += '.'
p = s.find('.')
s += " "*( 9 - ( len(s) - p ))
return s
from wallet import format_satoshis
def numbify(entry, is_int = False):
text = entry.get_text().strip()
@ -1117,7 +1112,7 @@ class BitcoinGUI:
self.status_image.set_from_stock(gtk.STOCK_NO, gtk.ICON_SIZE_MENU)
self.network_button.set_tooltip_text("Trying to contact %s.\n%d blocks"%(self.wallet.interface.host, self.wallet.interface.blocks))
text = "Balance: %s "%( format_satoshis(c) )
if u: text += "[+ %s unconfirmed]"%( format_satoshis(u) )
if u: text += "[%s unconfirmed]"%( format_satoshis(u,True) )
if self.error: text = self.error
self.status_bar.pop(self.context_id)
self.status_bar.push(self.context_id, text)
@ -1175,7 +1170,7 @@ class BitcoinGUI:
details+= "Outputs:\n-"+ '\n-'.join(tx['outputs'])
self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label,
('+' if v>0 else '') + format_satoshis(v), format_satoshis(balance), tooltip, details] )
format_satoshis(v,True), format_satoshis(balance), tooltip, details] )
if cursor: self.history_treeview.set_cursor( cursor )

12
client/wallet.py

@ -213,9 +213,19 @@ def raw_tx( inputs, outputs, for_sig = None ):
from version import ELECTRUM_VERSION, SEED_VERSION
def format_satoshis(x, is_diff=False):
from decimal import Decimal
s = str( Decimal(x) /100000000 )
if is_diff and x>0:
s = "+" + s
if not '.' in s: s += '.'
p = s.find('.')
s += " "*( 9 - ( len(s) - p ))
s = " "*( 5 - ( p )) + s
return s
from version import ELECTRUM_VERSION, SEED_VERSION

Loading…
Cancel
Save