diff options
author | Johnson Lau <jl2012@xbt.hk> | 2016-10-16 23:53:16 +0800 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-10-17 14:10:58 +0200 |
commit | 540413d9958fd253d4bf99858db431164db275e1 (patch) | |
tree | f40fc4a2c3cc9084e6946ee320f2edf0bbe10a2f /src/policy/policy.h | |
parent | 9bb2a02f0dd8851a6dc413fd86ce0b51878b5007 (diff) | |
download | bitcoin-540413d9958fd253d4bf99858db431164db275e1.tar.xz |
Add standard limits for P2WSH with tests
Github-Pull: #8499
Rebased-From: 3ade2f64cfe43ab53e4869ffc35d5fd23201e1c1
Diffstat (limited to 'src/policy/policy.h')
-rw-r--r-- | src/policy/policy.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/policy/policy.h b/src/policy/policy.h index 9d6ff1233b..fb528d7486 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -30,6 +30,12 @@ static const unsigned int MAX_STANDARD_TX_SIGOPS_COST = MAX_BLOCK_SIGOPS_COST/5; static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300; /** Default for -bytespersigop */ static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20; +/** The maximum number of witness stack items in a standard P2WSH script */ +static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS = 100; +/** The maximum size of each witness stack item in a standard P2WSH script */ +static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE = 80; +/** The maximum size of a standard witnessScript */ +static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600; /** * Standard script verification flags that standard transactions will comply * with. However scripts violating these flags may still be present in valid @@ -69,6 +75,12 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes * @return True if all inputs (scriptSigs) use only standard transaction forms */ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs); + /** + * Check if the transaction is over standard P2WSH resources limit: + * 3600bytes witnessScript size, 80bytes per witness stack element, 100 witness stack elements + * These limits are adequate for multi-signature up to n-of-100 using OP_CHECKSIG, OP_ADD, and OP_EQUAL, + */ +bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs); extern unsigned int nBytesPerSigOp; |