spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.22k stars 3.02k forks source link

Cannot sign transaction due to RuntimeError('DataError: Forbidden key path') #9062

Closed crispweed closed 1 month ago

crispweed commented 1 month ago

Using trezor hardware device, and recovering from old multibit HD wallet seed, "m/0h" derivation path is necessary in order for Electrum to find the unspent outputs.

(With this derivation path, unspent outputs are found, and the wallet reports that bitcoin is available.)

Up to there, then, it seems that Electrum is able to generate the relevant addresses from the seed.

When attempting to send bitcoin, however, it seems that using this derivation path now causes problems. It looks like the exception is then being raised here, in electrum/keystore.py:

    def derive_pubkey(self, for_change: int, n: int) -> bytes:
        for_change = int(for_change)
        if for_change not in (0, 1):
            raise CannotDerivePubkey("forbidden path")

How come some code paths are apparently able to generate addresses with this derivation path, but not others?

SomberNight commented 1 month ago

What exactly are you doing // how to reproduce this? Please at the very least include a full traceback. The keystore is supposed to be created at the "account" level in BIP-44 parlance. i.e. if you specify a derivation path of m/0h e.g. in the GUI, the keystore will use m/0h as a "derivation prefix", and it will then derive leaf keys at x/0/i and x/1/j (so at full path m/0h/0/i and m/0h/1/j).

crispweed commented 1 month ago

Ok, so looks like this error was not actually coming from the source code I quoted, but from the Trezor itself. Sorry for the confusion!