I want to know what the 5183a8d8 in the xpub above is generated based on, is this the fingerprint?
Just get the
HASH160 of the compressed public key pair of ECDSA Private key part (
without the 'Chain Code') of the "
Master Private Key".
Given that your example has an "
Extended Public Key" instead, you wont be able to compute the master fingerprint from it.
I'll provide you a valid example:
Descriptor (
Master Fingerprint: de651e9f):
"wpkh([de651e9f/84h/1h/0h]tpubDDDduCzj2qe9kXmasbrKu8CxNG6LoueVcQbeb3mJ9nKC9m2UnwKxGupu83TKhq9EV4RCCXdsf5mVboMh5FBf5AC74PPHXh2fBrP47q7oqHx/1/*)
Descriptor with Master Private Key (
private version of the above):
"wpkh(tprv8ZgxMBicQKsPfMMj4bdRMrXr3RMDCc24Pqqa3TAGHBrqgtSQ6mYnxzHLNPzSJD1m8hv3pEjiu3fYdGTcVzc8WNvfChULWAQAqojcimN4D4h/84'/1'/0'/1/*)
Now to compute the Master Fingerprint:
const bitcoin = require('bitcoinjs-lib');
const bip39 = require('bip39');
const bitcoinMessage = require('bitcoinjs-message');
const ecc = require('tiny-secp256k1')
const { BIP32Factory } = require('bip32')
const bip32 = BIP32Factory(ecc)
function computeFingerprintFromXPriv() {
const mnemonic = "top ritual venue glad soon alcohol annual base tornado invest speak lpke";
const seed = bip39.mnemonicToSeedSync(mnemonic);
const network = bitcoin.networks.testnet;
const root = bip32.fromSeed(seed, network);
const path = "m/86'/1'/0'";
const account = root.derivePath(path);
const xpriv = account.toBase58()
const extendedPublicKey = account.neutered().toBase58();
console.log(extendedPublicKey)
const node = bip32.fromBase58(xpriv,network);
const compressedPublicKey = node.publicKey;
const hash160 = bitcoin.crypto.hash160(compressedPublicKey);
console.log(`Master fingerprint: ${hash160.toString('hex')}`);
return hash160.toString('hex').substring(0,
;
}
I successfully reproduced it using bitcoinjs of node, but the final result of hash160 does not correspond to the correct result. I don't know why
[133a3b35/86h/1h/0h]tpubDCynnv7orn7ymby6QpWMgw9DwJahdDzzgxARwSd4ipdJ9rv5na4ppub8Pv6346pWtigrNMFrnau
uCgcsx1SrtaWqNuELKFGTeZYvAVhX3ES/<0;1;9;10>
The correct result is 133a3b35, but the final output is de404428. I have confirmed that the extended public key is consistent with the extended public key result above, but the fingerprint is different. I don't know why