Skip to content

Conversation

@jonasschnelli
Copy link
Contributor

@jonasschnelli jonasschnelli commented Jun 15, 2016

  • Adds the base58check encoded extended master key to the "dumpwallet" file format (as a comment line).
  • Adds "master=1" as key dump flag
  • Lists the P2PKH address HASH160 of the master key in getwalletinfo

Before:

# Wallet dump created by Bitcoin v0.12.99.0-a552aca-dirty
# * Created on 2016-06-15T08:15:56Z
# * Best block at time of backup was 810 (530d5809aa50bcb4b35be0285aaafce93ccaf62c5410e53b9c4ce0c788c5a841),
#   mined on 2016-06-10T08:47:06Z

cVf2BZsGdkK8YanPbuxoP8CbEARU5sAYQKUs8j3Nf2wshCNQRAzo 2016-06-10T06:46:42Z change=1 # addr=myzPbNLzcmFSAW739GsB36r5HSZBfjuTUH

After:

# Wallet dump created by Bitcoin v0.12.99.0-a498925
# * Created on 2016-06-15T08:58:18Z
# * Best block at time of backup was 810 (530d5809aa50bcb4b35be0285aaafce93ccaf62c5410e53b9c4ce0c788c5a841),
#   mined on 2016-06-10T08:47:06Z

# extended private masterkey: tprv8ZgxMBicQKsPcuhwAr4bbp1p8BXKeYQutTqhh23QQKpVAfQcenCnLWMcWGpuK6Gnhuw19GHGg2oVwMnR9DYfbyvwFN4r5uB1YHspewdSEGJ

cVf2BZsGdkK8YanPbuxoP8CbEARU5sAYQKUs8j3Nf2wshCNQRAzo 2016-06-10T06:46:42Z hdmaster=1 # addr=myzPbNLzcmFSAW739GsB36r5HSZBfjuTUH
{
  "walletversion": 60000,
  "balance": 0.00000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 0,
  "keypoololdest": 1465977498,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "masterkeyid": "039aac5f30713ecba8fed140c45d926bfc9ca2ca"
}

@jonasschnelli jonasschnelli changed the title [Wallet] add HD xpriv to dumpwallet, show masterkeyid in getwalletinfo [Wallet] Add HD xpriv to dumpwallet, show masterkeyid in getwalletinfo Jun 15, 2016
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of "the P2PKH address of the hd master key"? Why would someone need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extended keys are mostly not P2PKH encoded (they have their "own encoding format"). But here we print the masterkeyid. A P2PKH address should be okay for this case, but we should label it as P2PKH.

Copy link
Member

@sipa sipa Jul 7, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonasschnelli I think it is good to split off this change to another pull, as it seems too controversial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is, we store the masterkeyid as a CKeyID. IMO to get the xpub (base58 check encoded extended public key) we need to have a unlocked wallet.
@sipa: What would you propose instead? Caching the xpub in a separate wallet.dat record type?

Copy link
Member

@sipa sipa Jul 7, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonasschnelli jonasschnelli force-pushed the 2016/06/hd_info branch 2 times, most recently from 578b35d to 4ba20ac Compare July 7, 2016 15:19
@jonasschnelli
Copy link
Contributor Author

Changed the masterkey-ID from P2PKH to a plain hex of the Hash160.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: comment still says addr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could mention that this is the pubkey.

@maflcko maflcko added this to the 0.14 milestone Jul 8, 2016
@jonasschnelli
Copy link
Contributor Author

Fixed @MarcoFalke 's nits.

@jonasschnelli
Copy link
Contributor Author

@MarcoFalke: -salvagewallet only recovers private keys. It will recover your seed, but will not activate it. We might want to also try to recover the metadata which key is used as hd seed...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is already merged. Needs rebase

@jonasschnelli
Copy link
Contributor Author

Rebased and fixed nits.

@jonasschnelli
Copy link
Contributor Author

Fixed rebase issue (const CHDChain& GetHDChain() was defined twice).

@maflcko maflcko changed the title [Wallet] Add HD xpriv to dumpwallet, show masterkeyid in getwalletinfo [Wallet] Add HD xpriv to dumpwallet Jul 20, 2016
@jtimon
Copy link
Contributor

