[Wallet] Add HD xpriv to dumpwallet #8206

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2016/06/hd_info changing 2 files +27 −4
  1. jonasschnelli commented at 9:10 am on June 15, 2016: contributor
    • 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:

    0# Wallet dump created by Bitcoin v0.12.99.0-a552aca-dirty
    1# * Created on 2016-06-15T08:15:56Z
    2# * Best block at time of backup was 810 (530d5809aa50bcb4b35be0285aaafce93ccaf62c5410e53b9c4ce0c788c5a841),
    3#   mined on 2016-06-10T08:47:06Z
    4
    5cVf2BZsGdkK8YanPbuxoP8CbEARU5sAYQKUs8j3Nf2wshCNQRAzo 2016-06-10T06:46:42Z change=1 # addr=myzPbNLzcmFSAW739GsB36r5HSZBfjuTUH
    

    After:

    0# Wallet dump created by Bitcoin v0.12.99.0-a498925
    1# * Created on 2016-06-15T08:58:18Z
    2# * Best block at time of backup was 810 (530d5809aa50bcb4b35be0285aaafce93ccaf62c5410e53b9c4ce0c788c5a841),
    3#   mined on 2016-06-10T08:47:06Z
    4
    5# extended private masterkey: tprv8ZgxMBicQKsPcuhwAr4bbp1p8BXKeYQutTqhh23QQKpVAfQcenCnLWMcWGpuK6Gnhuw19GHGg2oVwMnR9DYfbyvwFN4r5uB1YHspewdSEGJ
    6
    7cVf2BZsGdkK8YanPbuxoP8CbEARU5sAYQKUs8j3Nf2wshCNQRAzo 2016-06-10T06:46:42Z hdmaster=1 # addr=myzPbNLzcmFSAW739GsB36r5HSZBfjuTUH
    
     0{
     1  "walletversion": 60000,
     2  "balance": 0.00000000,
     3  "unconfirmed_balance": 0.00000000,
     4  "immature_balance": 0.00000000,
     5  "txcount": 0,
     6  "keypoololdest": 1465977498,
     7  "keypoolsize": 100,
     8  "paytxfee": 0.00000000,
     9  "masterkeyid": "039aac5f30713ecba8fed140c45d926bfc9ca2ca"
    10}
    
  2. jonasschnelli added the label Wallet on Jun 15, 2016
  3. jonasschnelli force-pushed on Jun 15, 2016
  4. jonasschnelli renamed this:
    [Wallet] add HD xpriv to dumpwallet, show masterkeyid in getwalletinfo
    [Wallet] Add HD xpriv to dumpwallet, show masterkeyid in getwalletinfo
    on Jun 15, 2016
  5. jonasschnelli force-pushed on Jun 15, 2016
  6. in src/wallet/rpcwallet.cpp: in e4d6997602 outdated
    2189@@ -2190,6 +2190,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp)
    2190             "  \"keypoolsize\": xxxx,        (numeric) how many new keys are pre-generated\n"
    2191             "  \"unlocked_until\": ttt,      (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
    2192             "  \"paytxfee\": x.xxxx,         (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
    2193+            "  \"masterkeyid\": \"<addr>\",    (string) the P2PKH address of the hd master key\n"
    


    MarcoFalke commented at 7:38 am on July 7, 2016:
    What is the meaning of “the P2PKH address of the hd master key”? Why would someone need this?

    jonasschnelli commented at 7:40 am on July 7, 2016:
    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.

    sipa commented at 8:21 am on July 7, 2016:
    I disagree with identifying it as a P2PKH address. It is not intended to receive money with, so it should not be made to look like an address.

    MarcoFalke commented at 8:24 am on July 7, 2016:
    @jonasschnelli I think it is good to split off this change to another pull, as it seems too controversial.

    jonasschnelli commented at 9:01 am on July 7, 2016:
    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?

    sipa commented at 9:25 am on July 7, 2016:
    You can use something else than xpub, no? Just don’t make it look like an address…
  7. jonasschnelli force-pushed on Jul 7, 2016
  8. jonasschnelli force-pushed on Jul 7, 2016
  9. jonasschnelli commented at 3:21 pm on July 7, 2016: contributor
    Changed the masterkey-ID from P2PKH to a plain hex of the Hash160.
  10. in src/wallet/rpcwallet.cpp: in 4ba20ac34b outdated
    2189@@ -2190,6 +2190,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp)
    2190             "  \"keypoolsize\": xxxx,        (numeric) how many new keys are pre-generated\n"
    2191             "  \"unlocked_until\": ttt,      (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
    2192             "  \"paytxfee\": x.xxxx,         (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
    2193+            "  \"masterkeyid\": \"<addr>\",    (string) the Hash160 of the hd master key\n"
    


    MarcoFalke commented at 6:07 pm on July 7, 2016:
    Nit: comment still says addr

    MarcoFalke commented at 11:38 am on July 8, 2016:
    Also, could mention that this is the pubkey.
  11. MarcoFalke added this to the milestone 0.14 on Jul 8, 2016
  12. jonasschnelli force-pushed on Jul 8, 2016
  13. jonasschnelli commented at 12:09 pm on July 8, 2016: contributor
    Fixed @MarcoFalke ’s nits.
  14. jonasschnelli commented at 9:23 am on July 9, 2016: contributor
    @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…
  15. in src/wallet/rpcwallet.cpp: in 4cdac40232 outdated
    2189@@ -2190,6 +2190,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp)
    2190             "  \"keypoolsize\": xxxx,        (numeric) how many new keys are pre-generated\n"
    2191             "  \"unlocked_until\": ttt,      (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
    2192             "  \"paytxfee\": x.xxxx,         (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
    2193+            "  \"masterkeyid\": \"<hash160>\", (string) the Hash160 of the hd master pubkey\n"
    


    MarcoFalke commented at 3:47 pm on July 18, 2016:
    I think this is already merged. Needs rebase
  16. jonasschnelli force-pushed on Jul 20, 2016
  17. jonasschnelli commented at 12:33 pm on July 20, 2016: contributor
    Rebased and fixed nits.
  18. jonasschnelli force-pushed on Jul 20, 2016
  19. jonasschnelli commented at 1:30 pm on July 20, 2016: contributor
    Fixed rebase issue (const CHDChain& GetHDChain() was defined twice).
  20. MarcoFalke renamed this:
    [Wallet] Add HD xpriv to dumpwallet, show masterkeyid in getwalletinfo
    [Wallet] Add HD xpriv to dumpwallet
    on Jul 20, 2016
  21. jtimon commented at 9:45 pm on July 20, 2016: contributor
    “Implementation looks really clean and simple, and like it should compile ACKd07513c 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.
  22. jonasschnelli added this to the milestone 0.13.0 on Jul 21, 2016
  23. jonasschnelli removed this from the milestone 0.14 on Jul 21, 2016
  24. jonasschnelli force-pushed on Jul 21, 2016
  25. MarcoFalke added the label Needs backport on Jul 21, 2016
  26. MarcoFalke commented at 8:34 pm on July 21, 2016: member

    Tested ACK 0d17b08

    • HD wallet dump before and after
     0--- /tmp/hd_old 2016-07-21 22:08:29.063603489 +0200
     1+++ /tmp/hd_new 2016-07-21 22:28:20.219771942 +0200
     2@@ -1,9 +1,11 @@
     3-# Wallet dump created by Bitcoin v0.12.99.0-51a4ee8-dirty
     4-# * Created on 2016-07-21T20:08:29Z
     5+# Wallet dump created by Bitcoin v0.13.99.0-0d17b08
     6+# * Created on 2016-07-21T20:28:20Z
     7 # * Best block at time of backup was 0 (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206),
     8 #   mined on 2011-02-02T23:16:42Z
     9
    10-cT5hkmWtB9JjGQ98pnfxyHokCKcht8MnGNgGtvhq4M5FvnbE3PT 2011-02-02T21:16:42Z change=1 # addr=moFcHwrWqkULwZ8yrCN8SkPgyBHzAq5WDF
    11+# extended private masterkey: tprv8ZgxMBicQKsPdriJqoSXGJgLwhkQVGzgr7CMvA79HSYtLYf4rYtwFkkNZAL1qBiE29bkwTF6Sf2Wjn3zUTw5LeWnZgToQq1NAhNDn3ot
    12+
    13+cT5hkmWtB9JjGQ98pnfxyHokCKcht8MnGNgGtvhq4M5FvnbE3PT 2011-02-02T21:16:42Z hdmaster=1 # addr=moFcHwrWqkULwZ8yrCN8SkPgyBHzAq5WDF
    14 cVrL8K7UNJa3L78tsuAjdi51HCnQMTkWrDWhNb2dKtzozyReanc 2016-07-21T20:08:14Z label= # addr=mqaKs6gthQGVXWjaaWF9tmpcMrXCYRbKRb
    15 cQajRw3Fnk9QovuXsbrj21SX3EJcF5trzRcrCi85cPzN62qJnMq 2016-07-21T20:08:14Z reserve=1 # addr=mySBbQzsTLBdEwJe6CKEL1HNnqsM9EZm68
    
    • Classic wallet before and after
    0--- /tmp/no_old 2016-07-21 22:07:55.770906223 +0200
    1+++ /tmp/no_new 2016-07-21 22:28:42.492569385 +0200
    2@@ -1,5 +1,5 @@
    3-# Wallet dump created by Bitcoin v0.12.99.0-51a4ee8-dirty
    4-# * Created on 2016-07-21T20:07:55Z
    5+# Wallet dump created by Bitcoin v0.13.99.0-0d17b08
    6+# * Created on 2016-07-21T20:28:42Z
    7 # * Best block at time of backup was 0 (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206),
    8 #   mined on 2011-02-02T23:16:42Z
    
  27. jonasschnelli force-pushed on Jul 22, 2016
  28. jonasschnelli force-pushed on Jul 22, 2016
  29. jonasschnelli commented at 9:36 am on July 22, 2016: contributor

    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:

     0# Wallet dump created by Bitcoin v0.13.0.0-2b9f372-dirty
     1# * Created on 2016-07-22T09:25:58Z
     2# * Best block at time of backup was 0 (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206),
     3#   mined on 2011-02-02T23:16:42Z
     4
     5# extended private masterkey: tprv8ZgxMBicQKsPd5xrraojbVg9Etp7JAindCm1q5iLyp6JnzaFnFyRP3ruMwizMTjNBDUNxQfyjZbzvWSEjCMP7jaJS7Cj9XikDLZoj3xNmBS
     6
     7cTATMp7yBuGjKB9eRowuZv6YzVTpcgicq79diJdLq4rBCUGDuNxN 2016-07-22T09:18:00Z change=1 # addr=mik21P4JTNFt37Lj6LGKihHA3wZ1qigSgx hdkeypath: m/0'/0'/7'
     8cRkWTpXeca4HDnD5Lu8SXkZr4iDQSraD24du4HcT91eKw81Vchm2 2016-07-22T09:18:00Z change=1 # addr=mjygFDgoaqgh36kEGNRpHLQDTksa3s5MRy hdkeypath: m/0'/0'/1'
     9cP7h7Kocgu75DJZZoyuh8JkDhmqZtobdsUWWbN7aZpc9Cm4pWGYP 2016-07-22T09:18:00Z change=1 # addr=mm43KEzEpadHBB5biiC9Xb8uSr7zr8bHFG hdkeypath: m/0'/0'/4'
    10cR6qyrB3i2SvXFEtWGdf3CU2xVbAhFWQQLwG2hvhJCAshB1dNMme 2016-07-22T09:18:00Z change=1 # addr=mm8m5fT4XJTvjoWPEQEnZB4vCi7PX6G8Np hdkeypath: m/0'/0'/2'
    11cQWEKErbdMaBm9Jq4bhgDRmieeY6beruyCgiKBkpwaPrmk5zwXEj 2016-07-22T09:18:00Z label= # addr=mq6je35LGwWDxBsYKoGWjXMyvrWPY4bieV hdkeypath: m/0'/0'/0'
    12cMfLpMYL3S2VBrTWBaVbeWiaBTDhG3PHZVkGv99tHp3sEC8BKUu8 2016-07-22T09:18:00Z change=1 # addr=mttBmwdL5GLCmhS8wRCeSKk8oYLnoPp16p hdkeypath: m/0'/0'/3'
    13cMgur3MsbhLRxNgSE8kVcH6A2reDvMkGuHHTYUYVUvssXqBdjjHr 2016-07-22T09:18:00Z change=1 # addr=muJfnEN2NTeBxxF8Gof93MqfBiAbyfFEha hdkeypath: m/0'/0'/5'
    14cVrDVdP5JMn6EgAZfSGC95KE347WmAGZfdXMXde2rS2qsXxbpjmk 2016-07-22T09:18:00Z oldhdmaster=1 # addr=mvvBZ1Md38ZNgbBrz5ZL7cCFykiRwNxaee hdkeypath: m
    15cPKq9W9LonJLK7VpZT4488x9JbSmwt4xsSnMEenEfqdggi8JDrns 2016-07-22T09:18:00Z change=1 # addr=mxy6ME2nxAw2PXyfqqGxjBbccCbYnfxbN1 hdkeypath: m/0'/0'/6'
    16cSjjNu2Z1LFF91siFFCJdqym1K7HBuV9oX7u9M3BBaheUhL9j8ti 2016-07-22T09:18:00Z change=1 # addr=n4PG8RF16Z16aiWdGxjiTAKLh5vhW28Z7W hdkeypath: m/0'/0'/8'
    17cTceAiNuF3P3uy1zq8mCTw5ExfgkZC9epQDQFh81JtgFBDom8Pi2 2016-07-22T09:18:01Z change=1 # addr=mohpfbNfUgwxBY5Z7PWsLUWVZfataTCLKb hdkeypath: m/0'/0'/10'
    18cV2oTqiG128zWUMsyakqnt9vS1o9xo6ES5Vy7aWhNtBhdNFzVku8 2016-07-22T09:18:01Z change=1 # addr=n17XEKYwc1pFY2m7BKXamVdX7jDmBuyYxk hdkeypath: m/0'/0'/9'
    19cRfMrm6v3D5Ypb3ozJi3s5sf2sjVv5a8wjm3oF3JeMZorj6ujkvR 2016-07-22T09:25:29Z reserve=1 # addr=mgEYLY5vXDG8sNoF4oiHsuTsEfgbc9DCrW hdkeypath: m/0'/0'/5'
    20cTADRxhPRsnonzqvaK1pE8zFC44roVDTRmGqULk2j1BecHpD55Nk 2016-07-22T09:25:29Z reserve=1 # addr=mgJn4zqYqGrbRXkcyVg4bL4PVtEVtMvNw5 hdkeypath: m/0'/0'/9'
    21cUHRMwwVmhX38JCNqtyM7U71ZDdA1xjEQKSJ63BUsSpGa11H2zHH 2016-07-22T09:25:29Z reserve=1 # addr=mmz1jW6Rnc7dMVaavoimHraWfw9RawSD6G hdkeypath: m/0'/0'/0'
    22cQBYTxbHTJETGYdQuFEq63rR2ZUpNXCUVPpRHxqq3xJSGE3Ny9S1 2016-07-22T09:25:29Z reserve=1 # addr=mpYTX3bj6aPJAj2RrvNJzn6RfS6o4HMpfA hdkeypath: m/0'/0'/1'
    23cRHKQMthnHt8Zv16zQJJSHMrF8SeNHNFBZ93AHASfvakjoh1XumW 2016-07-22T09:25:29Z reserve=1 # addr=mq3JTBit3C5GVd83gHZZ6655kZY4pd2rdR hdkeypath: m/0'/0'/7'
    24cTL35ENNE7FvtHzUZRicG5C2hHaRQaxzhHtVzgsm2y6WLJkNo5Ls 2016-07-22T09:25:29Z reserve=1 # addr=mtZwQY6FKZkdjy25djWUNsuKa7L25AnQDg hdkeypath: m/0'/0'/2'
    25cS39uGTtoePbuY9fmPKHQ3k87Y2XEd2StsL5KBgcLXMBYb6qabok 2016-07-22T09:25:29Z hdmaster=1 # addr=mxC8X9VJSCp6Zniu4dd4iRBzkJhJf68YoM hdkeypath: m
    26cR5bkb8zmVRDrq493MahwnpNu8U8zvqZ6UjMFJ3Uc9sJN9ea1tzT 2016-07-22T09:25:29Z reserve=1 # addr=mzECSuZ3r9GVLhQeGfkyEVjGfzfMFdnwyn hdkeypath: m/0'/0'/8'
    27cMcQjv1qGcb6F68bR4GzmSfTTuBPp2hNUGAsAicAQa8z6KX7d5eu 2016-07-22T09:25:29Z reserve=1 # addr=mzhbwXYTtnhkGpFEnZoNG6SV9Wih2rAwcG hdkeypath: m/0'/0'/4'
    28cPPBqv9UQKSTofYez72eE4HAa6aLY9e17ycae96PmDG3hBnTjKVh 2016-07-22T09:25:29Z reserve=1 # addr=n1KXTTZAXLha5JruXy3RnA2y4tk63nsztU hdkeypath: m/0'/0'/3'
    29cQ3sDHnWD3UTV6BnNecZ3d1r3Z2ULMG2HjTgpoEMAYd2m1jTf7sK 2016-07-22T09:25:29Z reserve=1 # addr=n2jujGbNUKtTe8wHDvDDtwm7dLtasvm6xj hdkeypath: m/0'/0'/6'
    30cSbkZ7ff2HaKephpeNFMfBVsLftq7Zmu3A4F6rwnPoz4iBcGkNwo 2016-07-22T09:25:55Z reserve=1 # addr=mpbx56wFoHfq5voMrQz6J6SpjJrP7KXRVi hdkeypath: m/0'/0'/10'
    31
    32# End of dump
    

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

  30. in src/wallet/rpcdump.cpp: in aa5487b45c outdated
    628+            file << strprintf("%s %s ", CBitcoinSecret(key).ToString(), strTime);
    629             if (pwalletMain->mapAddressBook.count(keyid)) {
    630-                file << strprintf("%s %s label=%s # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, EncodeDumpString(pwalletMain->mapAddressBook[keyid].name), strAddr);
    631+                file << strprintf("label=%s", EncodeDumpString(pwalletMain->mapAddressBook[keyid].name));
    632+            } else if (keyid == masterKeyID) {
    633+                file << "hdmaster=1";
    


    laanwj commented at 9:05 am on July 26, 2016:
    I like this code simplification
  31. jonasschnelli force-pushed on Jul 27, 2016
  32. jonasschnelli commented at 1:05 pm on July 27, 2016: contributor
    Force push changed two typo/text-only changes s/keypath:/keypath= and s/oldhdmaster/inactivehdmaster.
  33. jonasschnelli force-pushed on Jul 27, 2016
  34. [Wallet] add HD xpriv to dumpwallet 77c912d21c
  35. jonasschnelli force-pushed on Jul 27, 2016
  36. laanwj merged this on Jul 27, 2016
  37. laanwj closed this on Jul 27, 2016

  38. laanwj referenced this in commit 4d4970fe53 on Jul 27, 2016
  39. laanwj commented at 1:32 pm on July 27, 2016: member
    Tested ACK 77c912d
  40. laanwj referenced this in commit 18b8ee1cd1 on Jul 27, 2016
  41. MarcoFalke removed the label Needs backport on Jul 31, 2016
  42. MarcoFalke commented at 2:18 pm on July 31, 2016: member
    Removed “Needs backport”
  43. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-19 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me