tfix sweep - electrum - Electrum Bitcoin wallet
 (HTM) git clone https://git.parazyd.org/electrum
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
       ---
 (DIR) commit 15ab48aaa8b291777086c95658f4808443c8a289
 (DIR) parent 3dabb94046cd94e145ee19f38cf6a0b36a6edcf9
 (HTM) Author: ThomasV <thomasv@electrum.org>
       Date:   Thu,  5 Oct 2017 20:08:16 +0200
       
       fix sweep
       
       Diffstat:
         M lib/bitcoin.py                      |       2 +-
         M lib/commands.py                     |       2 +-
         M lib/wallet.py                       |       9 +++++----
       
       3 files changed, 7 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/lib/bitcoin.py b/lib/bitcoin.py
       t@@ -509,7 +509,7 @@ def deserialize_privkey(key):
                compressed = len(vch) == 34
                return txin_type, vch[1:33], compressed
            else:
       -        return False
       +        raise BaseException("cannot deserialize", key)
        
        def regenerate_key(pk):
            assert len(pk) == 32
 (DIR) diff --git a/lib/commands.py b/lib/commands.py
       t@@ -388,7 +388,7 @@ class Commands:
                privkey to a destination address. The transaction is not
                broadcasted."""
                tx_fee = satoshis(tx_fee)
       -        privkeys = privkey if type(privkey) is list else [privkey]
       +        privkeys = privkey.split()
                self.nocheck = nocheck
                dest = self._resolver(destination)
                tx = self.wallet.sweep(privkeys, self.network, self.config, dest, tx_fee, imax)
 (DIR) diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -874,15 +874,16 @@ class Abstract_Wallet(PrintError):
            def sweep(self, privkeys, network, config, recipient, fee=None, imax=100):
                inputs = []
                keypairs = {}
       -        for privkey in privkeys:
       -            pubkey = public_key_from_private_key(privkey)
       -            address = address_from_private_key(privkey)
       +        for sec in privkeys:
       +            txin_type, privkey, compressed = bitcoin.deserialize_privkey(sec)
       +            pubkey = bitcoin.public_key_from_private_key(privkey, compressed)
       +            address = bitcoin.pubkey_to_address(txin_type, pubkey)
                    u = network.synchronous_get(('blockchain.address.listunspent', [address]))
                    pay_script = bitcoin.address_to_script(address)
                    for item in u:
                        if len(inputs) >= imax:
                            break
       -                item['type'] = 'p2pkh'
       +                item['type'] = txin_type
                        item['scriptPubKey'] = pay_script
                        item['redeemPubkey'] = pubkey
                        item['address'] = address