jtimon commented Jul 20, 2016

"Implementation looks really clean and simple, and like it should compile ACK" d07513c
That's right, not even a "concept ACK". But it doesn't look like I'll be against the concept once I put more time into understanding it either.

@jonasschnelli jonasschnelli modified the milestones: 0.13.0, 0.14 Jul 21, 2016
@maflcko
Copy link
Member

maflcko commented Jul 21, 2016

Tested ACK 0d17b08

  • HD wallet dump before and after
--- /tmp/hd_old 2016-07-21 22:08:29.063603489 +0200
+++ /tmp/hd_new 2016-07-21 22:28:20.219771942 +0200
@@ -1,9 +1,11 @@
-# Wallet dump created by Bitcoin v0.12.99.0-51a4ee8-dirty
-# * Created on 2016-07-21T20:08:29Z
+# Wallet dump created by Bitcoin v0.13.99.0-0d17b08
+# * Created on 2016-07-21T20:28:20Z
 # * Best block at time of backup was 0 (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206),
 #   mined on 2011-02-02T23:16:42Z

-cT5hkmWtB9JjGQ98pnfxyHokCKcht8MnGNgGtvhq4M5FvnbE3PT 2011-02-02T21:16:42Z change=1 # addr=moFcHwrWqkULwZ8yrCN8SkPgyBHzAq5WDF
+# extended private masterkey: tprv8ZgxMBicQKsPdriJqoSXGJgLwhkQVGzgr7CMvA79HSYtLYf4rYtwFkkNZAL1qBiE29bkwTF6Sf2Wjn3zUTw5LeWnZgToQq1NAhNDn3ot
+
+cT5hkmWtB9JjGQ98pnfxyHokCKcht8MnGNgGtvhq4M5FvnbE3PT 2011-02-02T21:16:42Z hdmaster=1 # addr=moFcHwrWqkULwZ8yrCN8SkPgyBHzAq5WDF
 cVrL8K7UNJa3L78tsuAjdi51HCnQMTkWrDWhNb2dKtzozyReanc 2016-07-21T20:08:14Z label= # addr=mqaKs6gthQGVXWjaaWF9tmpcMrXCYRbKRb
 cQajRw3Fnk9QovuXsbrj21SX3EJcF5trzRcrCi85cPzN62qJnMq 2016-07-21T20:08:14Z reserve=1 # addr=mySBbQzsTLBdEwJe6CKEL1HNnqsM9EZm68
  • Classic wallet before and after
--- /tmp/no_old 2016-07-21 22:07:55.770906223 +0200
+++ /tmp/no_new 2016-07-21 22:28:42.492569385 +0200
@@ -1,5 +1,5 @@
-# Wallet dump created by Bitcoin v0.12.99.0-51a4ee8-dirty
-# * Created on 2016-07-21T20:07:55Z
+# Wallet dump created by Bitcoin v0.13.99.0-0d17b08
+# * Created on 2016-07-21T20:28:42Z
 # * Best block at time of backup was 0 (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206),
 #   mined on 2011-02-02T23:16:42Z

@jonasschnelli jonasschnelli force-pushed the 2016/06/hd_info branch 2 times, most recently from 3c30f5b to aa5487b Compare July 22, 2016 09:36
@jonasschnelli
Copy link
Contributor Author

Slightly updated to allow identifying old, non active master keys (currently useful after encrypting the wallet).
Also added the keypath in the comment section of each key.

Example of an encrypted wallet done with #8389:

# Wallet dump created by Bitcoin v0.13.0.0-2b9f372-dirty
# * Created on 2016-07-22T09:25:58Z
# * Best block at time of backup was 0 (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206),
#   mined on 2011-02-02T23:16:42Z

# extended private masterkey: tprv8ZgxMBicQKsPd5xrraojbVg9Etp7JAindCm1q5iLyp6JnzaFnFyRP3ruMwizMTjNBDUNxQfyjZbzvWSEjCMP7jaJS7Cj9XikDLZoj3xNmBS

