| 54 | } |
| 55 | |
| 56 | bool 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 | |
| 87 | unsigned int GetSpecialScriptSize(unsigned int nSize) |
| 88 | { |
no test coverage detected