Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: COBRAS on September 09, 2021, 02:34:55 AM



Title: How to find XPUB adress in wallet.dat file ?
Post by: COBRAS on September 09, 2021, 02:34:55 AM
How to find XPUB adress in wallet.dat file ?


thx


Title: Re: How to find XPUB adress in wallet.dat file ?
Post by: n0nce on September 09, 2021, 11:05:26 AM
See this stackexchange answer.

Bitcoin Core uses hardened derivation so there simply is no xpub to begin with, it isn't being hidden from you or obscured.

However, you could get xprv by using dumpwallet command.
The use case for this is however quite different :D If OP e.g. wants to extract xpub to watch Core wallets on a mobile Bitcoin app, please don't try to now transfer xpriv to your phone or other insecure system in any way or form...


Title: Re: How to find XPUB adress in wallet.dat file ?
Post by: n0nce on September 09, 2021, 11:21:18 AM
I often see OP dealing with private/public key, so i assume he already know how to handle xprv securely. If the want to create watch-only wallet, he could simply copy list of addresses generated by dumpwallet command.
Alright, just wanted to make sure that someone doesn't think 'okay, it spits out only xpriv, then let's try that instead' ;)


Title: Re: How to find XPUB adress in wallet.dat file ?
Post by: BitMaxz on September 09, 2021, 01:21:48 PM
Alright, just wanted to make sure that someone doesn't think 'okay, it spits out only xpriv, then let's try that instead' ;)

It should include the public key or addresses if you use the command dumpwallet

Here's the sample of dumpwallet testnet result
Quote
# Wallet dump created by Bitcoin v0.21.0   
# * Created on 2021-01-21T16:59:50Z   
# * Best block at time of backup was 1905234 (00000000e26170d0f846a334a1bfdfebe8da906c5),   
#   mined on 2021-01-21T17:05:05Z   

# extended private masterkey: tpR2efnJMh85ufpQcYSTwrrKrYJ   

cTdH4SbvTR 1970-01-01T00:00:01Z label= # addr=mnb8RSpTqvhLh8Q6,2MudYFE2awqc,tbvhpur8zf35ql3yx5h9nu   
cRaKzuR9MCVwAxVa3aAZrVh15YbV 2019-08-26T01:19:00Z reserve=1 # addr=tb1q3qc52q hdkeypath=m/0'/0'/222'   
cT2ozo5xcj6iCe4dTfywan3qJnib 2019-08-26T01:19:00Z hdseed=1 # addr=tb1qzqtu25qsue0a5pp3hg8lkftclf8ds   
cNb2K9tUhQaeXiVz2Jt2Wq9DMLdf 2019-08-26T01:19:00Z reserve=1 # addr=tb14d7lx hdkeypath=m/0'/0'/117'   

.....4040 lines   
# End of dump
Source: https://bitcoin.stackexchange.com/questions/101767/dumpwallet-output-documentation-explanation

under addr= should be the public key.