Skip to content

Commit

Permalink
Bugfix: Import electrum multisig wallet (with available seed) (#1543)
Browse files Browse the repository at this point in the history
* Fixed bugs to import electrum multisig wallet
- 1. bug was a space in recv_descriptor
- 2. bug was that hw_type key does not exist in the electrum wallet dict if the seed in th electrum wallet

* black

* Capitalized device names

* Added warning in logger

* Changed warning to flash

Removed logger.warning

Added missing import

Co-authored-by: Kim Neunert <k9ert@gmx.de>
  • Loading branch information
relativisticelectron and k9ert authored Feb 1, 2022
1 parent 1f1ac53 commit eaeac1f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/cryptoadvance/specter/util/wallet_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from embit.descriptor.arguments import AllowedDerivation
from embit.liquid.descriptor import LDescriptor
from cryptoadvance.specter.key import Key
from flask import flash
from flask_babel import lazy_gettext as _

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -266,7 +268,19 @@ def parse_wallet_data_import(cls, wallet_data):
xpubs += "[{}]{}/0/*,".format(
d["derivation"].replace("m", d["root_fingerprint"]), d["xpub"]
)
cosigners_types.append({"type": d["hw_type"], "label": d["label"]})
if "hw_type" in d:
cosigners_types.append({"type": d["hw_type"], "label": d["label"]})
else: # this can occcur if no hardware wallet was used, but the seed is available
cosigners_types.append(
{"type": "electrum", "label": f"Electrum Multisig {i}"}
)
if "seed" in d:
flash(
_(
"The Electrum wallet contains a seed. The seed will not be imported."
),
"warning",
)
i += 1
xpubs = xpubs.rstrip(",")

Expand All @@ -278,7 +292,7 @@ def parse_wallet_data_import(cls, wallet_data):
raise Exception('"xpub" not found in "x1/" in Electrum backup json')

required_sigs = int(wallet_data.get("wallet_type").split("of")[0])
recv_descriptor = "{}(sortedmulti({}, {}))".format(
recv_descriptor = "{}(sortedmulti({},{}))".format(
wallet_type, required_sigs, xpubs
)
wallet_name = "Electrum {} of {}".format(required_sigs, i - 1)
Expand Down

0 comments on commit eaeac1f

Please sign in to comment.