hdMasterKey and hdMasterKeyId do not actually refer to the BIP 32 Master Key #12084

issue achow101 openend this issue on January 4, 2018
  1. achow101 commented at 1:49 am on January 4, 2018: member

    The actual BIP 32 master key in a wallet (the key which every key is derived from) is not actually the same key that is reported as being the BIP 32 master key by basically everything in the wallet that reports it.

    Instead the key that is reported as being the BIP 32 master key is actually the seed. This seed is hashed according to the BIP 32 specification to become the BIP 32 master key which everything else is then derived from.

    A number of things are wrongly reported and named because of this:

    • hdmasterkeyid in validateaddress and getwalletinfo
    • The key marked as hdmaster with keypath m in the dumpwallet output
    • The extended private masterkey in dumpwallet output is the actual master private key and has a different id than hdmasterkeyid used elsewhere
    • Almost all uses of masterkey and masterkeyid in the wallet code refer to the seed rather than the actual masterkey.

    While this discrepancy does not currently affect usage, it could in the future with possible master key importing or seed importing. With the way that things are currently named, it would be confusing as to whether an import worked properly.


    I found this while implementing BIP 174 and it totally derailed me for 3 hours since it needs the actual master key id

  2. fanquake added the label Wallet on Jan 4, 2018
  3. jonasschnelli commented at 9:07 am on January 4, 2018: contributor

    Yes. This is correct. It should probably have been named hdseed. I guess the user visible forms of the master key should be in the base58check representation (xpriv) of the extend private master key.

    • One step would be to rename hdmaster to hdseed (for legacy reasons and to identify key relations), same for hdmasterkeyid (to hdseedid)
    • Another step would be to add hdextmaster where we could use the base58check encoding of the extended master key
  4. MarcoFalke commented at 11:03 am on January 4, 2018: member
    Related: #8684
  5. jonasschnelli referenced this in commit 6738813bcb on May 21, 2018
  6. jonasschnelli commented at 7:47 am on May 21, 2018: contributor
    Closing (fixed with #12924)
  7. jonasschnelli closed this on May 21, 2018

  8. UdjinM6 referenced this in commit a39799d0e9 on Jun 18, 2021
  9. UdjinM6 referenced this in commit e1bebeb731 on Jun 24, 2021
  10. UdjinM6 referenced this in commit 984a37825d on Jun 26, 2021
  11. UdjinM6 referenced this in commit 7de8332d9e on Jun 26, 2021
  12. UdjinM6 referenced this in commit 21bb444ad3 on Jun 28, 2021
  13. MarcoFalke 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: 2024-12-18 18:12 UTC

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