From 7b4046cf681c2b20d8a187d3eb42564651e34af6 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 1 Sep 2013 23:09:27 +0200 Subject: [PATCH] fee belongs in wallet storage --- gui/gui_classic.py | 12 +++--------- lib/wallet.py | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gui/gui_classic.py b/gui/gui_classic.py index 2eef11e89..4c2a1a3ea 100644 --- a/gui/gui_classic.py +++ b/gui/gui_classic.py @@ -249,7 +249,6 @@ class ElectrumWindow(QMainWindow): self.expert_mode = config.get('classic_expert_mode', False) self.decimal_point = config.get('decimal_point', 8) self.num_zeros = int(config.get('num_zeros',0)) - self.fee = int(config.get('fee_per_kb',20000)) set_language(config.get('language')) @@ -522,11 +521,6 @@ class ElectrumWindow(QMainWindow): return - def set_fee(self, fee): - if self.fee != fee: - self.fee = fee - self.config.set_key('fee_per_kb', self.fee, True) - def set_label(self, name, text = None): changed = False @@ -534,7 +528,7 @@ class ElectrumWindow(QMainWindow): if text: if old_text != text: self.wallet.labels[name] = text - self.wallet.storage.set_key('labels', self.wallet.labels) + self.wallet.storage.put('labels', self.wallet.labels) changed = True else: if old_text: @@ -2027,7 +2021,7 @@ class ElectrumWindow(QMainWindow): fee_label = QLabel(_('Transaction fee')) grid_wallet.addWidget(fee_label, 0, 0) fee_e = AmountEdit(self.base_unit) - fee_e.setText(self.format_amount(self.fee).strip()) + fee_e.setText(self.format_amount(self.wallet.fee).strip()) grid_wallet.addWidget(fee_e, 0, 2) msg = _('Fee per kilobyte of transaction.') + ' ' \ + _('Recommended value') + ': ' + self.format_amount(50000) @@ -2117,7 +2111,7 @@ class ElectrumWindow(QMainWindow): QMessageBox.warning(self, _('Error'), _('Invalid value') +': %s'%fee, _('OK')) return - self.set_fee(fee) + self.wallet.set_fee(fee) nz = unicode(nz_e.text()) try: diff --git a/lib/wallet.py b/lib/wallet.py index 801412434..686c7425a 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -156,6 +156,7 @@ class Wallet: self.imported_keys = storage.get('imported_keys',{}) self.history = storage.get('addr_history',{}) # address -> list(txid, height) + self.fee = int(storage.get('fee_per_kb',20000)) self.master_public_keys = storage.get('master_public_keys',{}) self.master_private_keys = storage.get('master_private_keys', {}) @@ -921,6 +922,11 @@ class Wallet: return inputs, total, fee + def set_fee(self, fee): + if self.fee != fee: + self.fee = fee + self.storage.put('fee_per_kb', self.fee, True) + def estimated_fee(self, inputs): estimated_size = len(inputs) * 180 + 80 # this assumes non-compressed keys fee = self.fee * int(round(estimated_size/1024.))