Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
add key generation type #5916
Conversation
laanwj
added
the
Wallet
label
Mar 18, 2015
|
Remembering where a key comes from, yeah, why not. |
|
"generationtype" may not be the best name though; we also have "generated" for wallet transactions that shows whether the coins were mined. |
|
What about using |
|
key_generation_type then, we don't tend to use lowerCamelCase in RPC |
|
Right. |
|
Hm, one thought: Would the resulting wallet still be backwards compatible? |
|
Good point. I'll have to check/test the backward compatibility. I'm not sure what happens to the deserialization when there are one additional byte at the end. |
|
It's backward and forward compatible. The 1byte flag added at the end of the CKeyMetadata serialization stream will be ignored when running (old) master-branch. Using a "new" wallet on a "old" bitcoind will still keep the key generation data because Metadata is somehow immutable (will only be created/changes when a key gets generated). |
|
SGTM, utACK |
luke-jr
and 1 other
commented on an outdated diff
Jun 2, 2015
| @@ -42,9 +42,15 @@ enum DBErrors | ||
| class CKeyMetadata | ||
| { | ||
| public: | ||
| - static const int CURRENT_VERSION=1; | ||
| + static const int CURRENT_VERSION=2; | ||
| + static const uint8_t KEY_GENERATION_TYPE_UNKNOWN = 0x0001; | ||
| + static const uint8_t KEY_GENERATION_TYPE_IMPORTED = 0x0002; | ||
| + static const uint8_t KEY_GENERATION_TYPE_UNENC_WALLET = 0x0004; | ||
| + static const uint8_t KEY_GENERATION_TYPE_ENC_WALLET = 0x0008; |
|
|
|
I don't understand the term "generation" in this context. |
|
@luke-jr: "generation" was the best i could find. What would you prefer (maybe something like "Key generation environment" or "key generation security context")? |
|
"origin" perhaps. Also, this is lacking -upgradewallet logic. Even if old versions can handle it, third-party software might not. |
|
@luke-jr: right, it missed the |
|
Renamed to key origin and added wallet new wallet feature level 70000 |
luke-jr
commented on the diff
Jul 11, 2015
| @@ -1165,6 +1165,22 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) | ||
| fIsWatchonly = (*it).second.fIsWatchonly; | ||
| } | ||
| + // convert keyflags into a string | ||
| + CKeyID keyID; | ||
| + uint8_t keyFlags = 0; | ||
| + if (address.GetKeyID(keyID)) | ||
| + keyFlags = pwalletMain->mapKeyMetadata[keyID].keyFlags; | ||
| + | ||
| + std::string keyOrigin; | ||
| + if (keyFlags & CKeyMetadata::KEY_ORIGIN_UNKNOWN) |
luke-jr
Member
|
laanwj
and 1 other
commented on an outdated diff
Jul 21, 2015
| @@ -43,8 +43,16 @@ class CKeyMetadata | ||
| { | ||
| public: | ||
| static const int CURRENT_VERSION=1; | ||
| + static const int VERSION_SUPPORT_FLAGS=2; | ||
| + static const uint8_t KEY_ORIGIN_UNSET = 0x0000; | ||
| + static const uint8_t KEY_ORIGIN_UNKNOWN = 0x0001; | ||
| + static const uint8_t KEY_ORIGIN_IMPORTED = 0x0002; | ||
| + static const uint8_t KEY_ORIGIN_UNENC_WALLET = 0x0004; | ||
| + static const uint8_t KEY_ORIGIN_ENC_WALLET = 0x0008; |
laanwj
Owner
|
|
concept and code review ACK |
|
NACK on the bit flag, concept ACK on the general idea (tracking private key origin). |
|
@dcousens: i really like the idea of bit flags. IMO it is flexible, it could indicate different things like if a key was generated deterministic after bip32, etc. What are the downsides of the bit flags compared to a enum/int? |
|
@jonasschnelli I'd go so far to say that this could be user defined, as even a I don't really have a strong opinion either way on this, did you have a use case in mind? edit: in terms of #3314, a bit flag would make sense. |
|
I'd disagree with using a string type. It uses more memory and disk space (this is per key!), and is also worst for anything machine-understandable. |
jonasschnelli
added some commits
Mar 17, 2015
|
Rebased and replace the 8bit bitfield with a 32bit bitfield, also removed the "unset" keyflag. |
|
How will this top commit affect wallets with top-minus-one keyFlags? Bitcoin LJR includes the previous semantics, and it would be nice not to break loading such wallets. Maybe the wallet version can be bumped one to handle that case? |
|
@luke-jr: hmm.. yes. This would be required unless we want to break LJR 0.11 wallets. I have plans to update this PR, but it will take some weeks (this PR has low prio). If anyone likes to take this over: go ahead. |
jonasschnelli
referenced this pull request
Nov 7, 2015
Closed
Wallet: Store hash for encrypted keys #6943
pstratem
commented on src/wallet/rpcwallet.cpp in f1fef04
Dec 8, 2015
|
This doesn't look like it would handle multiple flags being set very well. |
|
Edit: or better, simply return a list of strings here. |
That's better. |
|
Concept ACK. |
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Jun 27, 2016
|
Do we really need a minVersionBump for this change? What about just detecting the change in the deserialization code? |
|
Well, we don't want to add data unless the user upgrades their wallet explicitly (or makes a new one) either. |
But this would make the upgraded wallet no longer work with older versions of bitcoin-core (<0.13 if we would merge this for 0.13) even with the fact that older version are capable of handling the changed/new CKeyMetadata format. This sounds inefficient to me. |
|
Won't old versions currently strip off the key origin data, even if they load the wallet itself okay? |
luke-jr
referenced this pull request
Aug 6, 2016
Open
Key origin metadata, with HD wallet support #8471
|
Closing in favor of #8471 |

jonasschnelli commentedMar 17, 2015
A encrypted wallet can still hold keys which where created when the wallet was unencrypted.
Could solve #3314.
This PR will add a 8bit-flags-int to the CKeyMetadata class.
listreceivedbyaddresswill report whether the key was generated within a encrypted wallet or if it was imported throughtimportprivkey.If this gets conceptual ACKs id like to extend this to the UI level.