diff options
author | Johnson Lau <jl2012@users.noreply.github.com> | 2016-07-20 18:31:45 +0800 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-07-26 14:25:28 +0200 |
commit | f84ee3dab66831383e58c7de3fabc306754633db (patch) | |
tree | e0e0df62fd11e02833beb1044ce695593a6e9c62 /src/policy/policy.cpp | |
parent | 86edc20a178cc17cdc6915e9e93a7241c27c368c (diff) | |
download | bitcoin-f84ee3dab66831383e58c7de3fabc306754633db.tar.xz |
Make witness v0 outputs non-standard before segwit activation
Github-Pull: #8381
Rebased-From: 1ffaff2f747af683513d6d74a7241d41e3f6e051
Diffstat (limited to 'src/policy/policy.cpp')
-rw-r--r-- | src/policy/policy.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 8617db00c8..de3996bb4a 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)) @@ -49,11 +49,14 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) } else if (whichType == TX_NULL_DATA && (!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; } |