MCPcopy Create free account
hub / github.com/ElementsProject/elements / DecompressScript

Function DecompressScript

src/compressor.cpp:95–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95bool DecompressScript(CScript& script, unsigned int nSize, const CompressedScript& in)
96{
97 switch(nSize) {
98 case 0x00:
99 script.resize(25);
100 script[0] = OP_DUP;
101 script[1] = OP_HASH160;
102 script[2] = 20;
103 memcpy(&script[3], in.data(), 20);
104 script[23] = OP_EQUALVERIFY;
105 script[24] = OP_CHECKSIG;
106 return true;
107 case 0x01:
108 script.resize(23);
109 script[0] = OP_HASH160;
110 script[1] = 20;
111 memcpy(&script[2], in.data(), 20);
112 script[22] = OP_EQUAL;
113 return true;
114 case 0x02:
115 case 0x03:
116 script.resize(35);
117 script[0] = 33;
118 script[1] = nSize;
119 memcpy(&script[2], in.data(), 32);
120 script[34] = OP_CHECKSIG;
121 return true;
122 case 0x04:
123 case 0x05:
124 unsigned char vch[33] = {};
125 vch[0] = nSize - 2;
126 memcpy(&vch[1], in.data(), 32);
127 CPubKey pubkey{vch};
128 if (!pubkey.Decompress())
129 return false;
130 assert(pubkey.size() == 65);
131 script.resize(67);
132 script[0] = 65;
133 memcpy(&script[1], pubkey.begin(), 65);
134 script[66] = OP_CHECKSIG;
135 return true;
136 }
137 return false;
138}
139
140// Amount compression:
141// * If the amount is 0, output 0

Callers 2

UnserMethod · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 5

DecompressMethod · 0.80
resizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.68