Author

Topic: I loss privkey, but I have address, xpriv and hdseed ... (Read 261 times)

newbie
Activity: 8
Merit: 4
Thank you for that answer.

The fact is that I had a lot of feedback telling me that the berkeley db version was essential for a good reading of the wallet (4.8 required).
I suspected for a long time that there is no private key but I signed up and asked for help here to make sure I didn't forget anything in the way.
HCP
legendary
Activity: 2086
Merit: 4361
It honestly sounds like you've either imported an address to your wallet (without the associated private key) and then sent funds to that address... or, at some point, you imported a "standalone" private key generated from an external source which was obviously not backed up by the seed/xpriv and backup(s) of the wallet.dat with that private key included were not made (or were subsequently misplaced/lost).

Bitcoin Core doesn't delete keys from your wallet file... and given you have the xpriv, hdseed and a full walletdump with all the private keys etc and you're still unable to find the address/private key controlling the coins, then this would suggest that the funds were indeed sent to a "watching-only" or "standalone" address Undecided


I'm not sure what you were expecting trying different Bitcoin Core versions, different OSes and/or compiling your own version of Bitcoin Core... if the key isn't in your wallet.dat, then you're not going to 'find the coins' no matter what you do.

After fully syncing Bitcoin Core, and rescanning the wallet.dat, a simple dumpwallet would show all the keys that were in the wallet.dat (and/or generated in the keypool etc), if the address and private key were not visible in that output, then you can be fairly sure that your wallet.dat does not hold the private necessary.


One last question, was your wallet always encrypted from when it was first created or did you add a passphrase at a later date? Huh
newbie
Activity: 8
Merit: 4
# To be sure that my compilations are good:
 - I apply: https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
 - I verify dependencies with: https://github.com/bitcoin/bitcoin/blob/master/doc/dependencies.md
 - I compile with make check and all tests are good.
 - I check my node on https://bitnodes.io/

# To be clear, all my tests are done on aws instances (t3a.2xlarge)

# This is my procedure to compile node
Code:
# Basic
sudo -s
passwd ubuntuµ
apt update
apt upgrade

# Dependencies
apt install -y libboost-all-dev libzmq3-dev libminiupnpc-dev curl git build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 software-properties-common libssl-dev libevent-dev libsqlite3-dev libnatpmp-dev

# SSH conf (put file by sftp)
sed -i 's/^PasswordAuthentication no*$/PasswordAuthentication yes/' /etc/ssh/sshd_config
service ssh reload

# Create specific user for bitcoind
adduser satoshi
su satoshi
cd ~
# Get bitcoin source and prepare compilation
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
git checkout -b 0.21
# To compile db4 lib for bitcoin's compilation.
# It's this version who'll used independent of OS library version.
./contrib/install_db4.sh `pwd`
export BDB_PREFIX='/home/satoshi/bitcoin/db4'
./autogen.sh
./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --without-gui

# Compile with check
make check

# exit satoshi, comeback to root
exit
cd /home/satoshi/bitcoin
make install

maybe i am doing some things wrong?
newbie
Activity: 8
Merit: 4
thank you for your answers (I do not have enough merit point to add to you but I will think about it in the future).

I'm trying:
- importwallet (bitcoin-cli importwallet ascii_file) + rescan -> no success.
- loadwallet (bitcoin-cli loadwallet wallet.dat) + rescan -> no success.
- import seed (bitcoin-cli sethdseed true "wifkey") + rescan -> no success.
- I generate more 4 000 000 address from xpriv with a lot of path -> no success.
- I try a lot of tools (known and unknown tool in github) to extract keys from wallet.dat (from VM without network access) -> no success

I'm trying importwallet, loadwallet, import seed with lot of version
- precompiled bitcoin binaries (from bitcoin.org)  -> no success.
- compile 0.21 with bdb 4.8 -> no success.
- compile 0.21 with bdb 5.3 -> no success.
- compile 0.18 with bdb 4.8 -> no success.
- compile 0.18 with bdb 5.3 -> no success.
- test all of this with debian 10, ubuntu 20.04 LTS, ubuntu 18.04 LTS, ubunutu 16.04 LTS -> no success

