Specify whether an imported key should be imported as compressed or uncompressed #2699

issue ThePiachu opened this issue on May 26, 2013
  1. ThePiachu commented at 7:02 AM on May 26, 2013: none

    At the moment the call to import a private key looks like:

    importprivkey <bitcoinprivkey> [label] [rescan=true]

    I would like to expand it with an optional parameter of [compressed=true]. The reasoning behind it is that some people want to import their keys in a specific format to conform with either their previous format (keeping the same address between BitcoinQT and their other wallet that may or may not use compressed format), or maps to a specific vanity address they desire. The adoption of this option would encourage other wallet hosts and developers to do the same and encourage more people to use compressed keys (as opposed to uncompressed keys which are the norm at the moment since everyone else is using them).

  2. luke-jr commented at 8:09 AM on May 26, 2013: member

    I'm pretty sure the private key encoding specifies whether it's compressed or not...

  3. ThePiachu commented at 8:43 AM on May 26, 2013: none

    I think that's public key encoding. The same private key can be mapped to both compressed and uncompressed public key. It is different from Wallet Import Format (which is private key + checksum) or Mini Private Key (which needs to be hashed into a normal private key).

  4. luke-jr commented at 8:52 AM on May 26, 2013: member

    Reading base58.h, it seems that the private key format simply appends a 0x01 byte to the binary data, if it's a compressed key, before running it through the usual Base58Check algorithm...

  5. laanwj commented at 11:46 AM on May 26, 2013: member

    @luke-jr is correct. If the length of the key is 33, and the last byte of the private key is 0x01, the key is interpreted as compressed. Otherwise, it is treated as uncompressed. So an additional parameter is not needed.

  6. laanwj closed this on May 26, 2013

  7. 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-21 18:16 UTC

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