cTATMp7yBuGjKB9eRowuZv6YzVTpcgicq79diJdLq4rBCUGDuNxN 2016-07-22T09:18:00Z change=1 # addr=mik21P4JTNFt37Lj6LGKihHA3wZ1qigSgx hdkeypath: m/0'/0'/7'
cRkWTpXeca4HDnD5Lu8SXkZr4iDQSraD24du4HcT91eKw81Vchm2 2016-07-22T09:18:00Z change=1 # addr=mjygFDgoaqgh36kEGNRpHLQDTksa3s5MRy hdkeypath: m/0'/0'/1'
cP7h7Kocgu75DJZZoyuh8JkDhmqZtobdsUWWbN7aZpc9Cm4pWGYP 2016-07-22T09:18:00Z change=1 # addr=mm43KEzEpadHBB5biiC9Xb8uSr7zr8bHFG hdkeypath: m/0'/0'/4'
cR6qyrB3i2SvXFEtWGdf3CU2xVbAhFWQQLwG2hvhJCAshB1dNMme 2016-07-22T09:18:00Z change=1 # addr=mm8m5fT4XJTvjoWPEQEnZB4vCi7PX6G8Np hdkeypath: m/0'/0'/2'
cQWEKErbdMaBm9Jq4bhgDRmieeY6beruyCgiKBkpwaPrmk5zwXEj 2016-07-22T09:18:00Z label= # addr=mq6je35LGwWDxBsYKoGWjXMyvrWPY4bieV hdkeypath: m/0'/0'/0'
cMfLpMYL3S2VBrTWBaVbeWiaBTDhG3PHZVkGv99tHp3sEC8BKUu8 2016-07-22T09:18:00Z change=1 # addr=mttBmwdL5GLCmhS8wRCeSKk8oYLnoPp16p hdkeypath: m/0'/0'/3'
cMgur3MsbhLRxNgSE8kVcH6A2reDvMkGuHHTYUYVUvssXqBdjjHr 2016-07-22T09:18:00Z change=1 # addr=muJfnEN2NTeBxxF8Gof93MqfBiAbyfFEha hdkeypath: m/0'/0'/5'
cVrDVdP5JMn6EgAZfSGC95KE347WmAGZfdXMXde2rS2qsXxbpjmk 2016-07-22T09:18:00Z oldhdmaster=1 # addr=mvvBZ1Md38ZNgbBrz5ZL7cCFykiRwNxaee hdkeypath: m
cPKq9W9LonJLK7VpZT4488x9JbSmwt4xsSnMEenEfqdggi8JDrns 2016-07-22T09:18:00Z change=1 # addr=mxy6ME2nxAw2PXyfqqGxjBbccCbYnfxbN1 hdkeypath: m/0'/0'/6'
cSjjNu2Z1LFF91siFFCJdqym1K7HBuV9oX7u9M3BBaheUhL9j8ti 2016-07-22T09:18:00Z change=1 # addr=n4PG8RF16Z16aiWdGxjiTAKLh5vhW28Z7W hdkeypath: m/0'/0'/8'
cTceAiNuF3P3uy1zq8mCTw5ExfgkZC9epQDQFh81JtgFBDom8Pi2 2016-07-22T09:18:01Z change=1 # addr=mohpfbNfUgwxBY5Z7PWsLUWVZfataTCLKb hdkeypath: m/0'/0'/10'
cV2oTqiG128zWUMsyakqnt9vS1o9xo6ES5Vy7aWhNtBhdNFzVku8 2016-07-22T09:18:01Z change=1 # addr=n17XEKYwc1pFY2m7BKXamVdX7jDmBuyYxk hdkeypath: m/0'/0'/9'
cRfMrm6v3D5Ypb3ozJi3s5sf2sjVv5a8wjm3oF3JeMZorj6ujkvR 2016-07-22T09:25:29Z reserve=1 # addr=mgEYLY5vXDG8sNoF4oiHsuTsEfgbc9DCrW hdkeypath: m/0'/0'/5'
cTADRxhPRsnonzqvaK1pE8zFC44roVDTRmGqULk2j1BecHpD55Nk 2016-07-22T09:25:29Z reserve=1 # addr=mgJn4zqYqGrbRXkcyVg4bL4PVtEVtMvNw5 hdkeypath: m/0'/0'/9'
cUHRMwwVmhX38JCNqtyM7U71ZDdA1xjEQKSJ63BUsSpGa11H2zHH 2016-07-22T09:25:29Z reserve=1 # addr=mmz1jW6Rnc7dMVaavoimHraWfw9RawSD6G hdkeypath: m/0'/0'/0'
cQBYTxbHTJETGYdQuFEq63rR2ZUpNXCUVPpRHxqq3xJSGE3Ny9S1 2016-07-22T09:25:29Z reserve=1 # addr=mpYTX3bj6aPJAj2RrvNJzn6RfS6o4HMpfA hdkeypath: m/0'/0'/1'
cRHKQMthnHt8Zv16zQJJSHMrF8SeNHNFBZ93AHASfvakjoh1XumW 2016-07-22T09:25:29Z reserve=1 # addr=mq3JTBit3C5GVd83gHZZ6655kZY4pd2rdR hdkeypath: m/0'/0'/7'
cTL35ENNE7FvtHzUZRicG5C2hHaRQaxzhHtVzgsm2y6WLJkNo5Ls 2016-07-22T09:25:29Z reserve=1 # addr=mtZwQY6FKZkdjy25djWUNsuKa7L25AnQDg hdkeypath: m/0'/0'/2'
cS39uGTtoePbuY9fmPKHQ3k87Y2XEd2StsL5KBgcLXMBYb6qabok 2016-07-22T09:25:29Z hdmaster=1 # addr=mxC8X9VJSCp6Zniu4dd4iRBzkJhJf68YoM hdkeypath: m
cR5bkb8zmVRDrq493MahwnpNu8U8zvqZ6UjMFJ3Uc9sJN9ea1tzT 2016-07-22T09:25:29Z reserve=1 # addr=mzECSuZ3r9GVLhQeGfkyEVjGfzfMFdnwyn hdkeypath: m/0'/0'/8'
cMcQjv1qGcb6F68bR4GzmSfTTuBPp2hNUGAsAicAQa8z6KX7d5eu 2016-07-22T09:25:29Z reserve=1 # addr=mzhbwXYTtnhkGpFEnZoNG6SV9Wih2rAwcG hdkeypath: m/0'/0'/4'
cPPBqv9UQKSTofYez72eE4HAa6aLY9e17ycae96PmDG3hBnTjKVh 2016-07-22T09:25:29Z reserve=1 # addr=n1KXTTZAXLha5JruXy3RnA2y4tk63nsztU hdkeypath: m/0'/0'/3'
cQ3sDHnWD3UTV6BnNecZ3d1r3Z2ULMG2HjTgpoEMAYd2m1jTf7sK 2016-07-22T09:25:29Z reserve=1 # addr=n2jujGbNUKtTe8wHDvDDtwm7dLtasvm6xj hdkeypath: m/0'/0'/6'
cSbkZ7ff2HaKephpeNFMfBVsLftq7Zmu3A4F6rwnPoz4iBcGkNwo 2016-07-22T09:25:55Z reserve=1 # addr=mpbx56wFoHfq5voMrQz6J6SpjJrP7KXRVi hdkeypath: m/0'/0'/10'

# End of dump

Though, this PR does not directly depend on #8389.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this code simplification

@jonasschnelli
Copy link
Contributor Author

Force push changed two typo/text-only changes s/keypath:/keypath= and s/oldhdmaster/inactivehdmaster.

@laanwj laanwj merged commit 77c912d into bitcoin:master Jul 27, 2016
laanwj added a commit that referenced this pull request Jul 27, 2016
77c912d [Wallet] add HD xpriv to dumpwallet (Jonas Schnelli)
@laanwj
Copy link
Member

laanwj commented Jul 27, 2016

Tested ACK 77c912d

laanwj pushed a commit that referenced this pull request Jul 27, 2016
@maflcko
Copy link
Member

maflcko commented Jul 31, 2016

Removed "Needs backport"

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants