electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 3b8c1c6c04effe94ffe50ad2076840ef6439835d
parent 4ff3791cb93fcdda0b534bc2be575121f4d59705
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri,  6 Apr 2018 18:29:41 +0200

detect when trying to sign with a hw wallet offline in a not supported config

closes #4229

Diffstat:
Mplugins/keepkey/plugin.py | 4+++-
Mplugins/ledger/ledger.py | 3+++
Mplugins/trezor/trezor.py | 4+++-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/plugins/keepkey/plugin.py b/plugins/keepkey/plugin.py @@ -7,7 +7,7 @@ from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey, from electrum import constants from electrum.i18n import _ from electrum.plugins import BasePlugin -from electrum.transaction import deserialize +from electrum.transaction import deserialize, Transaction from electrum.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey from electrum.base_wizard import ScriptTypeNotSupported @@ -48,6 +48,8 @@ class KeepKeyCompatibleKeyStore(Hardware_KeyStore): for txin in tx.inputs(): pubkeys, x_pubkeys = tx.get_sorted_pubkeys(txin) tx_hash = txin['prevout_hash'] + if txin.get('prev_tx') is None and not Transaction.is_segwit_input(txin): + raise Exception(_('Offline signing with {} is not supported for legacy inputs.').format(self.device)) prev_tx[tx_hash] = txin['prev_tx'] for x_pubkey in x_pubkeys: if not is_xpubkey(x_pubkey): diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py @@ -350,6 +350,9 @@ class Ledger_KeyStore(Hardware_KeyStore): self.give_error("No matching x_key for sign_transaction") # should never happen redeemScript = Transaction.get_preimage_script(txin) + if txin.get('prev_tx') is None: # and not Transaction.is_segwit_input(txin): + # note: offline signing does not work atm even with segwit inputs for ledger + raise Exception(_('Offline signing with {} is not supported.').format(self.device)) inputs.append([txin['prev_tx'].raw, txin['prevout_n'], redeemScript, txin['prevout_hash'], signingPos, txin.get('sequence', 0xffffffff - 1) ]) inputsPaths.append(hwAddress) pubKeys.append(pubkeys) diff --git a/plugins/trezor/trezor.py b/plugins/trezor/trezor.py @@ -6,7 +6,7 @@ from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey, from electrum import constants from electrum.i18n import _ from electrum.plugins import BasePlugin, Device -from electrum.transaction import deserialize +from electrum.transaction import deserialize, Transaction from electrum.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey from ..hw_wallet import HW_PluginBase @@ -63,6 +63,8 @@ class TrezorKeyStore(Hardware_KeyStore): for txin in tx.inputs(): pubkeys, x_pubkeys = tx.get_sorted_pubkeys(txin) tx_hash = txin['prevout_hash'] + if txin.get('prev_tx') is None and not Transaction.is_segwit_input(txin): + raise Exception(_('Offline signing with {} is not supported for legacy inputs.').format(self.device)) prev_tx[tx_hash] = txin['prev_tx'] for x_pubkey in x_pubkeys: if not is_xpubkey(x_pubkey):