-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Bug: IsUsedDestination shouldn't use key id as script id for ScriptHash #17924
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
All wallet tests should probably be run on all possible address types. See also #17199 (comment) |
It should ideally not be possible to footgun like this either by what I did. There's no situation I can think of that you'd want that conversion. |
pushed a very non-comprehensive commit that would have stopped me in my tracks if I thought "nesting" worked with I can keep poking at something more comprehensive, but I felt this was unobtrusive enough to be a non-controversial start. |
…esting computation
6fe6e0c
to
6dd59d2
Compare
Github-Pull: bitcoin#17924 Rebased-From: 4b8f1e9
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.
Code review ACK 6dd59d2
I like the fact this reduces the chance of a similar future mistake. It certainly isn't obvious at a glance.
struct ScriptHash : public uint160 | ||
{ | ||
ScriptHash() : uint160() {} | ||
// These don't do what you'd expect. | ||
// Use ScriptHash(GetScriptForDestination(...)) instead. | ||
explicit ScriptHash(const WitnessV0KeyHash& hash) = delete; |
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.
Why explicit
here?
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.
I was going back and forth on how to fix this and left that there :) I think this is a no-op
Github-Pull: bitcoin#17924 Rebased-From: 4b8f1e9
…esting computation Github-Pull: bitcoin#17924 Rebased-From: 6dd59d2
ACK 6dd59d2 |
ACK 6dd59d2 |
I guess this is less likely to happen, but should |
I think that's way less likely, and we might be able to do something smarter to be more generally robust as a followup? |
Maybe we should just make the inheritance private? |
I took a swing at it here: #17938 |
@Empact looks much more comprehensive. If people agree we can merge this, then rebase and work on reviewing something like that? |
In that case, why not go all the way, and use composition instead of inheritance. But let's do this fix for 0.19 then maybe do something more comprehensive for 0.20. |
…d for ScriptHash 6dd59d2 Don't allow implementers to think ScriptHash(Witness*()) results in nesting computation (Gregory Sanders) 4b8f1e9 IsUsedDestination shouldn't use key id as script id for ScriptHash (Gregory Sanders) Pull request description: Regression introduced in #17621 which causes p2sh-segwit addresses to be erroneously missed. Tests are only failing in 0.19 branch, likely because that release still uses p2sh-segwit addresses rather than bech32 by default. I'll devise a test case to catch this going forward. ACKs for top commit: achow101: ACK 6dd59d2 MarcoFalke: ACK 6dd59d2 meshcollider: Code review ACK 6dd59d2 Tree-SHA512: b3e0f320c97b8c1f814cc386840240cbde2761fee9711617b713d3f75a4a5dce2dff2df573d80873df42a1f4b74e816ab8552a573fa1d62c344997fbb6af9950
Being backported in 17792. |
cd67b1d Use correct C++11 header for std::swap() (Hennadii Stepanov) b8101fb Fix comparison function signature (Hennadii Stepanov) eac4907 Don't allow implementers to think ScriptHash(Witness*()) results in nesting computation (Gregory Sanders) e2c45d8 IsUsedDestination shouldn't use key id as script id for ScriptHash (Gregory Sanders) a5489c9 IsUsedDestination should count any known single-key address (Gregory Sanders) 88729d8 Fix issue with conflicted mempool tx in listsinceblock (Adam Jonas) eafcea7 gui: Fix duplicate wallet showing up (João Barbosa) 7e66d04 Drop signal CClientUIInterface::LoadWallet (Russell Yanofsky) 179d55f zmq: Fix due to invalid argument and multiple notifiers (João Barbosa) Pull request description: Backports - #16963 - #17445 - #17258 - #17621 - #17924 - #17634 ACKs for top commit: laanwj: ACK cd67b1d, checked that I got more or less the same result (including conflict resolution) backporting these commits Tree-SHA512: 645786267cfb10a01a56f7cfd91ddead5f1475df5714595ae480237e04d40c5cfb7460b40532279cacd83e4b775a4ace68a258ec2184b8ad0e997a690a9245e5
- [0.19] wallet: Reset reused transactions cache bitcoin#18083 - 0.19: Backports bitcoin#17792 - psbt: handle unspendable psbts bitcoin#17524 - qt: Fix comparison function signature bitcoin#17634 - psbt: check that various indexes and amounts are within bounds bitcoin#17156 - [0.19] psbt: check that various indexes and amounts are within bounds bitcoin#18079 - [0.19] Final backports for 0.19.1 bitcoin#17988 - Bug: IsUsedDestination shouldn't use key id as script id for ScriptHash bitcoin#17924 - qt: Fix deprecated QCharRef usage bitcoin#18101 - gui: Throttle GUI update pace when -reindex bitcoin#18121 - gui: Fix race in WalletModel::pollBalanceChanged bitcoin#18123 - gui: Fix unintialized WalletView::progressDialog bitcoin#18062 - Bugfix: GUI: Hide the HD/encrypt icons earlier so they get re-shown if another wallet is open bitcoin#18007 - bug-fix macos: give free bytes to F_PREALLOCATE bitcoin#17887 - test: add missing #include to fix compiler errors bitcoin#17980 - zmq: Fix due to invalid argument and multiple notifiers bitcoin#17445
4d73691 Disallow automatic conversion between hash types (Ben Woosley) fa9ef2c Remove an apparently unnecessary conversion (Ben Woosley) 966a22d Explicitly support conversion between equivalent hash types (Ben Woosley) f32c1e0 Use explicit conversion from WitnessV0KeyHash -> CKeyID (Ben Woosley) 2c54217 Use explicit conversion from PKHash -> CKeyID (Ben Woosley) a9e451f Convert CPubKey to WitnessV0KeyHash directly (Ben Woosley) 3fcc468 Prefer explicit CScriptID construction (Ben Woosley) 0a5ea32 Prefer explicit uint160 conversion (Ben Woosley) Pull request description: This bases the script/standard hash types, TxDestination-related and CScriptID on a base template which does not silently convert the underlying `uintN` type. Inspired by and built on #17924. Commits are small and focused to ease review. Note some of these changes may be relative to existing bugs of the same sort as #17924. See particularly "Convert CPubKey to WitnessV0KeyHash directly" and "Remove an apparently unnecessary conversion". ACKs for top commit: achow101: ACK 4d73691 meshcollider: re-utACK 4d73691 Tree-SHA512: f1b3284ddc6fb6c6e726f2c22668b6d732d45eb5418262ed2b9c728f60be7be43dfb414b6ddd9915025c8dcd7f360dc3b46e997a945a2feb95b0e5c4f05d6b54
…t id for ScriptHash Summary: 6dd59d2e491bc11ab26498668543e65440a3a931 Don't allow implementers to think ScriptHash(Witness*()) results in nesting computation (Gregory Sanders) 4b8f1e989f3b969dc628b0801d5c31ebd373719c IsUsedDestination shouldn't use key id as script id for ScriptHash (Gregory Sanders) Pull request description: Regression introduced in bitcoin/bitcoin#17621 which causes p2sh-segwit addresses to be erroneously missed. Tests are only failing in 0.19 branch, likely because that release still uses p2sh-segwit addresses rather than bech32 by default. I'll devise a test case to catch this going forward. --- Backport of Core [[bitcoin/bitcoin#17924 | PR17924]] Test Plan: ninja all check check-functional Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7800
Regression introduced in #17621 which causes p2sh-segwit addresses to be erroneously missed.
Tests are only failing in 0.19 branch, likely because that release still uses p2sh-segwit addresses rather than bech32 by default.
I'll devise a test case to catch this going forward.