I think it's just a watch only wallet without the private key that holds the funds.
I would just like to be sure that I tested everything.
How can I be sure (prove?) that there is no privatekey associated with the address holding the funds in the files I have?

My last attempt to date:

getblockchaininfo:
Code:
$ bitcoin-cli getblockchaininfo
{
  "chain": "main",
  "blocks": 683301,
  "headers": 683301,
  "bestblockhash": "00000000000000000007ee873edad4ffa6148e80b1c764a97a216302bc9d4d7e",
  "difficulty": 20608845737768.16,
  "mediantime": 1620836374,
  "verificationprogress": 0.9999976376076224,
  "initialblockdownload": false,
  "chainwork": "00000000000000000000000000000000000000001d5069c69e80af0e88e54390",
  "size_on_disk": 391466597573,
  "pruned": false,
  "softforks": {
    "bip34": {
      "type": "buried",
      "active": true,
      "height": 227931
    },
    "bip66": {
      "type": "buried",
      "active": true,
      "height": 363725
    },
    "bip65": {
      "type": "buried",
      "active": true,
      "height": 388381
    },
    "csv": {
      "type": "buried",
      "active": true,
      "height": 419328
    },
    "segwit": {
      "type": "buried",
      "active": true,
      "height": 481824
    },
    "taproot": {
      "type": "bip9",
      "bip9": {
        "status": "started",
        "bit": 2,
        "start_time": 1619222400,
        "timeout": 1628640000,
        "since": 681408,
        "statistics": {
          "period": 2016,
          "threshold": 1815,
          "elapsed": 1894,
          "count": 763,
          "possible": false
        },
        "min_activation_height": 709632
      },
      "active": false
    }
  },
  "warnings": ""
}

sethdseed:
Code:
bitcoin-cli sethdseed true "wifkey from walletdump where hdseed=1"
error code: -5
error message:
Already have this key (either as an HD seed or as a loose private key)

rescan:
Code:
$ bitcoin-cli stop
Bitcoin Core stopping
$ bitcoind --rescan
Bitcoin Core starting

getbalances:
Code:
$ bitcoin-cli getbalances
{
  "mine": {
    "trusted": 0.00000000,
    "untrusted_pending": 0.00000000,
    "immature": 0.00000000,
    "used": 0.00000000
  },
  "watchonly": {
    "trusted": [a lot of bitcoin here],
    "untrusted_pending": 0.00000000,
    "immature": 0.00000000
  }
}
HCP
legendary
Activity: 2086
Merit: 4361
NotATether is right. I have an dumpwallet from bitcoin core 0.21
In this file hdkeypath is m/0'/0'/X' et m/0'/1'/X'
Wait... If you have the dumpwallet from bitcoin core... then you should already have the private keys that you need, as that file contains all the WIF private keys for all the generated keys? Huh What are you missing? Huh


In any case, if you have the hdseed, then theoretically, you should be able to simple create a new empty wallet in Bitcoin Core and then import the seed using the sethdseed command: https://bitcoincore.org/en/doc/0.21.0/rpc/wallet/sethdseed/


So, in your dumpwallet output, you should see a line that has "hdseed=1" like this:


Code:
KwVxXUCtGQGXrUrDjrvDZAu6bLRM6DFKTJ57gRY8FTWDLcqFfZha 2021-05-12T07:47:39Z hdseed=1 # addr=bc1qg0zlcmemuhyz6f6w3m02th2yz7d43zww9cagkm


If you use: "File" -> "Create Wallet..."



You can create a "blank" wallet:



Once that is created, go to: "Window" -> "Console"



Make sure that it is set to "blank_wallet" (or whatever name you used) in the dropdown:



Then use the sethdseed command:
Code:
sethdseed true TYPE_THE_HDSEED_WIF_FROM_DUMPWALLET_HERE

In our case:
Code:
sethdseed true KwVxXUCtGQGXrUrDjrvDZAu6bLRM6DFKTJ57gRY8FTWDLcqFfZha


After a brief pause, it should return "null"



Now, our original wallet has receiving address:
Code:
bc1q2a4wjm9v3awla7gq0j9sknq47ahat6amxncex3



