From 28b946127bb9439165f26844e37a160ee0f33946 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Sun, 18 Feb 2018 19:35:48 -0300 Subject: [PATCH] make IsPayToCryptoCondition neat --- src/script/script.cpp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/script/script.cpp b/src/script/script.cpp index c5eab8ca8..5069d9152 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -227,28 +227,15 @@ bool CScript::IsPayToCryptoCondition() const { const_iterator pc = this->begin(); vector data; - int i = 0; - while (pc < this->end()) - { - opcodetype opcode; - if (!this->GetOp(pc, opcode, data)) - return 0; - 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; - break; - } - } - return 1; + opcodetype opcode; + if (this->GetOp(pc, opcode, data)) + // Sha256 conditions are <76 bytes + if (opcode > OP_0 && opcode < OP_PUSHDATA1) + if (this->GetOp(pc, opcode, data)) + if (opcode == OP_CHECKCRYPTOCONDITION) + if (pc == this->end()) + return 1; + return 0; } bool CScript::IsPushOnly() const