Skip to content

add mnemonicinfo, importmasterkey#37

Merged
scravy merged 6 commits into
masterfrom
mnemonic-rpcs
Aug 27, 2018
Merged

add mnemonicinfo, importmasterkey#37
scravy merged 6 commits into
masterfrom
mnemonic-rpcs

Conversation

@scravy
Copy link
Copy Markdown
Member

@scravy scravy commented Aug 24, 2018

This is the importmasterkey and mnemonicinfo RPCs. Tests will follow shortly, do not merge yet ;-) but you can start reviewing.

The unit-e importmasterkey is named extkeyimportmaster in particl (but I chose not to refer to it as an ext key; the extended keys are technically the the derived keys in the HD structure which also reflect the path (m' / 44 / ...).

mnemonicinfo is like a dry run and I am using it to test the mnemonic functionality for conformance with BIP32 and BIP39.

@scravy scravy force-pushed the mnemonic-rpcs branch 12 times, most recently from cce4a8f to 78b9924 Compare August 24, 2018 14:00
@scravy
Copy link
Copy Markdown
Member Author

scravy commented Aug 24, 2018

This is done and up for review now! Tests are complete.

I was facing the following issue: I had put lib uninorm (for utf8/unicode) and the mnemonic.cpp into libunite_common (src/Makefile.am). This was fine on macOS but failed to link in linux. For now I moved everything into libunite_wallet (which after all is probably even better as mnemonics strictly relate to the wallet anyhow).

Another thing which bugs me: Although we're pretty sure that node.start and node.stop in the functional tests wait for the node to actually have stopped and actually have started the test sometimes fails and to me it looks like as if the node is not yet properly handling connections :-( (talking about wallet_importmasterkey test).

@scravy
Copy link
Copy Markdown
Member Author

scravy commented Aug 24, 2018

I should note the following thing: I am trying to use as much bitcoin functionality as possible. Bitcoins CWallet already has methods to set the master key but I do suspect it was not their intention for them to be used /after/ a wallet has been created already. When the node comes up it automatically creates a wallet. Upon creation the wallet is preseeded with a list of reserve keys. It is thus tricky to distinguish a newly created wallet from a wallet which is already in use. Nevertheless you could import a new masterkey into an already used wallet, which is why setting a new masterkey will automatically backup your existing wallet (although in most cases this will be an empty wallet).

I'll create a ticket for this. I could imagine that we might want to detect a newly created wallet and just prohibit overwriting the masterkey for a wallet that is already in use.

edit: Issue: #40

@scravy scravy force-pushed the mnemonic-rpcs branch 4 times, most recently from a70e6b0 to f33d3d5 Compare August 24, 2018 20:48
Comment thread src/esperanza/walletextension.h Outdated
int m_deepestTxnDepth = 0; // for stake mining

int m_stakeLimitHeight = 0; // for regtest, don't stake above nStakeLimitHeight
int m_stakeLimitHeight =
Copy link
Copy Markdown
Member

@Gnappuraz Gnappuraz Aug 27, 2018

Choose a reason for hiding this comment

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

maybe we can put the comment in the line above and thus prevent the new line with a 0;

Comment thread src/wallet/rpcmnemonic.cpp Outdated
@@ -0,0 +1,163 @@
// Copyright (c) 2010 Satoshi Nakamoto
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am confused, didn't we take this from particl? cause it seems here it was taken from bitcoin.

Copy link
Copy Markdown
Member Author

@scravy scravy Aug 27, 2018

Choose a reason for hiding this comment

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

Copy'n'paste abfuck from my side... I merely duplicated rpcwallet and got rid of it's guts. Changing!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In addition: I'd like to point out that the code in rpcmnemonic we did not take form particl at all, it sets a master key in the existing CWallet, doing a lot less voodoo then the CHDWallet form particl.

Comment thread src/wallet/rpcmnemonic.cpp Outdated
LOCK(wallet->cs_wallet);
const std::string walletFileName = wallet->GetName();
std::string mnemonic = "";
if (request.params.size() > 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This check seems to be redundant as the size of the request.params is checked at the beginning of the function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1,67 @@
#!/usr/bin/env python3
# Copyright (c) 2016-2017 The Bitcoin Core developers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same copy paste license?

Comment thread test/functional/wallet_mnemonicinfo.py Outdated
@@ -0,0 +1,185 @@
#!/usr/bin/env python3
# Copyright (c) 2016-2017 The Bitcoin Core developers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These tests are our very own.

@scravy
Copy link
Copy Markdown
Member Author

scravy commented Aug 27, 2018

@Nizametdinov about extkeygenesisimport and extkeyimportmaster.

The distinction between these commands was not ported. All keys are derived along a chain, i.e. m / 0'/1' (this means masternode (it's always m), default account (account 0, purpose field according to BIP43), chain (1 is internal).

The bitcoin codebase we're forking form already has support for these internal/external chain splits (FEATURE_HD_SPLIT). In particl they just opted for a ridiculously high number for the internal chain (444444) and my guess would be that they created the adresses for the genesis transactions (in the genesis blocks) in that chain, thus need to keep it. Anyways, feature-wise we do have this split and we just need to have an index for our coin :-)

For the desktop application: use importmasterkey with a seed.

@scravy
Copy link
Copy Markdown
Member Author

scravy commented Aug 27, 2018

@Gnappuraz I checked the copyright headers one by one again. All the copyright for ShadowCoin/BlackCoin were correct. I added the headers for particl copyright as it was indeed missing from most files in esperanza/.

Our own copyright we add before we release with a script. The script already exists and does not add if the copyright notice is already there and does add if it's not there yet.

@scravy scravy merged commit c395aee into master Aug 27, 2018
@scravy scravy deleted the mnemonic-rpcs branch August 27, 2018 10:42
@scravy scravy added this to the Implement BIP39 (seed wallet from mnemonics) milestone Sep 4, 2018
@scravy scravy added the wallet label Sep 4, 2018
@scravy scravy self-assigned this Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants