MCPcopy Create free account
hub / github.com/LUX-Core/lux / CScript

Class CScript

src/script/script.h:421–734  ·  view source on GitHub ↗

Serialized script, used inside transaction inputs and outputs */

Source from the content-addressed store, hash-verified

419
420/** Serialized script, used inside transaction inputs and outputs */
421class CScript : public CScriptBase
422{
423protected:
424 CScript& push_int64(int64_t n)
425 {
426 if (n == -1 || (n >= 1 && n <= 16))
427 {
428 push_back(n + (OP_1 - 1));
429 }
430 else if (n == 0)
431 {
432 push_back(OP_0);
433 }
434 else
435 {
436 *this << CScriptNum::serialize(n);
437 }
438 return *this;
439 }
440public:
441 CScript() { }
442 CScript(const CScript& b) : CScriptBase(b.begin(), b.end()) { }
443 CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { }
444 CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
445 CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
446
447 ADD_SERIALIZE_METHODS;
448
449 template <typename Stream, typename Operation>
450 inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
451 READWRITE(static_cast<CScriptBase&>(*this));
452 }
453
454 CScript& operator+=(const CScript& b)
455 {
456 reserve(size() + b.size());
457 insert(end(), b.begin(), b.end());
458 return *this;
459 }
460
461 friend CScript operator+(const CScript& a, const CScript& b)
462 {
463 CScript ret = a;
464 ret += b;
465 return ret;
466 }
467
468 CScript(int64_t b) { operator<<(b); }
469
470 explicit CScript(opcodetype b) { operator<<(b); }
471 explicit CScript(const CScriptNum& b) { operator<<(b); }
472 explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
473
474
475 CScript& operator<<(int64_t b) { return push_int64(b); }
476
477 CScript& operator<<(opcodetype opcode)
478 {

Callers

nothing calls this directly

Calls 7

sizeFunction · 0.85
endFunction · 0.85
RawMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getvchMethod · 0.45

Tested by

no test coverage detected