1
0

sweeping minikeys: search for both compressed and uncompressed pubkeys

This commit is contained in:
SomberNight
2017-11-11 11:02:30 +01:00
parent 568afd7a17
commit 9e2cd17790
2 changed files with 19 additions and 6 deletions

View File

@@ -893,15 +893,28 @@ class Abstract_Wallet(PrintError):
inputs.append(item)
def sweep(self, privkeys, network, config, recipient, fee=None, imax=100):
def find_utxos_for_privkey(txin_type, privkey, compressed):
pubkey = bitcoin.public_key_from_private_key(privkey, compressed)
self._append_utxos_to_inputs(inputs, network, pubkey, txin_type, imax)
keypairs[pubkey] = privkey, compressed
inputs = []
keypairs = {}
for sec in privkeys:
txin_type, privkey, compressed = bitcoin.deserialize_privkey(sec)
pubkey = bitcoin.public_key_from_private_key(privkey, compressed)
self._append_utxos_to_inputs(inputs, network, pubkey, txin_type, imax)
if txin_type == 'p2pkh': # WIF serialization is ambiguous :(
self._append_utxos_to_inputs(inputs, network, pubkey, 'p2pk', imax)
keypairs[pubkey] = privkey, compressed
find_utxos_for_privkey(txin_type, privkey, compressed)
# do other lookups to increase support coverage
if is_minikey(sec):
# minikeys don't have a compressed byte
# we lookup both compressed and uncompressed pubkeys
find_utxos_for_privkey(txin_type, privkey, not compressed)
elif txin_type == 'p2pkh':
# WIF serialization does not distinguish p2pkh and p2pk
# we also search for pay-to-pubkey outputs
find_utxos_for_privkey('p2pk', privkey, compressed)
if not inputs:
raise BaseException(_('No inputs found. (Note that inputs need to be confirmed)'))