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

Function CompressScript

src/compressor.cpp:56–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56bool CompressScript(const CScript& script, std::vector<unsigned char> &out)
57{
58 CKeyID keyID;
59 if (IsToKeyID(script, keyID)) {
60 out.resize(21);
61 out[0] = 0x00;
62 memcpy(&out[1], &keyID, 20);
63 return true;
64 }
65 CScriptID scriptID;
66 if (IsToScriptID(script, scriptID)) {
67 out.resize(21);
68 out[0] = 0x01;
69 memcpy(&out[1], &scriptID, 20);
70 return true;
71 }
72 CPubKey pubkey;
73 if (IsToPubKey(script, pubkey)) {
74 out.resize(33);
75 memcpy(&out[1], &pubkey[1], 32);
76 if (pubkey[0] == 0x02 || pubkey[0] == 0x03) {
77 out[0] = pubkey[0];
78 return true;
79 } else if (pubkey[0] == 0x04) {
80 out[0] = 0x04 | (pubkey[64] & 0x01);
81 return true;
82 }
83 }
84 return false;
85}
86
87unsigned int GetSpecialScriptSize(unsigned int nSize)
88{

Callers 1

SerializeMethod · 0.85

Calls 5

IsToKeyIDFunction · 0.85
memcpyFunction · 0.85
IsToScriptIDFunction · 0.85
IsToPubKeyFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected