Create a constant for 100000000 and use it
Use same name as is in bitcoind. Note that one of the constants in text.py had the wrong number of zeroes previously...
This commit is contained in:
@@ -23,7 +23,7 @@ from __future__ import absolute_import
|
||||
import android
|
||||
|
||||
from electrum import SimpleConfig, Wallet, WalletStorage, format_satoshis
|
||||
from electrum.bitcoin import is_address
|
||||
from electrum.bitcoin import is_address, COIN
|
||||
from electrum import util
|
||||
from decimal import Decimal
|
||||
import datetime, re
|
||||
@@ -585,7 +585,7 @@ def payto_loop():
|
||||
continue
|
||||
|
||||
try:
|
||||
amount = int( 100000000 * Decimal(amount) )
|
||||
amount = int(COIN * Decimal(amount))
|
||||
except Exception:
|
||||
modal_dialog('Error','Invalid amount')
|
||||
continue
|
||||
@@ -608,7 +608,7 @@ def payto_loop():
|
||||
if re.match('^bitcoin:', data):
|
||||
payto, amount, label, message, _ = util.parse_URI(data)
|
||||
if amount:
|
||||
amount = str(amount/100000000)
|
||||
amount = str(amount / COIN)
|
||||
droid.fullSetProperty("recipient", "text", payto)
|
||||
droid.fullSetProperty("amount", "text", amount)
|
||||
droid.fullSetProperty("message", "text", message)
|
||||
@@ -662,7 +662,7 @@ def receive_loop():
|
||||
elif event["name"]=="amount":
|
||||
amount = modal_input('Amount', 'Amount you want to receive (in BTC). ', format_satoshis(receive_amount) if receive_amount else None, "numberDecimal")
|
||||
if amount is not None:
|
||||
receive_amount = int(100000000 * Decimal(amount)) if amount else None
|
||||
receive_amount = int(COIN * Decimal(amount)) if amount else None
|
||||
out = 'receive'
|
||||
|
||||
elif event["name"]=="message":
|
||||
@@ -770,7 +770,7 @@ def settings_loop():
|
||||
|
||||
def set_listview():
|
||||
host, port, p, proxy_config, auto_connect = network.get_parameters()
|
||||
fee = str( Decimal( wallet.fee_per_kb)/100000000 )
|
||||
fee = str(Decimal(wallet.fee_per_kb) / COIN)
|
||||
is_encrypted = 'yes' if wallet.use_encryption else 'no'
|
||||
protocol = protocol_name(p)
|
||||
droid.fullShow(settings_layout)
|
||||
@@ -818,10 +818,10 @@ def settings_loop():
|
||||
|
||||
elif pos == "3": #fee
|
||||
fee = modal_input('Transaction fee', 'The fee will be this amount multiplied by the number of inputs in your transaction. ',
|
||||
str(Decimal(wallet.fee_per_kb)/100000000 ), "numberDecimal")
|
||||
str(Decimal(wallet.fee_per_kb) / COIN), "numberDecimal")
|
||||
if fee:
|
||||
try:
|
||||
fee = int( 100000000 * Decimal(fee) )
|
||||
fee = int(COIN * Decimal(fee))
|
||||
except Exception:
|
||||
modal_dialog('error','invalid fee value')
|
||||
wallet.set_fee(fee)
|
||||
|
||||
14
gui/gtk.py
14
gui/gtk.py
@@ -25,7 +25,7 @@ gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, Gdk, GObject, cairo
|
||||
from decimal import Decimal
|
||||
from electrum.util import print_error, InvalidPassword
|
||||
from electrum.bitcoin import is_valid
|
||||
from electrum.bitcoin import is_valid, COIN
|
||||
from electrum.wallet import NotEnoughFunds
|
||||
from electrum import WalletStorage, Wallet
|
||||
|
||||
@@ -48,7 +48,7 @@ def numbify(entry, is_int = False):
|
||||
s = s.replace('.','')
|
||||
s = s[:p] + '.' + s[p:p+8]
|
||||
try:
|
||||
amount = int( Decimal(s) * 100000000 )
|
||||
amount = int(Decimal(s) * COIN)
|
||||
except Exception:
|
||||
amount = None
|
||||
else:
|
||||
@@ -164,7 +164,7 @@ def run_settings_dialog(self):
|
||||
fee_label.set_size_request(150,10)
|
||||
fee_label.show()
|
||||
fee.pack_start(fee_label,False, False, 10)
|
||||
fee_entry.set_text( str( Decimal(self.wallet.fee_per_kb) /100000000 ) )
|
||||
fee_entry.set_text(str(Decimal(self.wallet.fee_per_kb) / COIN))
|
||||
fee_entry.connect('changed', numbify, False)
|
||||
fee_entry.show()
|
||||
fee.pack_start(fee_entry,False,False, 10)
|
||||
@@ -196,7 +196,7 @@ def run_settings_dialog(self):
|
||||
return
|
||||
|
||||
try:
|
||||
fee = int( 100000000 * Decimal(fee) )
|
||||
fee = int(COIN * Decimal(fee))
|
||||
except Exception:
|
||||
show_message("error")
|
||||
return
|
||||
@@ -698,7 +698,7 @@ class ElectrumWindow:
|
||||
if not self.funds_error:
|
||||
if not is_fee:
|
||||
fee = tx.get_fee()
|
||||
fee_entry.set_text( str( Decimal( fee ) / 100000000 ) )
|
||||
fee_entry.set_text(str(Decimal(fee) / COIN))
|
||||
self.fee_box.show()
|
||||
amount_entry.modify_text(Gtk.StateType.NORMAL, Gdk.color_parse("#000000"))
|
||||
fee_entry.modify_text(Gtk.StateType.NORMAL, Gdk.color_parse("#000000"))
|
||||
@@ -791,12 +791,12 @@ class ElectrumWindow:
|
||||
return
|
||||
|
||||
try:
|
||||
amount = int( Decimal(amount_entry.get_text()) * 100000000 )
|
||||
amount = int(Decimal(amount_entry.get_text()) * COIN)
|
||||
except Exception:
|
||||
self.show_message( "invalid amount")
|
||||
return
|
||||
try:
|
||||
fee = int( Decimal(fee_entry.get_text()) * 100000000 )
|
||||
fee = int(Decimal(fee_entry.get_text()) * COIN)
|
||||
except Exception:
|
||||
self.show_message( "invalid fee")
|
||||
return
|
||||
|
||||
@@ -36,7 +36,7 @@ import shutil
|
||||
|
||||
from util import *
|
||||
|
||||
bitcoin = lambda v: v * 100000000
|
||||
bitcoin = lambda v: v * COIN
|
||||
|
||||
def IconButton(filename, parent=None):
|
||||
pixmap = QPixmap(filename)
|
||||
|
||||
@@ -30,7 +30,7 @@ from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
import PyQt4.QtCore as QtCore
|
||||
|
||||
from electrum.bitcoin import MIN_RELAY_TX_FEE, is_valid
|
||||
from electrum.bitcoin import MIN_RELAY_TX_FEE, COIN, is_valid
|
||||
from electrum.plugins import run_hook
|
||||
|
||||
import icons_rc
|
||||
@@ -1092,7 +1092,7 @@ class ElectrumWindow(QMainWindow):
|
||||
return
|
||||
|
||||
amount = sum(map(lambda x:x[2], outputs))
|
||||
confirm_amount = self.config.get('confirm_amount', 100000000)
|
||||
confirm_amount = self.config.get('confirm_amount', COIN)
|
||||
if amount >= confirm_amount:
|
||||
o = '\n'.join(map(lambda x:x[1], outputs))
|
||||
if not self.question(_("send %(amount)s to %(address)s?")%{ 'amount' : self.format_amount(amount) + ' '+ self.base_unit(), 'address' : o}):
|
||||
|
||||
12
gui/stdio.py
12
gui/stdio.py
@@ -3,7 +3,7 @@ _ = lambda x:x
|
||||
#from i18n import _
|
||||
from electrum.wallet import WalletStorage, Wallet
|
||||
from electrum.util import format_satoshis, set_verbosity, StoreDict
|
||||
from electrum.bitcoin import is_valid
|
||||
from electrum.bitcoin import is_valid, COIN
|
||||
from electrum.network import filter_protocol
|
||||
import sys, getpass, datetime
|
||||
|
||||
@@ -125,11 +125,11 @@ class ElectrumGui:
|
||||
msg = _( "Synchronizing..." )
|
||||
else:
|
||||
c, u, x = self.wallet.get_balance()
|
||||
msg = _("Balance")+": %f "%(Decimal(c) / 100000000)
|
||||
msg = _("Balance")+": %f "%(Decimal(c) / COIN)
|
||||
if u:
|
||||
msg += " [%f unconfirmed]"%(Decimal(u) / 100000000)
|
||||
msg += " [%f unconfirmed]"%(Decimal(u) / COIN)
|
||||
if x:
|
||||
msg += " [%f unmatured]"%(Decimal(x) / 100000000)
|
||||
msg += " [%f unmatured]"%(Decimal(x) / COIN)
|
||||
else:
|
||||
msg = _( "Not connected" )
|
||||
|
||||
@@ -178,12 +178,12 @@ class ElectrumGui:
|
||||
print(_('Invalid Bitcoin address'))
|
||||
return
|
||||
try:
|
||||
amount = int( Decimal( self.str_amount) * 100000000 )
|
||||
amount = int(Decimal(self.str_amount) * COIN)
|
||||
except Exception:
|
||||
print(_('Invalid Amount'))
|
||||
return
|
||||
try:
|
||||
fee = int( Decimal( self.str_fee) * 100000000 )
|
||||
fee = int(Decimal(self.str_fee) * COIN)
|
||||
except Exception:
|
||||
print(_('Invalid Fee'))
|
||||
return
|
||||
|
||||
15
gui/text.py
15
gui/text.py
@@ -1,10 +1,9 @@
|
||||
import curses, datetime, locale
|
||||
from decimal import Decimal
|
||||
_ = lambda x:x
|
||||
#from i18n import _
|
||||
from electrum.util import format_satoshis, set_verbosity
|
||||
from electrum.util import StoreDict
|
||||
from electrum.bitcoin import is_valid
|
||||
from electrum.bitcoin import is_valid, COIN
|
||||
|
||||
from electrum import Wallet, WalletStorage
|
||||
|
||||
@@ -133,11 +132,11 @@ class ElectrumGui:
|
||||
msg = _("Synchronizing...")
|
||||
else:
|
||||
c, u, x = self.wallet.get_balance()
|
||||
msg = _("Balance")+": %f "%(Decimal(c) / 100000000)
|
||||
msg = _("Balance")+": %f "%(Decimal(c) / COIN)
|
||||
if u:
|
||||
msg += " [%f unconfirmed]"%(Decimal(u) / 100000000)
|
||||
msg += " [%f unconfirmed]"%(Decimal(u) / COIN)
|
||||
if x:
|
||||
msg += " [%f unmatured]"%(Decimal(x) / 100000000)
|
||||
msg += " [%f unmatured]"%(Decimal(x) / COIN)
|
||||
else:
|
||||
msg = _("Not connected")
|
||||
|
||||
@@ -297,12 +296,12 @@ class ElectrumGui:
|
||||
self.show_message(_('Invalid Bitcoin address'))
|
||||
return
|
||||
try:
|
||||
amount = int( Decimal( self.str_amount) * 100000000 )
|
||||
amount = int(Decimal(self.str_amount) * COIN)
|
||||
except Exception:
|
||||
self.show_message(_('Invalid Amount'))
|
||||
return
|
||||
try:
|
||||
fee = int( Decimal( self.str_fee) * 100000000 )
|
||||
fee = int(Decimal(self.str_fee) * COIN)
|
||||
except Exception:
|
||||
self.show_message(_('Invalid Fee'))
|
||||
return
|
||||
@@ -388,7 +387,7 @@ class ElectrumGui:
|
||||
if out.get('Default GUI'):
|
||||
self.config.set_key('gui', out['Default GUI'], True)
|
||||
if out.get('Default fee'):
|
||||
fee = int ( Decimal( out['Default fee']) *10000000 )
|
||||
fee = int(Decimal(out['Default fee']) * COIN)
|
||||
self.config.set_key('fee_per_kb', fee, True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user