URI: 
       tcoinchooser methods should not belong in wallet class - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit bca0f31fcaa9c0337963858ab72efb59610ef929
   DIR parent d9c567446c7b51e321ed96614c12cd51282a1329
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 10 Mar 2016 16:37:45 +0100
       
       coinchooser methods should not belong in wallet class
       
       Diffstat:
         M gui/kivy/uix/dialogs/settings.py    |       8 ++++----
         M gui/qt/main_window.py               |      10 +++++-----
         M lib/coinchooser.py                  |      10 ++++++++++
         M lib/wallet.py                       |      14 ++------------
       
       4 files changed, 21 insertions(+), 21 deletions(-)
       ---
   DIR diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py
       t@@ -8,6 +8,7 @@ from electrum.i18n import languages
        from electrum_gui.kivy.i18n import _
        from electrum.plugins import run_hook
        from electrum.bitcoin import RECOMMENDED_FEE
       +from electrum import coinchooser
        
        from choice_dialog import ChoiceDialog
        
       t@@ -157,13 +158,12 @@ class SettingsDialog(Factory.Popup):
                self._unit_dialog.open()
        
            def coinselect_status(self):
       -        return self.app.wallet.coin_chooser_name(self.app.electrum_config)
       +        return coinchooser.get_name(self.app.electrum_config)
        
            def coinselect_dialog(self, item, dt):
                if self._coinselect_dialog is None:
       -            from electrum import COIN_CHOOSERS
       -            choosers = sorted(COIN_CHOOSERS.keys())
       -            chooser_name = self.app.wallet.coin_chooser_name(self.config)
       +            choosers = sorted(coinchooser.COIN_CHOOSERS.keys())
       +            chooser_name = coinchooser.get_name(self.config)
                    def cb(text):
                        self.config.set_key('coin_chooser', text)
                        item.status = text
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -49,8 +49,8 @@ from electrum.util import (block_explorer, block_explorer_info, format_time,
                                   format_satoshis_plain, NotEnoughFunds, StoreDict,
                                   UserCancelled)
        from electrum import Transaction, mnemonic
       -from electrum import util, bitcoin, commands
       -from electrum import SimpleConfig, COIN_CHOOSERS, paymentrequest
       +from electrum import util, bitcoin, commands, coinchooser
       +from electrum import SimpleConfig, paymentrequest
        from electrum.wallet import Wallet, BIP32_RD_Wallet, Multisig_Wallet
        
        from amountedit import BTCAmountEdit, MyLineEdit, BTCkBEdit
       t@@ -2845,10 +2845,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                    lines = [ln.lstrip(" ") for ln in klass.__doc__.split("\n")]
                    return '\n'.join([key, "", " ".join(lines)])
        
       -        choosers = sorted(COIN_CHOOSERS.keys())
       -        chooser_name = self.wallet.coin_chooser_name(self.config)
       +        choosers = sorted(coinchooser.COIN_CHOOSERS.keys())
       +        chooser_name = coinchooser.get_name(self.config)
                msg = _('Choose coin (UTXO) selection method.  The following are available:\n\n')
       -        msg += '\n\n'.join(fmt_docs(*item) for item in COIN_CHOOSERS.items())
       +        msg += '\n\n'.join(fmt_docs(*item) for item in coinchooser.COIN_CHOOSERS.items())
                chooser_label = HelpLabel(_('Coin selection') + ':', msg)
                chooser_combo = QComboBox()
                chooser_combo.addItems(choosers)
   DIR diff --git a/lib/coinchooser.py b/lib/coinchooser.py
       t@@ -308,3 +308,13 @@ class CoinChooserPrivacy(CoinChooserRandom):
        
        COIN_CHOOSERS = {'Priority': CoinChooserOldestFirst,
                         'Privacy': CoinChooserPrivacy}
       +
       +def get_name(config):
       +    kind = config.get('coin_chooser')
       +    if not kind in COIN_CHOOSERS:
       +        kind = 'Priority'
       +    return kind
       +
       +def get_coin_chooser(config):
       +    klass = COIN_CHOOSERS[get_name(config)]
       +    return klass()
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -47,7 +47,7 @@ from version import *
        from transaction import Transaction
        from plugins import run_hook
        import bitcoin
       -from coinchooser import COIN_CHOOSERS
       +import coinchooser
        from synchronizer import Synchronizer
        from verifier import SPV
        from mnemonic import Mnemonic
       t@@ -921,16 +921,6 @@ class Abstract_Wallet(PrintError):
                # this method can be overloaded
                return tx.get_fee()
        
       -    def coin_chooser_name(self, config):
       -        kind = config.get('coin_chooser')
       -        if not kind in COIN_CHOOSERS:
       -            kind = 'Priority'
       -        return kind
       -
       -    def coin_chooser(self, config):
       -        klass = COIN_CHOOSERS[self.coin_chooser_name(config)]
       -        return klass()
       -
            def make_unsigned_transaction(self, coins, outputs, config, fixed_fee=None, change_addr=None):
                # check outputs
                for type, data, value in outputs:
       t@@ -975,7 +965,7 @@ class Abstract_Wallet(PrintError):
        
                # Let the coin chooser select the coins to spend
                max_change = self.max_change_outputs if self.multiple_change else 1
       -        coin_chooser = self.coin_chooser(config)
       +        coin_chooser = coinchooser.get_coin_chooser(config)
                tx = coin_chooser.make_tx(coins, outputs, change_addrs[:max_change],
                                          fee_estimator, dust_threshold)