forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 717
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
[Wallet] HD Wallet - v2. #1327
Merged
furszy
merged 51 commits into
PIVX-Project:master
from
furszy:2020_hd_wallet_rebased_7_feb
Mar 11, 2020
Merged
[Wallet] HD Wallet - v2. #1327
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
4198824
[Crypter] vMasterKey protected to be able to get it in the child clas…
furszy 5276621
[Refactor] CExtKey, SetSeed changed to SetMaster following upstream's…
furszy 922a831
KeyOriginInfo struct created.
furszy c731f26
memory.h file created, upstream backport.
furszy 4b33cef
[Backport] Simple GetScriptForRawPubKey coming from upstream.
furszy ffb719f
CHDChain class created.
furszy 155a8d9
HD Wallet connected to the wallet.
furszy 698bd64
[Backport] key_io.h/cpp
furszy 99f6071
test framework, at least 10 keys in the keypool to be able to generat…
furszy beb5fcb
Remove DecodeBase58Check warning
furszy 80a8407
BIP44 derivation path + HD wallet functional tests passing.
furszy c791b7a
[RPC] getaddressinfo implemented.
furszy 3e79435
[Wallet] SPKM single account.
furszy 37d89f6
[RPC] sethdseed implemented.
furszy ac87b5c
[Wallet] HD chain scan + mark unused addresses flow implemented.
furszy 198e70e
key_io DecodeSecret backported.
furszy 23aeeb5
[Wallet] Use internal key for tx change.
furszy bcc8796
[Tests] Backport HD wallet functional test.
furszy eebb3fc
[Test] wallet_keypool_topup fix.
furszy ac16d22
[Test] Test runner, wallet_hd.py added.
furszy 2864d82
rpc: Prevent `dumpwallet` from overwriting files.
furszy 84a8403
[RPC] `dumpwallet` exporting hd key path.
furszy 70ba39b
[RPC] `importwallet` hdseed key type added.
furszy 5fb1b7f
[Build] missing HD new files.
furszy 8377ef4
[Cleanup] Unifying internal/external chain counter increment.
furszy e0621f4
KeyIO namespace.
furszy 811fb29
linux link issue fix
furszy 9a7d0fd
[Wallet] HD Wallet, staking chain counter.
furszy 403ff69
[SPKM] Staking addresses derivation path.
furszy 7a8a1fd
[Unittest] Remove rpc_wallet_tests.cpp.
furszy 4a79a08
[Wallet] GetKeyFromPool using the new keypool type instead of the int…
furszy 0f87145
[Cleanup] Removing unused NewKeyPool from the wallet class.
furszy a7ea0b0
keyOrigin size validation fix.
furszy deef0b3
[Wallet] Default keypool size decreased to 100.
furszy 2580cab
[Wallet] CanSupportFeature(FEATURE_HD_SPLIT) moved to IsHDEnabled.
furszy d0325eb
[RPC] getwalletinfo keypoolsize_hd_staking count added.
furszy 25ee29b
Cleanup: dumpwallet never empty str check removed + duplicated line c…
furszy cc1a60b
[Wallet] Upgrade to HD flow with -upgradewallet flag.
furszy 805ed41
[RPC] sethdseed help text corrections.
furszy 025c02a
[Cleanup] Removing not used methods.
furszy 69e57c2
[Wallet] throw error if staking key was misclassified.
furszy 5b94a2f
[Wallet] GetOldestKeyPoolTime implemented inside the SPKM.
furszy 051a4c5
[Bug] Return key to the proper keypool.
furszy 1f426ac
[Wallet] Not used wallet feature versions commented (plus init bug fix).
furszy cc2f0eb
[Wallet] Bugfix, CReservedKey internal flag initialized.
furszy 5748d39
[Test] HD wallet upgrade functional test.
furszy 7f7ffae
[Wallet] Upgrade to HD from a locked wallet error notification + furt…
furszy 2072ebc
[Tests] Replace invalid `/` separator for OS specific separator.
furszy 1cccdea
[Doc] HD Wallet release notes.
furszy a40cc8a
[Lint] Do not check for trailing spaces in release-notes.md file.
furszy 818dac7
[RPC] Missing sethdseed.
furszy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2014-2019 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include "key_io.h" | ||
|
||
#include "base58.h" | ||
#include <boost/variant/apply_visitor.hpp> | ||
#include <boost/variant/static_visitor.hpp> | ||
|
||
#include <assert.h> | ||
#include <string.h> | ||
#include <algorithm> | ||
|
||
namespace KeyIO { | ||
|
||
CKey DecodeSecret(const std::string &str) { | ||
CKey key; | ||
std::vector<unsigned char> data; | ||
if (DecodeBase58Check(str, data)) { | ||
const std::vector<unsigned char> &privkey_prefix = Params().Base58Prefix(CChainParams::SECRET_KEY); | ||
if ((data.size() == 32 + privkey_prefix.size() || | ||
(data.size() == 33 + privkey_prefix.size() && data.back() == 1)) && | ||
std::equal(privkey_prefix.begin(), privkey_prefix.end(), data.begin())) { | ||
bool compressed = data.size() == 33 + privkey_prefix.size(); | ||
key.Set(data.begin() + privkey_prefix.size(), data.begin() + privkey_prefix.size() + 32, compressed); | ||
} | ||
} | ||
if (!data.empty()) { | ||
memory_cleanse(data.data(), data.size()); | ||
} | ||
return key; | ||
} | ||
|
||
std::string EncodeSecret(const CKey &key) { | ||
assert(key.IsValid()); | ||
std::vector<unsigned char> data = Params().Base58Prefix(CChainParams::SECRET_KEY); | ||
data.insert(data.end(), key.begin(), key.end()); | ||
if (key.IsCompressed()) { | ||
data.push_back(1); | ||
} | ||
std::string ret = EncodeBase58Check(data); | ||
memory_cleanse(data.data(), data.size()); | ||
return ret; | ||
} | ||
|
||
CExtKey DecodeExtKey(const std::string &str) { | ||
CExtKey key; | ||
std::vector<unsigned char> data; | ||
if (DecodeBase58Check(str, data)) { | ||
const std::vector<unsigned char> &prefix = Params().Base58Prefix(CChainParams::EXT_SECRET_KEY); | ||
if (data.size() == BIP32_EXTKEY_SIZE + prefix.size() && | ||
std::equal(prefix.begin(), prefix.end(), data.begin())) { | ||
key.Decode(data.data() + prefix.size()); | ||
} | ||
} | ||
return key; | ||
} | ||
|
||
std::string EncodeExtKey(const CExtKey &key) { | ||
std::vector<unsigned char> data = Params().Base58Prefix(CChainParams::EXT_SECRET_KEY); | ||
size_t size = data.size(); | ||
data.resize(size + BIP32_EXTKEY_SIZE); | ||
key.Encode(data.data() + size); | ||
std::string ret = EncodeBase58Check(data); | ||
memory_cleanse(data.data(), data.size()); | ||
return ret; | ||
} | ||
|
||
}// namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2009-2010 Satoshi Nakamoto | ||
// Copyright (c) 2009-2018 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef PIVX_KEY_IO_H | ||
#define PIVX_KEY_IO_H | ||
|
||
#include "chainparams.h" | ||
#include "key.h" | ||
#include "pubkey.h" | ||
#include "script/standard.h" | ||
|
||
#include <string> | ||
|
||
namespace KeyIO { | ||
|
||
CKey DecodeSecret(const std::string &str); | ||
|
||
std::string EncodeSecret(const CKey &key); | ||
|
||
CExtKey DecodeExtKey(const std::string &str); | ||
|
||
std::string EncodeExtKey(const CExtKey &extkey); | ||
|
||
} | ||
|
||
#endif //PIVX_KEY_IO_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can probably remove it from the overloaded DecodeBase58Check too.