From 5b383ba7f466e3afa24ee04bd854950d4148ad24 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sun, 18 Feb 2018 18:49:04 -0300 Subject: [PATCH] enable cryptoconditions spending --- src/script/script.cpp | 23 ++++++++++++++--------- src/script/standard.cpp | 4 +++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/script/script.cpp b/src/script/script.cpp index a78bd7e29..c5eab8ca8 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -227,21 +227,26 @@ bool CScript::IsPayToCryptoCondition() const { const_iterator pc = this->begin(); vector data; - int i; + int i = 0; while (pc < this->end()) { opcodetype opcode; if (!this->GetOp(pc, opcode, data)) return 0; - if (0 == i) - if (opcode != OP_PUSHDATA1) + switch (i++) { + case 0: + // Binary condition should be less than 76 bytes + if (!(opcode > OP_0 && opcode < OP_PUSHDATA1)) + return 0; + break; + case 1: + if (opcode != OP_CHECKCRYPTOCONDITION) + return 0; + break; + default: return 0; - if (1 == i) - if (opcode != OP_CHECKCRYPTOCONDITION) - return 0; - if (i > 1) - return 0; - i++; + break; + } } return 1; } diff --git a/src/script/standard.cpp b/src/script/standard.cpp index c304840f4..4dadaff56 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -71,7 +71,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector