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
invalidateaddress
andgetwalletinfo
- The key marked as
hdmaster
with keypathm
in thedumpwallet
output - The extended private masterkey in
dumpwallet
output is the actual master private key and has a different id thanhdmasterkeyid
used elsewhere - Almost all uses of
masterkey
andmasterkeyid
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