From e6b9730c49da6a0219453dec8f4df351292e6e07 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 17 Jun 2018 16:28:04 -0700 Subject: Do not expose invalidity from IsMine --- src/script/ismine.cpp | 12 ++---------- src/script/ismine.h | 6 ------ 2 files changed, 2 insertions(+), 16 deletions(-) (limited to 'src/script') diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp index 43dd9e582..8c2686648 100644 --- a/src/script/ismine.cpp +++ b/src/script/ismine.cpp @@ -38,7 +38,7 @@ enum class IsMineResult NO = 0, //! Not ours WATCH_ONLY = 1, //! Included in watch-only balance SPENDABLE = 2, //! Included in all balances - INVALID = 3, //! Not spendable by anyone + INVALID = 3, //! Not spendable by anyone (uncompressed pubkey in segwit, P2SH inside P2SH or witness, witness inside witness) }; bool PermitsUncompressed(IsMineSigVersion sigversion) @@ -173,12 +173,10 @@ IsMineResult IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, } // namespace -isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid) +isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey) { - isInvalid = false; switch (IsMineInner(keystore, scriptPubKey, IsMineSigVersion::TOP)) { case IsMineResult::INVALID: - isInvalid = true; case IsMineResult::NO: return ISMINE_NO; case IsMineResult::WATCH_ONLY: @@ -189,12 +187,6 @@ isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& assert(false); } -isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey) -{ - bool isInvalid = false; - return IsMine(keystore, scriptPubKey, isInvalid); -} - isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest) { CScript script = GetScriptForDestination(dest); diff --git a/src/script/ismine.h b/src/script/ismine.h index a15768aec..4246da49f 100644 --- a/src/script/ismine.h +++ b/src/script/ismine.h @@ -24,12 +24,6 @@ enum isminetype /** used for bitflags of isminetype */ typedef uint8_t isminefilter; -/* isInvalid becomes true when the script is found invalid by consensus or policy. This will terminate the recursion - * and return ISMINE_NO immediately, as an invalid script should never be considered as "mine". This is needed as - * different SIGVERSION may have different network rules. Currently the only use of isInvalid is indicate uncompressed - * keys in SigVersion::WITNESS_V0 script, but could also be used in similar cases in the future - */ -isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid); isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest); -- cgit v1.2.3 From bb582a59c7532b0e4f647d9dfe50f0d816e81427 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 17 Jun 2018 19:44:50 -0700 Subject: Add P2WSH destination helper and use it instead of manual hashing --- src/script/standard.cpp | 10 +++++++--- src/script/standard.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/script') diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d9269d614..f0b2c62a9 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -5,6 +5,7 @@ #include