Skip to content

Conversation

jonasschnelli
Copy link
Contributor

Most simplest HD feature.

  • Use BIP32/hd key derivation by default for new wallets (m/0'/0')
  • Only private key derivation is supported (no pubkey-only-wallets for now)
  • No on the fly generation of private keys (keypools get still refilled, all derived private keys are touching the database, but deterministic)
  • Internal support for multiple hd keychains (potential allows simple key rotation feature)
  • Supports encrypted wallets
  • RPC- and unit-tests included
  • Currently now way to create a hd keychain for existing wallets (upcoming feature if/once this got merged)

ment as a starting point, have concrete plans to extend this, but don't want to overload this PR

getnewaddress "" true (last parameter true = "show details") returns an object if the new address was hd derived:

{
  "address": "n1EU7TC4YqVYGQYy5eav1APHhS3z3Jrgf4",
  "keypath": "m/0'/230'"
}

(same for getaddressesbyaccount)

@jonasschnelli jonasschnelli added this to the 0.13.0 milestone Jan 2, 2016
@jonasschnelli
Copy link
Contributor Author

The main benefits of this PR:

  • A wallet.dat backup, regardless of it's age, can be used to recover all private keys.
  • Basic groundwork for detaching the private-keys from the wallet (allow signing over hardware wallets, etc.)

print "encrypt wallet"
self.nodes[0].encryptwallet("test")
bitcoind_processes[0].wait()
del bitcoind_processes[0]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Is there a compelling reason to do 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.

Encrypting the wallet does stop the process,... i think this is required.

Copy link

Choose a reason for hiding this comment

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

Riky

Copy link

Choose a reason for hiding this comment

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

Riky

@jgarzik
Copy link
Contributor

jgarzik commented Jan 2, 2016

concept ACK

bool WriteHDCryptedMasterSeed(const uint256& hash, const std::vector<unsigned char>& vchCryptedSecret);
bool EraseHDMasterSeed(const uint256& hash);
bool WriteHDChain(const CHDChain& chain);
bool WriteHDAchiveChain(const uint256& hash);
Copy link
Member

Choose a reason for hiding this comment

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

Typo? Achive -> Active?

@luke-jr
Copy link
Member

luke-jr commented Jan 15, 2016

Note to test: If encrypting wallet fails for any reason at any late stage, the wallet should retain all unencrypted data.

EncryptSeeds(vMasterKeyIn);

std::vector<HDChainID> chainIds;
GetAvailableChainIDs(chainIds);
Copy link
Member

Choose a reason for hiding this comment

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

Return value is ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link

Choose a reason for hiding this comment

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

Oky

Copy link

Choose a reason for hiding this comment

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

Oky

Copy link

Choose a reason for hiding this comment

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

Oky

Copy link

Choose a reason for hiding this comment

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

Oky

Copy link

Choose a reason for hiding this comment

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

Oky

Copy link

Choose a reason for hiding this comment

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

Oky

@pointbiz
Copy link

Concept ACK

@@ -395,6 +395,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"),
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)));
strUsage += HelpMessageOpt("-usehd", _("Use hierarchical deterministic key derivation (HD wallets) (default: true)"));
strUsage += HelpMessageOpt("-hdseed", _("Use the given 256bit (64 char hex) as HD master seed (default: <generate random seed>)"));
Copy link
Member

Choose a reason for hiding this comment

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

Probably should make this clear it only happens upon first run of the wallet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably should make this clear it only happens upon first run of the wallet.

I agree, -hdseed as startup parameter is somehow not ideal. Not seeding the wallet at first start, would require an additional rpc command (something generatehdwallet, seedwallet, etc.).

Or an additional "bitcoin-wallet" tool that could allow generating and manipulating wallet.dat files.

But because I fear lack of reviewer, I don't want to make this PR more complex for now.

@jonasschnelli
Copy link
Contributor Author

Rebased and fixed reported nits.

return false;

Erase(std::make_pair(std::string("hdmasterseed"), hash));
Erase(std::make_pair(std::string("hdmasterseed"), hash));
Copy link
Member

Choose a reason for hiding this comment

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

double deletion?

@jonasschnelli
Copy link
Contributor Author

Rebased and fixed some nits.

@instagibbs
Copy link
Member

Concept ACK.

I think on-ramping users to this safely/transparently will be the most difficult part.

Warning users that the flag they've set can't be properly used until a new wallet is created(or some migration happens) is a must imo. There needs to be a tool/process to help with that migration, most likely with a backup/cloning step.

@jonasschnelli
Copy link
Contributor Author

Closing in favor of #8035.
Some parts of this PR could be used to extend HD functionality if and once #8035 has been merged.

@maflcko
Copy link
Member

maflcko commented May 15, 2016

@jonasschnelli Is it ok to delete the 2016/01/hdsimple branch from https://github.com/bitcoin/bitcoin/branches now?

@jonasschnelli jonasschnelli deleted the 2016/01/hdsimple branch May 16, 2016 13:44
@jonasschnelli
Copy link
Contributor Author

I deleted the branch. There is still some useful stuff in this branch (thinks like child key derivation by keypath-string) that could be re-used later.

@jonasschnelli jonasschnelli removed this from the 0.13.0 milestone May 16, 2016
@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.

7 participants