Retrieve a minimally-encoded number in range [min,max] from an (opcode, data) pair, * whether it's OP_n or through a push. */
| 64 | /** Retrieve a minimally-encoded number in range [min,max] from an (opcode, data) pair, |
| 65 | * whether it's OP_n or through a push. */ |
| 66 | static std::optional<int> GetScriptNumber(opcodetype opcode, valtype data, int min, int max) |
| 67 | { |
| 68 | int count; |
| 69 | if (IsSmallInteger(opcode)) { |
| 70 | count = CScript::DecodeOP_N(opcode); |
| 71 | } else if (IsPushdataOp(opcode)) { |
| 72 | if (!CheckMinimalPush(data, opcode)) return {}; |
| 73 | try { |
| 74 | count = CScriptNum(data, /* fRequireMinimal = */ true).getint(); |
| 75 | } catch (const scriptnum_error&) { |
| 76 | return {}; |
| 77 | } |
| 78 | } else { |
| 79 | return {}; |
| 80 | } |
| 81 | if (count < min || count > max) return {}; |
| 82 | return count; |
| 83 | } |
| 84 | |
| 85 | static bool MatchMultisig(const CScript& script, int& required_sigs, std::vector<valtype>& pubkeys) |
| 86 | { |
no test coverage detected