diff --git a/lib/gui_qt.py b/lib/gui_qt.py index eb386a815..750b6fb08 100644 --- a/lib/gui_qt.py +++ b/lib/gui_qt.py @@ -458,11 +458,6 @@ class ElectrumWindow(QMainWindow): grid.addWidget(self.fee_e, 4, 1, 1, 2) grid.addWidget(HelpButton(_('Bitcoin transactions are in general not free. A transaction fee is paid by the sender of the funds.\n\nThe amount of fee can be decided freely by the sender. However, transactions with low fees take more time to be processed.\n\nA suggested fee is automatically added to this field. You may override it. The suggested fee increases with the size of the transaction.')), 4, 3) - self.nochange_cb = QCheckBox(_('Do not create change address')) - grid.addWidget(self.nochange_cb,5,1,1,4) - self.nochange_cb.setChecked(False) - self.nochange_cb.setHidden(not self.wallet.expert_mode) - b = EnterButton(_("Send"), self.do_send) grid.addWidget(b, 6, 1) @@ -562,15 +557,8 @@ class ElectrumWindow(QMainWindow): else: password = None - if self.nochange_cb.isChecked(): - inputs, total, fee = self.wallet.choose_tx_inputs( amount, fee ) - change_addr = inputs[0][0] - print "sending change to", change_addr - else: - change_addr = None - try: - tx = self.wallet.mktx( to_address, amount, label, password, fee, change_addr ) + tx = self.wallet.mktx( to_address, amount, label, password, fee) except BaseException, e: self.show_message(str(e)) return @@ -1164,8 +1152,8 @@ class ElectrumWindow(QMainWindow): self.wallet.save() self.update_receive_tab() self.update_contacts_tab() - if self.wallet.seed: - self.nochange_cb.setHidden(not self.wallet.expert_mode) + # if self.wallet.seed: + # self.nochange_cb.setHidden(not self.wallet.expert_mode) def settings_dialog(self): @@ -1199,7 +1187,16 @@ class ElectrumWindow(QMainWindow): grid.addWidget(nz_e, 3, 1) nz_e.textChanged.connect(lambda: numbify(nz_e,True)) + cb = QCheckBox(_('Expert mode')) + grid.addWidget(cb, 4, 0) + cb.setChecked(self.wallet.expert_mode) + if self.wallet.expert_mode: + + nochange_cb = QCheckBox(_('Use change addresses')) + grid.addWidget(nochange_cb, 5, 0) + nochange_cb.setChecked(self.wallet.use_change) + msg = _('The gap limit is the maximal number of contiguous unused addresses in your sequence of receiving addresses.') + '\n' \ + _('You may increase it if you need more receiving addresses.') + '\n\n' \ + _('Your current gap limit is: ') + '%d'%self.wallet.gap_limit + '\n' \ @@ -1209,14 +1206,11 @@ class ElectrumWindow(QMainWindow): + _('Do not modify it if you do not understand what you are doing, or if you expect to recover your wallet without knowing it!') + '\n\n' gap_e = QLineEdit() gap_e.setText("%d"% self.wallet.gap_limit) - grid.addWidget(QLabel(_('Gap limit')), 4, 0) - grid.addWidget(gap_e, 4, 1) - grid.addWidget(HelpButton(msg), 4, 2) + grid.addWidget(QLabel(_('Gap limit')), 6, 0) + grid.addWidget(gap_e, 6, 1) + grid.addWidget(HelpButton(msg), 6, 2) gap_e.textChanged.connect(lambda: numbify(nz_e,True)) - cb = QCheckBox(_('Expert mode')) - grid.addWidget(cb, 5, 0) - cb.setChecked(self.wallet.expert_mode) vbox.addLayout(ok_cancel_buttons(d)) d.setLayout(vbox) @@ -1250,6 +1244,9 @@ class ElectrumWindow(QMainWindow): self.wallet.save() if self.wallet.expert_mode: + + self.wallet.nochange = nochange_cb.isChecked() + try: n = int(gap_e.text()) except: diff --git a/lib/wallet.py b/lib/wallet.py index 5517fd5a6..c1769b02d 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -256,6 +256,7 @@ class Wallet: self.gui_callback = gui_callback self.gap_limit = 5 # configuration + self.use_change = True self.fee = 100000 self.num_zeros = 0 self.master_public_key = '' @@ -611,6 +612,7 @@ class Wallet: s = { 'seed_version':self.seed_version, 'use_encryption':self.use_encryption, + 'use_change':self.use_change, 'master_public_key': self.master_public_key.encode('hex'), 'fee':self.fee, 'server':self.server, @@ -653,6 +655,7 @@ class Wallet: self.seed_version = d.get('seed_version') self.master_public_key = d.get('master_public_key').decode('hex') self.use_encryption = d.get('use_encryption') + self.use_change = bool(d.get('use_change',True)) self.fee = int( d.get('fee') ) self.seed = d.get('seed') self.server = d.get('server') @@ -878,12 +881,19 @@ class Wallet: tx['default_label'] = default_label - def mktx(self, to_address, amount, label, password, fee=None, change_addr=None, from_addr= None): + def mktx(self, to_address, amount, label, password, fee=None, from_addr= None): if not self.is_valid(to_address): raise BaseException("Invalid address") inputs, total, fee = self.choose_tx_inputs( amount, fee, from_addr ) if not inputs: raise BaseException("Not enough funds") + + if self.use_change: + change_addr = inputs[0][0] + print "sending change to", change_addr + else: + change_addr = None + outputs = self.choose_tx_outputs( to_address, amount, fee, total, change_addr ) s_inputs = self.sign_inputs( inputs, outputs, password )