Browse Source

Merge pull request #1 from spesmilo/master

Update
3.0.x
Sameer Zahid 7 years ago
committed by GitHub
parent
commit
ce0617fb4b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      contrib/build-wine/build-electrum-git.sh
  2. 2
      contrib/build-wine/build.sh
  3. 19
      gui/qt/main_window.py
  4. 4
      gui/qt/transaction_dialog.py
  5. 3
      lib/rsakey.py
  6. 7
      lib/wallet.py

2
contrib/build-wine/build-electrum-git.sh

@ -69,7 +69,7 @@ wine "C:/python$PYTHON_VERSION/scripts/pyinstaller.exe" --noconfirm --ascii --na
# set timestamps in dist, in order to make the installer reproducible
pushd dist
find -type f -exec touch -d '2000-01-1 18:00:16' {} +
find -type f -exec touch -d '2000-11-11T11:11:11+00:00' {} +
popd
# build NSIS installer

2
contrib/build-wine/build.sh

@ -15,7 +15,7 @@ $here/prepare-hw.sh || exit 1
echo "Resetting modification time in C:\Python..."
# (Because of some bugs in pyinstaller)
pushd /opt/wine64/drive_c/python*
find -type f -exec touch -d '2000-11-11 11:11:11' {} +
find -type f -exec touch -d '2000-11-11T11:11:11+00:00' {} +
popd
ls -l /opt/wine64/drive_c/python*

19
gui/qt/main_window.py

@ -118,6 +118,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.require_fee_update = False
self.tx_notifications = []
self.tl_windows = []
self.tx_external_keypairs = {}
self.create_status_bar()
self.need_update = threading.Event()
@ -1414,7 +1415,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.on_error(exc_info)
callback(False)
task = partial(self.wallet.sign_transaction, tx, password)
if self.tx_external_keypairs:
task = partial(Transaction.sign, tx, self.tx_external_keypairs)
else:
task = partial(self.wallet.sign_transaction, tx, password)
WaitingDialog(self, _('Signing transaction...'), task,
on_signed, on_failed)
@ -1557,6 +1561,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
e.setFrozen(False)
self.set_pay_from([])
self.rbf_checkbox.setChecked(False)
self.tx_external_keypairs = {}
self.update_status()
run_hook('do_clear', self)
@ -2364,14 +2369,20 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
address_e.textChanged.connect(on_address)
if not d.exec_():
return
from electrum.wallet import sweep
from electrum.wallet import sweep_preparations
try:
tx = sweep(get_pk(), self.network, self.config, get_address(), None)
self.do_clear()
coins, keypairs = sweep_preparations(get_pk(), self.network)
self.tx_external_keypairs = keypairs
self.spend_coins(coins)
self.payto_e.setText(get_address())
self.spend_max()
self.payto_e.setFrozen(True)
self.amount_e.setFrozen(True)
except BaseException as e:
self.show_message(str(e))
return
self.warn_if_watching_only()
self.show_transaction(tx)
def _do_import(self, title, msg, func):
text = text_dialog(self, title, msg + ' :', _('Import'))

4
gui/qt/transaction_dialog.py

@ -178,7 +178,9 @@ class TxDialog(QDialog, MessageBoxMixin):
tx_hash, status, label, can_broadcast, can_rbf, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
size = self.tx.estimated_size()
self.broadcast_button.setEnabled(can_broadcast)
self.sign_button.setEnabled(self.wallet.can_sign(self.tx))
can_sign = not self.tx.is_complete() and \
(self.wallet.can_sign(self.tx) or bool(self.main_window.tx_external_keypairs))
self.sign_button.setEnabled(can_sign)
self.tx_hash_e.setText(tx_hash or _('Unknown'))
if desc is None:
self.tx_desc.hide()

3
lib/rsakey.py

@ -526,7 +526,7 @@ class RSAKey(object):
return False
def generate(bits):
key = Python_RSAKey()
key = RSAKey()
p = getRandomPrime(bits//2, False)
q = getRandomPrime(bits//2, False)
t = lcm(p-1, q-1)
@ -540,4 +540,3 @@ class RSAKey(object):
key.qInv = invMod(q, p)
return key
generate = staticmethod(generate)

7
lib/wallet.py

@ -101,7 +101,7 @@ def append_utxos_to_inputs(inputs, network, pubkey, txin_type, imax):
item['num_sig'] = 1
inputs.append(item)
def sweep(privkeys, network, config, recipient, fee=None, imax=100):
def sweep_preparations(privkeys, network, imax=100):
def find_utxos_for_privkey(txin_type, privkey, compressed):
pubkey = bitcoin.public_key_from_private_key(privkey, compressed)
@ -123,6 +123,11 @@ def sweep(privkeys, network, config, recipient, fee=None, imax=100):
find_utxos_for_privkey('p2pk', privkey, compressed)
if not inputs:
raise BaseException(_('No inputs found. (Note that inputs need to be confirmed)'))
return inputs, keypairs
def sweep(privkeys, network, config, recipient, fee=None, imax=100):
inputs, keypairs = sweep_preparations(privkeys, network, imax)
total = sum(i.get('value') for i in inputs)
if fee is None:
outputs = [(TYPE_ADDRESS, recipient, total)]

Loading…
Cancel
Save