aboutsummaryrefslogtreecommitdiff
path: root/src/policy/policy.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-07-26 14:21:04 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-07-26 14:24:11 +0200
commit4b1a4d8810f9d84d0e03dc02b53fd910606a5544 (patch)
tree9c4a37f2790206db491774e3b9b882bccfe02a37 /src/policy/policy.cpp
parent618c9dd8c651f15ea37a09d3ee4fa4426c75ac02 (diff)
parentc59c434b7d1211c13f7904b9bc675e16910a1c0a (diff)
downloadbitcoin-4b1a4d8810f9d84d0e03dc02b53fd910606a5544.tar.xz
Merge #8381: Make witness v0 outputs non-standard
c59c434 qa: Add test for standardness of segwit v0 outputs (Suhas Daftuar) 1ffaff2 Make witness v0 outputs non-standard before segwit activation (Johnson Lau)
Diffstat (limited to 'src/policy/policy.cpp')
-rw-r--r--src/policy/policy.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index 0cd3ac7119..48080abc77 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -31,7 +31,7 @@
* DUP CHECKSIG DROP ... repeated 100 times... OP_1
*/
-bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
+bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType, const bool witnessEnabled)
{
std::vector<std::vector<unsigned char> > vSolutions;
if (!Solver(scriptPubKey, whichType, vSolutions))
@@ -50,10 +50,13 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
(!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes))
return false;
+ else if (!witnessEnabled && (whichType == TX_WITNESS_V0_KEYHASH || whichType == TX_WITNESS_V0_SCRIPTHASH))
+ return false;
+
return whichType != TX_NONSTANDARD;
}
-bool IsStandardTx(const CTransaction& tx, std::string& reason)
+bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnessEnabled)
{
if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) {
reason = "version";
@@ -92,7 +95,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
unsigned int nDataOut = 0;
txnouttype whichType;
BOOST_FOREACH(const CTxOut& txout, tx.vout) {
- if (!::IsStandard(txout.scriptPubKey, whichType)) {
+ if (!::IsStandard(txout.scriptPubKey, whichType, witnessEnabled)) {
reason = "scriptpubkey";
return false;
}