aboutsummaryrefslogtreecommitdiff
path: root/src/policy/policy.h
diff options
context:
space:
mode:
authorJohnson Lau <jl2012@xbt.hk>2016-10-16 23:53:16 +0800
committerJohnson Lau <jl2012@xbt.hk>2016-10-16 23:53:35 +0800
commit3ade2f64cfe43ab53e4869ffc35d5fd23201e1c1 (patch)
tree78eff29685321a56c9456c5d457c4c079aa7ddb9 /src/policy/policy.h
parent03dd707dc027fbf6f24120213f8eb66571600374 (diff)
Add standard limits for P2WSH with tests
Diffstat (limited to 'src/policy/policy.h')
-rw-r--r--src/policy/policy.h12
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;