Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HD wallet #1405

Merged
merged 31 commits into from
May 29, 2017
Merged

HD wallet #1405

merged 31 commits into from
May 29, 2017

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Mar 19, 2017

HD wallet for Dash Core 0.12.2.x+

  • minimal BIP32 changes backported from Bitcoin upstream;
  • BIP44 derivation scheme;
  • BIP39 mnemonic and mnemonic passphrase can be used to create HD wallet (optional, using random mnemonic and mnemonic passphrase if mnemonic was not specified by the user explicitly);
  • only seed is stored, all keys are derived on the fly (seed is stored encrypted if wallet is locked).

Note: mnemonic is not stored and can't be recovered.

@UdjinM6 UdjinM6 force-pushed the hdwallet branch 2 times, most recently from 4434d5b to d2eed76 Compare March 20, 2017 01:01
@UdjinM6 UdjinM6 added this to the 12.2 milestone Mar 20, 2017
@taw00
Copy link

taw00 commented Mar 20, 2017

Whoa. You can do this in core?

@UdjinM6 UdjinM6 changed the title HD wallet [WIP] HD wallet Mar 20, 2017
@SCDeveloper
Copy link

Will mean everyone needs to export and reimport their privkeys to the new wallet structure. But I can confirm this works as it is in https://github.com/duality-solutions/dynamic

@akijuh
Copy link

akijuh commented Mar 20, 2017

What that HD stands for?

@UdjinM6
Copy link
Author

UdjinM6 commented Mar 20, 2017

@SCDeveloper Yep, there will be a need in some migration for old users (optional though). Another option would be to create a completely new wallet and then simply send all funds from an old wallet to a new one. This way ALL keys will be recoverable. And yes, that repo was where I started from first and was able to compile wallet actually after resolving some conflicts. But I wasn't happy with way too many changes all over the place due to embedded refactoring, so had to backport upstream changes selectively instead. Anyway, thanks for the starting point :)

@akijuh Hierarchical Deterministic (HD) Wallets https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki

@schinzelh schinzelh changed the base branch from v0.12.1.x to v0.12.2.x March 22, 2017 19:18
@UdjinM6 UdjinM6 force-pushed the hdwallet branch 8 times, most recently from 70d0e7b to 4314a50 Compare March 31, 2017 15:36
@UdjinM6 UdjinM6 force-pushed the hdwallet branch 6 times, most recently from 9577c4c to 4e830e7 Compare April 19, 2017 04:24
@UdjinM6 UdjinM6 changed the title [WIP] HD wallet HD wallet Apr 19, 2017
@UdjinM6
Copy link
Author

UdjinM6 commented Apr 19, 2017

This should be ready for review and testing now.

@UdjinM6
Copy link
Author

UdjinM6 commented Apr 26, 2017

Changes:

  • top up keypool on hd wallet encryption (fix tests);
  • backport, fix and slightly refactor bitcoin core 9294 and 10235 (hd chain split).

NOTE: This breaks compatibility with hd wallets created on previous commits. If you have such wallet, apply this patch locally and run it once:

diff --git a/src/hdchain.h b/src/hdchain.h
index 6cdc7c831..b0fee515b 100644
--- a/src/hdchain.h
+++ b/src/hdchain.h
@@ -29,7 +29,17 @@ public:
         READWRITE(vchSeed);
         READWRITE(id);
         READWRITE(nExternalChainCounter);
-        READWRITE(nInternalChainCounter);
+        if (ser_action.ForRead()) {
+            try {
+                READWRITE(nInternalChainCounter);
+            }
+            catch (std::ios_base::failure&) {
+                nInternalChainCounter = 0;
+            }
+        }
+        else {
+            READWRITE(nInternalChainCounter);
+        }
     }
 
     bool SetNull();

@UdjinM6
Copy link
Author

UdjinM6 commented Apr 28, 2017

Wallet should now store mnemonic/mnemonicpassphrase.

NOTE: This is incompatible with previous hd wallets once again, run-once patch is should be similar to the one above but it's not(?).

EDIT: err... smth wasn't quite right with that commit, so I had to force push, sorry :/
EDIT2: and again... also patch for wallets on old commit doesn't seem to work for some reason... investigating..
EDIT3: ok, so it's smth with vector serialization I guess. Don't want to dig too much into it, so let's just accept that it's incompatible 😇 dump hdseed using old build and start new wallet using new build and -hdseed if you need one (might also require to run keypoolrefill to increase number of known addresses to the size of the old wallet and rescan).

@UdjinM6
Copy link
Author

UdjinM6 commented May 28, 2017

Rebased to resolve merge conflict after #1473 (around this line https://github.com/dashpay/dash/pull/1405/files#diff-8bdec64a6a2adb83b9696e5ca6d5522bR1282)

@UdjinM6 UdjinM6 merged commit 27f3218 into dashpay:v0.12.2.x May 29, 2017
spencerlievens added a commit to spencerlievens/dash that referenced this pull request May 30, 2017
UdjinM6 pushed a commit that referenced this pull request May 31, 2017
@UdjinM6 UdjinM6 deleted the hdwallet branch January 24, 2019 21:52
@UdjinM6 UdjinM6 mentioned this pull request Jun 27, 2021
@@ -90,6 +90,7 @@
testScripts = [
'bip68-112-113-p2p.py',
'wallet.py',
'wallet-hd.py',
Copy link

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants