| 53 | } |
| 54 | |
| 55 | bool 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 | |
| 86 | unsigned int GetSpecialScriptSize(unsigned int nSize) |
| 87 | { |