MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / CScript

Class CScript

src/script/script.h:384–560  ·  view source on GitHub ↗

Serialized script, used inside transaction inputs and outputs */

Source from the content-addressed store, hash-verified

382
383/** Serialized script, used inside transaction inputs and outputs */
384class CScript : public CScriptBase
385{
386protected:
387 CScript& push_int64(int64_t n)
388 {
389 if (n == -1 || (n >= 1 && n <= 16))
390 {
391 push_back(n + (OP_1 - 1));
392 }
393 else if (n == 0)
394 {
395 push_back(OP_0);
396 }
397 else
398 {
399 *this << CScriptNum::serialize(n);
400 }
401 return *this;
402 }
403public:
404 CScript() { }
405 CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { }
406 CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
407 CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
408
409 ADD_SERIALIZE_METHODS;
410
411 template <typename Stream, typename Operation>
412 inline void SerializationOp(Stream& s, Operation ser_action) {
413 READWRITEAS(CScriptBase, *this);
414 }
415
416 CScript& operator+=(const CScript& b)
417 {
418 reserve(size() + b.size());
419 insert(end(), b.begin(), b.end());
420 return *this;
421 }
422
423 friend CScript operator+(const CScript& a, const CScript& b)
424 {
425 CScript ret = a;
426 ret += b;
427 return ret;
428 }
429
430 CScript(int64_t b) { operator<<(b); }
431
432 explicit CScript(opcodetype b) { operator<<(b); }
433 explicit CScript(const CScriptNum& b) { operator<<(b); }
434 explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
435
436
437 CScript& operator<<(int64_t b) { return push_int64(b); }
438
439 CScript& operator<<(opcodetype opcode)
440 {
441 if (opcode < 0 || opcode > 0xff)

Callers

nothing calls this directly

Calls 7

insertFunction · 0.85
WriteLE16Function · 0.85
WriteLE32Function · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getvchMethod · 0.45

Tested by

no test coverage detected