25 memcpy(&hash, &script[3], 20);
33 if (script.
size() == 23 && script[0] ==
OP_HASH360 && script[1] == 20
35 memcpy(&hash, &script[2], 20);
44 && (script[1] == 0x02 || script[1] == 0x03)) {
45 pubkey.
Set(&script[1], &script[34]);
48 if (script.size() == 67 && script[0] == 65 && script[66] ==
OP_CHECKSIG 49 && script[1] == 0x04) {
50 pubkey.
Set(&script[1], &script[66]);
59 if (IsToKeyID(script, keyID)) {
62 memcpy(&out[1], &keyID, 20);
66 if (IsToScriptID(script, scriptID)) {
69 memcpy(&out[1], &scriptID, 20);
73 if (IsToPubKey(script, pubkey)) {
75 memcpy(&out[1], &pubkey[1], 32);
76 if (pubkey[0] == 0x02 || pubkey[0] == 0x03) {
79 }
else if (pubkey[0] == 0x04) {
80 out[0] = 0x04 | (pubkey[64] & 0x01);
89 if (nSize == 0 || nSize == 1)
91 if (nSize == 2 || nSize == 3 || nSize == 4 || nSize == 5)
112 memcpy(&script[2], in.data(), 20);
120 memcpy(&script[2], in.data(), 32);
125 unsigned char vch[33] = {};
127 memcpy(&vch[1], in.data(), 32);
128 CPubKey pubkey(&vch[0], &vch[33]);
129 if (!pubkey.Decompress())
131 assert(pubkey.size() == 65);
134 memcpy(&script[1], pubkey.begin(), 65);
155 while (((n % 10) == 0) && e < 9) {
161 assert(d >= 1 && d <= 9);
163 return 1 + (n*9 + d - 1)*10 + e;
165 return 1 + (n - 1)*10 + 9;
uint64_t CompressAmount(uint64_t n)
void resize(size_type new_size)
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
bool DecompressScript(CScript &script, unsigned int nSize, const std::vector< unsigned char > &in)
bool CompressScript(const CScript &script, std::vector< unsigned char > &out)
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid()) ...
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
void * memcpy(void *a, const void *b, size_t c)
A reference to a CKey: the Hash360 of its serialized public key.
A reference to a CScript: the Hash360 of its serialization (see script.h)
unsigned int GetSpecialScriptSize(unsigned int nSize)
uint64_t DecompressAmount(uint64_t x)