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

Function CompressScript

src/compressor.cpp:55–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

SerMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 4

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

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68