MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / IsCommitment

Method IsCommitment

src/script/script.cpp:231–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231bool 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}

Callers 2

BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 1

sizeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64