And our "blank" wallet (which now has the same hdseed) also has the same receiving address:
Code:
bc1q2a4wjm9v3awla7gq0j9sknq47ahat6amxncex3



Congrats... you have successfully "cloned" your old wallet from the hdseed. Cheesy Cool



But again, what exactly are you missing if you already have the dumpwallet output? It should already have all the addresses and WIF private keys for all of those addresses... Huh Huh Huh
legendary
Activity: 2268
Merit: 18711
The command for generating more addresses in an Electrum wallet is as follows:

Code:
[wallet.create_new_address(False) for i in range(50)]

Change (False) to (True) to generate change addresses instead of receiving addresses, and change (50) to any number you like to generate that many addresses (not too large or Electrum will crash).

If you still can't find your address, then I think the easier option would be to download and run offline Ian Coleman's BIP39 page from GitHub here: https://github.com/iancoleman/bip39/releases/latest/

You can enter your xprv in the "BIP32 Root Key" box, then select "BIP32" as the derivation path, and enter any custom derivation you like and generate addresses at the bottom.
newbie
Activity: 8
Merit: 4
have you a doc or a command for thath? I'm trying since a lot of time but without success ...
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
thx for information.
is there a way to generate all of this easily?

A normal wallet will usually have up to 20 or 30 different addresses requested by a human so the Electrum console route will be feasible if you restrict the search to m/44'/0'/0'/0 (or 1)/0-30.
newbie
Activity: 8
Merit: 4
thx for information.
is there a way to generate all of this easily?
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
NotATether is right. I have an dumpwallet from bitcoin core 0.21
In this file hdkeypath is m/0'/0'/X' et m/0'/1'/X'
I don't know how to derive the key from a path.

I'm trying to use electrum (4.1.2) and by default it derives 10 keys (without possibility of specifying path).
from the console (python) I can derive more key but I failed to specify the path I want.

Yeah the first levels are going to be m/44'/0'/0', hardened derivation.

After that the fourth level is /0 if this address is classified as a receiving address, or /1 if Core generate it as a change address.

The fifth level is going to be the numerical order that your private key/address was generated - basically given to you by Core (relative to the other receiving/change privkeys in your wallet) beginning at 0. Bitcoin Core pregenerates 1000 of these paths so your private key is most definitely between m/44'/0'/0'/0/0 and m/44'/0'/0'/0/999 (or m/44'/0'/0'/1/0 and m/44'/0'/0'/1/999).

The fourth and fifth levels are unhardened.
newbie
Activity: 8
Merit: 4
NotATether is right. I have an dumpwallet from bitcoin core 0.21
In this file hdkeypath is m/0'/0'/X' et m/0'/1'/X'
I don't know how to derive the key from a path.

I'm trying to use electrum (4.1.2) and by default it derives 10 keys (without possibility of specifying path).
from the console (python) I can derive more key but I failed to specify the path I want.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
He probably has the hdseed from a bitcoin core wallet given that it makes extended use of the word.

In that case your derivation path is almost certainly m/44/0/0. Derive the private key at that path and see if it matches your address.
legendary
Activity: 2380
Merit: 5213
What wallet did you use?
How did you generate the seed?
Most of the wallets use m/44'/0'/0' as the derivation path for P2PKH addresses.

I recommend you to install electrum and import your seed without changing the derivation path.
To do so, create a new wallet, select "Standard wallet" and then "I already have a seed". Click on "Options" and check "BIP39" when importing the seed and choose legacy as the script type.
Go to "Addresses" tab and check if you can see your address there. (If "Addresses" tab is not available, click on "View" and top of the window and select "View addresses".)

If the suggestion above wasn't helpful, try blockpath.
Enter your xpub there and wait until it scans generated addresses.
Note that it's impossible to scan all possible addresses. The tool scans many of common paths.

Warning:
Download electrum only from its official website and do not forget to verify your download.
newbie
Activity: 8
Merit: 4
Hello,
All is in title.

I loss privkey from an funded P2PKH address.
I have xpriv (I can calculate xpub if necessary).
I have hdseed (priv and pub).

Is it possible to bruteforce hdpath and generate couple (pub, priv) as long as my target isn't found?
if it's possible, how ?

[sorry for my english, it's not my native language]
Jump to: