How to get a pubKey for an address using bitcoin-cli

1 reply 182 views
Posts: 8 · Reputation: 167
#1Jul 11, 2025, 11:01 PM
Hey tech peeps, I could really use your help with finding my wallet's public key for a specific address. Here's what I know so far: The scriptPubKey doesn’t have the public key for Taproot addresses anymore. The bitcoin-cli commands `validateaddress` and `getaddressinfo` don’t give back the pubKey either. The addresses I’m looking at have only been used for receiving, so there haven't been any transactions to pull the pubKey from. Right now, the only method I have is to dump the private key via bitcoin-cli, then import it into bitcoin-js to get the pubKey. But honestly, I’d prefer not to do that. Thanks for any tips or insights you can share. Really appreciate it! BTC
5 Reply Quote Share
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#2Jul 12, 2025, 04:35 AM
Since you're talking about a wallet with TapRoot, it must be a descriptor wallet. So, how are you able to export its private key? I'm curious. Anyways, you may use getaddressinfo, then take note of the extended public key in its "parent_desc" and the derivation path's internal/external chain index. (the number after the "/" on its right, '0' for receiving addresses, '1' for change addresses) And also the "address_index" in its descriptor - "desc:". (the last digit on its derivation path) Then use bitcoin-js or other tool to derive the public key from the xpub. e.g. (RegTest): getaddressinfo bcrt1pg9aez39kk2w5qucfy5da340amz3ajzug7zs4xetpkhzcr5maxwgqfw43k0 ... "desc": "tr([de651e9f/86h/1h/0h/0/3]6dd8531afdb9ce153cd8a053cc94e125ed7efc2be0e2c451b57104330274a595)#hskruc03", "parent_desc": "tr([de651e9f/86h/1h/0h]tpubDCjhgDSSsWLW5xD6nFUQswRHkdJrdAmfJqu8jewwoWYgXvvdA5jr2qqEZc38UVynn1zPMJv7vw8 hPXuhfd7yZhuLh5Fbq2mPb4CVrcE5To4/0/*)#l6qxnyxd", ... From the example; (external) chain index = 0 & address_index = 3. So derive the public key at tpub/0/3 which should be the public key of the address. Public key: 036dd8531afdb9ce153cd8a053cc94e125ed7efc2be0e2c451b57104330274a595 (I used IanColeman's BIP39 tool for this example, I don't use bitcoin-js)
3 Reply Quote Share

Related topics