- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.1k
Replace CScriptID and CKeyID in CTxDestination with dedicated types #15452
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
Conversation
| The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones: 
 If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. | 
07fb599    to
    3330398      
    Compare
  
    | Concept ACK. I believe @ryanofsky suggested something like this before. | 
| Not sure how to read appveyor error tbh | 
| The appveyor sync failure was fixed earlier this week | 
| Concept ACK. Maybe enumerate the new types in the PR description? 
 | 
| { | ||
| PKHash() : uint160() {} | ||
| explicit PKHash(const uint160& hash) : uint160(hash) {} | ||
| explicit PKHash(const CPubKey& pubkey); | 
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.
Inline definition might be more clear but I don't want to upset any strong c++ preferences out there.
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.
It's a mixed bag here(definition for other constructors are in .cpp), I'll leave as-is unless someone else chimes in
| utACK 3330398 | 
3330398    to
    61ccb14      
    Compare
  
    | rebased | 
61ccb14    to
    5148213      
    Compare
  
    | rebased and added description of new destination types in OP @Sjors | 
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.
Conditional utACK 5148213 if fixes are added for travis failures. I'm guessing this will just require rebasing and adding some more CKeyID/CScriptID replacements.
This change was also suggested a while ago in: #11403 (comment) and I think it could be simplified a little by taking the other suggestion in that comment and making ScriptHash inherit from CScriptID and PKHash inherit from CKeyID. This would avoid the need to add explicit conversions several places in this PR. I think it's important for conversions from CScriptID to ScriptHash and CKeyID to PKHash to be explicit, but it seems fine for conversions in the opposite direction to be implicit.
        
          
                src/wallet/wallet.cpp
              
                Outdated
          
        
      | for (const auto& entry : mapKeyMetadata) { | ||
| if (entry.second.nCreateTime) { | ||
| mapKeyBirth[entry.first] = entry.second.nCreateTime; | ||
| mapKeyBirth[PKHash(entry.first)] = entry.second.nCreateTime; | 
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.
This change and the 2 changes below will work but don't really make sense logically. Would suggest reverting these and just changing the map key type to:
boost::variant<CKeyID, CScriptID>or maybe
CKeyIDif you wanted to drop the "TODO: include scripts in GetKeyBirthTimes() output instead of separate" comment.
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.
done
5148213    to
    ddc21f2      
    Compare
  
    | fixed a single dangling test case that was expecting a  | 
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.
utACK ddc21f2. Changes since last review are fixing test case and switching GetKeyBirthTimes away from CTxDestination.
| tACK ddc21f2. Compiled, opened a wallet and ran test suite and bench on macOS 10.14.4. Not sure what else to test here. | 
ddc21f2    to
    3488d45      
    Compare
  
    3488d45    to
    78e407a      
    Compare
  
    | all comments addressed | 
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.
utACK 78e407a. Only changes are removing extra CScriptID()s and fixing the test case.
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.
utACK 78e407a
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.
utACK 78e407a
By removal of the // TODO: include scripts in GetKeyBirthTimes() output instead of separate comment, I assume you think that shouldn't be done, rather than because you implemented it.
…icated types 78e407a GetKeyBirthTimes should return key ids, not destinations (Gregory Sanders) 70946e7 Replace CScriptID and CKeyID in CTxDestination with dedicated types (Gregory Sanders) Pull request description: The current usage seems to be an overloading of meanings. `CScriptID` is used in the wallet as a lookup key, as well as a destination, and `CKeyID` likewise. Instead, have all destinations be dedicated types. New types: `CScriptID`->`ScriptHash` `CKeyID`->`PKHash` ACKs for commit 78e407: ryanofsky: utACK 78e407a. Only changes are removing extra CScriptID()s and fixing the test case. Sjors: utACK 78e407a meshcollider: utACK 78e407a Tree-SHA512: 437f59fc3afb83a40540da3351507aef5aed44e3a7f15b01ddad6226854edeee762ff0b0ef336fe3654c4cd99a205cef175211de8b639abe1130c8a6313337b9
| @meshcollider payoff was very low, and descriptor wallets would have changed whatever someone was going to do | 
…ith dedicated types 78e407a GetKeyBirthTimes should return key ids, not destinations (Gregory Sanders) 70946e7 Replace CScriptID and CKeyID in CTxDestination with dedicated types (Gregory Sanders) Pull request description: The current usage seems to be an overloading of meanings. `CScriptID` is used in the wallet as a lookup key, as well as a destination, and `CKeyID` likewise. Instead, have all destinations be dedicated types. New types: `CScriptID`->`ScriptHash` `CKeyID`->`PKHash` ACKs for commit 78e407: ryanofsky: utACK 78e407a. Only changes are removing extra CScriptID()s and fixing the test case. Sjors: utACK 78e407a meshcollider: utACK bitcoin@78e407a Tree-SHA512: 437f59fc3afb83a40540da3351507aef5aed44e3a7f15b01ddad6226854edeee762ff0b0ef336fe3654c4cd99a205cef175211de8b639abe1130c8a6313337b9
Update chainActive to ::ChainActive() in Namecoin code. Changed the Namecoin code for the upstream refactoring of CKeyID and CScriptID in the wallet (bitcoin/bitcoin#15452). Explicitly serialise block without witness, so that we do not have to activate segwit at height 432 first in name_multiupdate.py.
Update chainActive to ::ChainActive() in Xaya code. Changed the Xaya code (esp. the modified verifymessage) for the upstream refactoring of CKeyID and CScriptID in the wallet (bitcoin/bitcoin#15452). Explicitly serialise block without witness, so that we do not have to activate segwit at height 432 first in xaya_gameblocks.py.
…dedicated types Summary: bitcoin/bitcoin@70946e7 --- Depends on D6402 Partial backport of Core [[bitcoin/bitcoin#15452 | PR15452]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6403
…ions Summary: bitcoin/bitcoin@78e407a --- Depends on D6403 Concludes backport of Core [[bitcoin/bitcoin#15452 | PR15452]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6404
…ith dedicated types 78e407a GetKeyBirthTimes should return key ids, not destinations (Gregory Sanders) 70946e7 Replace CScriptID and CKeyID in CTxDestination with dedicated types (Gregory Sanders) Pull request description: The current usage seems to be an overloading of meanings. `CScriptID` is used in the wallet as a lookup key, as well as a destination, and `CKeyID` likewise. Instead, have all destinations be dedicated types. New types: `CScriptID`->`ScriptHash` `CKeyID`->`PKHash` ACKs for commit 78e407: ryanofsky: utACK 78e407a. Only changes are removing extra CScriptID()s and fixing the test case. Sjors: utACK 78e407a meshcollider: utACK bitcoin@78e407a Tree-SHA512: 437f59fc3afb83a40540da3351507aef5aed44e3a7f15b01ddad6226854edeee762ff0b0ef336fe3654c4cd99a205cef175211de8b639abe1130c8a6313337b9
The current usage seems to be an overloading of meanings.
CScriptIDis used in the wallet as a lookup key, as well as a destination, andCKeyIDlikewise. Instead, have all destinations be dedicated types.New types:
CScriptID->ScriptHashCKeyID->PKHash