Unable to import Electrum private key to 0.16.0 #12397

issue rex4539 opened this issue on February 9, 2018
  1. rex4539 commented at 2:51 PM on February 9, 2018: contributor

    Describe the issue. Importing a Bech32 private key in the debug console returns "Invalid private key encoding" error.

    What behavior did you expect? Private key is imported.

    What was the actual behavior (provide screenshots if the issue is GUI-related)? Invalid private key encoding (code -5)

    screen shot 2018-02-09 at 16 46 32

    How reliably can you reproduce the issue, what are the steps to do so?

    1. walletpassphrase "mypasswordhere" 1000
    2. importprivkey myprivatekeyhere

    What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? Bitcoin Core 0.16.0rc3 / https://bitcoin.org/bin/bitcoin-core-0.16.0/test.rc3/

    What type of machine are you observing the error on (OS/CPU and disk type)? OSX 10.11.6 / 2,4 GHz Intel Core 2 Duo / HDD

    Any extra information that might be useful in the debugging process. My private key is a normal 52 character key starting with an L and ending with a K.

    debug.log

  2. sipa commented at 7:14 PM on February 9, 2018: member

    The error "Invalid private key encoding" is thrown when the Base58 decoding fails. This could happen when there is a typo in the key, or if it's for the wrong network (e.g. it's a testnet key).

    Up to that point in the code, there should not be anything segwit specific.

    Where did you get this private key? Does importing it work when you run an earlier version?

  3. rex4539 commented at 7:20 PM on February 9, 2018: contributor

    There is definitely no typo or wrong network issue.

    I'm copy/pasting it from Electrum.

    I have created and use this Bech32 address in Electrum (mainnet).

    I tried with Bitcoin Core 0.16.0rc2 and it fails there too.

    Didn't try with earlier versions because it is my understanding that 0.16 is the first version supporting Bech32.

  4. sipa commented at 7:23 PM on February 9, 2018: member

    This has nothing to do with Bech32. The set of acceptable private keys hasn't changed.

    Perhaps Electrum introduced their own new private key format, which isn't compatible?

  5. rex4539 commented at 7:34 PM on February 9, 2018: contributor

    I will test with 0.15.1 and report back.

  6. MarcoFalke added the label Questions and Help on Feb 9, 2018
  7. rex4539 commented at 8:01 PM on February 9, 2018: contributor

    Same bug with 0.15.1

    Oh well, I guess I will not be able to import this key into Core...

    It's a shame because I wanted to fully transition to Core.

    I have imported all my legacy private keys and this was the last one.

    Will stick to Electrum for Bech32 then.

  8. sipa commented at 8:03 PM on February 9, 2018: member

    @rex4539 I'm sure there's a way to convert the private key into Bitcoin Core's format.

  9. rex4539 commented at 10:01 PM on February 9, 2018: contributor

    If anyone has a tool for converting it, I'd be happy to try it :)

  10. MarshMallowMan commented at 12:45 AM on February 10, 2018: none

    Could you possibly be using a 2 Factor Authentication Electrum Wallet? saw another post online of someone failing to import keys to bitcoin core from Electrum and that was his problem.

  11. rex4539 commented at 5:36 AM on February 10, 2018: contributor

    No, just using a simple segwit wallet.

  12. rex4539 renamed this:
    Unable to import Bech32 private key to 0.16.0
    Unable to import Electrum private key to 0.16.0
    on Feb 10, 2018
  13. Sjors commented at 2:23 PM on February 10, 2018: member

    Duplicate of #12111

  14. rex4539 commented at 9:23 PM on February 10, 2018: contributor

    Tried the solution mentioned in the linked post but still getting the same error.

  15. Sjors commented at 9:38 PM on February 10, 2018: member

    @rex4539 your best chance is probably to ask the Electrum folks (and maybe share their solution in #12111)

  16. rex4539 commented at 9:44 PM on February 10, 2018: contributor

    ok, the correct solution is the one posted here:

    https://github.com/spesmilo/electrum/issues/3667

    Finally imported the bech32 address into Core :)

  17. rex4539 closed this on Feb 10, 2018

  18. ecdsa commented at 10:08 PM on February 10, 2018: none

    @sipa indeed we extended the WIF format in Electrum version 3.0, in order to have a bijection between WIF and addresses. Maybe we will switch to a format with a user-readable prefix, eg: "p2pkh:base58privkey"

  19. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 06:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me