| 229 | } |
| 230 | |
| 231 | bool CScript::IsCommitment(const std::vector<unsigned char> &data) const { |
| 232 | // To ensure we have an immediate push, we limit the commitment size to 64 |
| 233 | // bytes. In addition to the data themselves, we have 2 extra bytes: |
| 234 | // OP_RETURN and the push opcode itself. |
| 235 | if (data.size() > 64 || this->size() != data.size() + 2) { |
| 236 | return false; |
| 237 | } |
| 238 | |
| 239 | if ((*this)[0] != OP_RETURN || (*this)[1] != data.size()) { |
| 240 | return false; |
| 241 | } |
| 242 | |
| 243 | for (size_t i = 0; i < data.size(); i++) { |
| 244 | if ((*this)[i + 2] != data[i]) { |
| 245 | return false; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | return true; |
| 250 | } |