define constants for tx output types
This commit is contained in:
@@ -21,13 +21,13 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import android
|
||||
|
||||
from electrum import SimpleConfig, Wallet, WalletStorage, format_satoshis
|
||||
from electrum.bitcoin import is_address, COIN
|
||||
from electrum import util
|
||||
from decimal import Decimal
|
||||
import datetime, re
|
||||
|
||||
from electrum import SimpleConfig, Wallet, WalletStorage, format_satoshis
|
||||
from electrum.bitcoin import is_address, COIN, TYPE_ADDRESS
|
||||
from electrum import util
|
||||
|
||||
|
||||
def modal_dialog(title, msg = None):
|
||||
droid.dialogCreateAlert(title,msg)
|
||||
@@ -442,9 +442,8 @@ def pay_to(recipient, amount, label):
|
||||
|
||||
droid.dialogCreateSpinnerProgress("Electrum", "signing transaction...")
|
||||
droid.dialogShow()
|
||||
|
||||
try:
|
||||
tx = wallet.mktx([('address', recipient, amount)], password, config)
|
||||
tx = wallet.mktx([(TYPE_ADDRESS, recipient, amount)], password, config)
|
||||
except Exception as e:
|
||||
modal_dialog('error', e.message)
|
||||
droid.dialogDismiss()
|
||||
|
||||
@@ -26,7 +26,6 @@ from context_menu import ContextMenu
|
||||
|
||||
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
|
||||
|
||||
|
||||
class CScreen(Factory.Screen):
|
||||
|
||||
__events__ = ('on_activate', 'on_deactivate', 'on_enter', 'on_leave')
|
||||
@@ -254,7 +253,7 @@ class SendScreen(CScreen):
|
||||
except:
|
||||
self.app.show_error(_('Invalid amount') + ':\n' + self.screen.amount)
|
||||
return
|
||||
outputs = [('address', address, amount)]
|
||||
outputs = [(bitcoin.TYPE_ADDRESS, address, amount)]
|
||||
message = unicode(self.screen.message)
|
||||
fee = None
|
||||
self.app.protected(self.send_tx, (outputs, fee, message))
|
||||
|
||||
@@ -34,7 +34,7 @@ import PyQt4.QtCore as QtCore
|
||||
|
||||
import icons_rc
|
||||
|
||||
from electrum.bitcoin import COIN, is_valid
|
||||
from electrum.bitcoin import COIN, is_valid, TYPE_ADDRESS
|
||||
from electrum.plugins import run_hook
|
||||
from electrum.i18n import _
|
||||
from electrum.util import block_explorer, block_explorer_info, block_explorer_URL
|
||||
@@ -1076,7 +1076,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||
fee = self.fee_e.get_amount() if freeze_fee else None
|
||||
if not outputs:
|
||||
addr = self.payto_e.payto_address if self.payto_e.payto_address else self.dummy_address
|
||||
outputs = [('address', addr, amount)]
|
||||
outputs = [(TYPE_ADDRESS, addr, amount)]
|
||||
try:
|
||||
tx = self.wallet.make_unsigned_transaction(self.get_coins(), outputs, self.config, fee)
|
||||
self.not_enough_funds = False
|
||||
@@ -1180,7 +1180,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||
if addr is None:
|
||||
self.show_error(_('Bitcoin Address is None'))
|
||||
return
|
||||
if _type == 'address' and not bitcoin.is_address(addr):
|
||||
if _type == TYPE_ADDRESS and not bitcoin.is_address(addr):
|
||||
self.show_error(_('Invalid Bitcoin Address'))
|
||||
return
|
||||
if amount is None:
|
||||
|
||||
@@ -77,11 +77,11 @@ class PayToEdit(ScanQRTextEdit):
|
||||
if n:
|
||||
script = str(n.group(1)).decode('hex')
|
||||
amount = self.parse_amount(y)
|
||||
return 'script', script, amount
|
||||
return bitcoin.TYPE_SCRIPT, script, amount
|
||||
else:
|
||||
address = self.parse_address(x)
|
||||
amount = self.parse_amount(y)
|
||||
return 'address', address, amount
|
||||
return bitcoin.TYPE_ADDRESS, address, amount
|
||||
|
||||
def parse_amount(self, x):
|
||||
p = pow(10, self.amount_edit.decimal_point())
|
||||
@@ -149,7 +149,7 @@ class PayToEdit(ScanQRTextEdit):
|
||||
amount = self.amount_edit.get_amount()
|
||||
except:
|
||||
amount = None
|
||||
self.outputs = [('address', self.payto_address, amount)]
|
||||
self.outputs = [(bitcoin.TYPE_ADDRESS, self.payto_address, amount)]
|
||||
|
||||
return self.outputs[:]
|
||||
|
||||
|
||||
@@ -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, COIN
|
||||
from electrum.bitcoin import is_valid, COIN, TYPE_ADDRESS
|
||||
from electrum.network import filter_protocol
|
||||
import sys, getpass, datetime
|
||||
|
||||
@@ -187,7 +187,7 @@ class ElectrumGui:
|
||||
if c == "n": return
|
||||
|
||||
try:
|
||||
tx = self.wallet.mktx( [(self.str_recipient, amount)], password, self.config, fee)
|
||||
tx = self.wallet.mktx([(TYPE_ADDRESS, self.str_recipient, amount)], password, self.config, fee)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return
|
||||
|
||||
12
gui/text.py
12
gui/text.py
@@ -1,13 +1,14 @@
|
||||
import tty, sys
|
||||
import curses, datetime, locale
|
||||
from decimal import Decimal
|
||||
_ = lambda x:x
|
||||
|
||||
from electrum.util import format_satoshis, set_verbosity
|
||||
from electrum.util import StoreDict
|
||||
from electrum.bitcoin import is_valid, COIN
|
||||
|
||||
from electrum.bitcoin import is_valid, COIN, TYPE_ADDRESS
|
||||
from electrum import Wallet, WalletStorage
|
||||
|
||||
import tty, sys
|
||||
_ = lambda x:x
|
||||
|
||||
|
||||
|
||||
class ElectrumGui:
|
||||
@@ -327,9 +328,8 @@ class ElectrumGui:
|
||||
return
|
||||
else:
|
||||
password = None
|
||||
|
||||
try:
|
||||
tx = self.wallet.mktx( [(self.str_recipient, amount)], password, self.config, fee)
|
||||
tx = self.wallet.mktx([(TYPE_ADDRESS, self.str_recipient, amount)], password, self.config, fee)
|
||||
except Exception as e:
|
||||
self.show_message(str(e))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user