HomePhabricator

Merge #13002: Do not treat bare multisig outputs as IsMine unless watched

Description

Merge #13002: Do not treat bare multisig outputs as IsMine unless watched

Summary:
PR13002 backport https://github.com/bitcoin/bitcoin/pull/13002/files

7d0f80b Use anonymous namespace instead of static functions (Pieter Wuille)
b61fb71 Mention removal of bare multisig IsMine in release notes (Pieter Wuille)
9c2a8b8 Do not treat bare multisig as IsMine (Pieter Wuille)
08f3228 Optimization: only test for witness scripts at top level (Pieter Wuille)
3619735 Track difference between scriptPubKey and P2SH execution in IsMine (Pieter Wuille)
ac6ec62 Switch to a private version of SigVersion inside IsMine (Pieter Wuille)
19fc973 Do not expose SigVersion argument to IsMine (Pieter Wuille)
fb1dfbb Remove unused IsMine overload (Pieter Wuille)
952d821 Make CScript -> CScriptID conversion explicit (Pieter Wuille)

Pull request description:

Currently our wallet code will treat bare multisig outputs (meaning scriptPubKeys with multiple public keys + `OP_CHECKMULTISIG` operator in it) as ours without the user asking for it, as long as all private keys in it are in our wallet.

This is a pointless feature. As it only works when all private keys are in one place, it's useless compared to single key outputs (P2PK, P2PKH, P2WPKH, P2SH-P2WPKH), and worse in terms of space, cost, UTXO size, and ability to test (due to lack of address format for them).

Furthermore, they are problematic in that producing a list of all `scriptPubKeys` we accept is not tractable (it involves all combinations of all public keys that are ours). In further wallet changes I'd like to move to a model where all scriptPubKeys that are treated as ours are explicit, rather than defined by whatever keys we have. The current behavior of the wallet is very hard to model in such a design, so I'd like to get rid of it.

I think there are two options:
* Remove it entirely (do not ever accept bare multisig outputs as ours, unless watched)
* Only accept bare multisig outputs in situations where the P2SH version of that output would also be acceptable

This PR implements the first option. The second option was explored in #12874.

Backport notes:

Test Plan: ninja check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D4911

Details

Provenance
Wladimir J. van der Laan <laanwj@gmail.com>Authored on Apr 26 2018, 17:48
Mark Lundeberg <markblundeberg@users.noreply.github.com>Committed on Jan 13 2020, 00:52
markblundebergPushed on Jan 13 2020, 01:07
Reviewer
Restricted Project
Differential Revision
D4911: Merge #13002: Do not treat bare multisig outputs as IsMine unless watched
Parents
rSTAGING8e73d9061359: document MANDATORY_SCRIPT_VERIFY_FLAGS accurately
Branches
Unknown
Tags
Unknown