aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-01-16 19:23:15 +0100
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-01-16 19:23:33 +0100
commitf018d0c9cd7f408dac016b6bfc873670de713d27 (patch)
tree507d9547263ae63a37c5a5e03c5a5838fc88dbfa /src
parenta9c789ed964dbfae59585e3b56c35816afc3d95e (diff)
parent6dd59d2e491bc11ab26498668543e65440a3a931 (diff)
Merge #17924: Bug: IsUsedDestination shouldn't use key id as script id for ScriptHash
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 https://github.com/bitcoin/bitcoin/pull/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 6dd59d2e491bc11ab26498668543e65440a3a931 MarcoFalke: ACK 6dd59d2 meshcollider: Code review ACK 6dd59d2e491bc11ab26498668543e65440a3a931 Tree-SHA512: b3e0f320c97b8c1f814cc386840240cbde2761fee9711617b713d3f75a4a5dce2dff2df573d80873df42a1f4b74e816ab8552a573fa1d62c344997fbb6af9950
Diffstat (limited to 'src')
-rw-r--r--src/script/standard.h5
-rw-r--r--src/wallet/wallet.cpp2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/script/standard.h b/src/script/standard.h
index e0defaf106..49a45f3eba 100644
--- a/src/script/standard.h
+++ b/src/script/standard.h
@@ -80,9 +80,14 @@ struct PKHash : public uint160
using uint160::uint160;
};
+struct WitnessV0KeyHash;
struct ScriptHash : public uint160
{
ScriptHash() : uint160() {}
+ // These don't do what you'd expect.
+ // Use ScriptHash(GetScriptForDestination(...)) instead.
+ explicit ScriptHash(const WitnessV0KeyHash& hash) = delete;
+ explicit ScriptHash(const PKHash& hash) = delete;
explicit ScriptHash(const uint160& hash) : uint160(hash) {}
explicit ScriptHash(const CScript& script);
using uint160::uint160;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 12c37968ce..c30125e827 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -744,7 +744,7 @@ bool CWallet::IsUsedDestination(const uint256& hash, unsigned int n) const
if (GetDestData(wpkh_dest, "used", nullptr)) {
return true;
}
- ScriptHash sh_wpkh_dest(wpkh_dest);
+ ScriptHash sh_wpkh_dest(GetScriptForDestination(wpkh_dest));
if (GetDestData(sh_wpkh_dest, "used", nullptr)) {
return true;
}