Skip to content

Commit a960ad0

Browse files
authored
Fix #822 (#825)
1 parent 687eca0 commit a960ad0

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/cryptoadvance/specter/server_endpoints/devices.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def device(device_alias):
258258
action = request.form["action"]
259259
if action == "forget":
260260
if len(wallets) != 0:
261-
err = "Device could not be removed since it is used in wallets: {}.\nYou must delete those wallets before you can remove this device.".format(
261+
err = "Device could not be removed since it is used in wallets: {}.<br>You must delete those wallets before you can remove this device.<br>You can delete a wallet from its Settings -> Advanced page.".format(
262262
[wallet.name for wallet in wallets]
263263
)
264264
else:
@@ -270,8 +270,14 @@ def device(device_alias):
270270
)
271271
return redirect("")
272272
elif action == "delete_key":
273-
key = request.form["key"]
274-
device.remove_key(Key.from_json({"original": key}))
273+
key = Key.from_json({"original": request.form["key"]})
274+
wallets_with_key = [w for w in wallets if key in w.keys]
275+
if len(wallets_with_key) != 0:
276+
err = "Key could not be removed since it is used in wallets: {}.<br>You must delete those wallets before you can remove this key.<br>You can delete a wallet from its Settings -> Advanced page.".format(
277+
", ".join([wallet.name for wallet in wallets_with_key])
278+
)
279+
else:
280+
device.remove_key(key)
275281
elif action == "rename":
276282
device_name = request.form["newtitle"]
277283
if not device_name:

src/cryptoadvance/specter/templates/device/device.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<br>
7979
{% if device.supports_hwi_toggle_passphrase %}
8080
<button type="button" class="btn centered" onclick="togglePassphrase('{{ device.device_type }}')">Toggle device passphrase</button>
81+
<br>
8182
{% endif %}
8283
<form action="./" method="POST">
8384
<button type="submit" name="action" value="forget" class="btn danger centered" id="forget_device">Forget the device</button>

src/cryptoadvance/specter/wallet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,11 @@ def get_electrum_file(self):
848848

849849
to_return = {"wallet_type": "{}of{}".format(self.sigs_required, len(self.keys))}
850850
for cnt, device in enumerate(self.devices):
851-
key = [key for key in device.keys if key in self.keys][0]
851+
keys_matched = [key for key in device.keys if key in self.keys]
852+
if keys_matched:
853+
key = keys_matched[0]
854+
else:
855+
return {"error": "Missing key couldn't be found in any device"}
852856
if device.device_type in electrum_devices:
853857
to_return["x{}/".format(cnt + 1)] = {
854858
"ckcc_xfp": int(

0 commit comments

Comments
 (0)