23 memcpy(&hash, &script[3], 20);
30 if (script.
size() == 23 && script[0] ==
OP_HASH160 && script[1] == 20 &&
32 memcpy(&hash, &script[2], 20);
39 if (script.
size() == 35 && script[0] == 33 && script[34] ==
OP_CHECKSIG &&
40 (script[1] == 0x02 || script[1] == 0x03)) {
41 pubkey.
Set(&script[1], &script[34]);
44 if (script.
size() == 67 && script[0] == 65 && script[66] ==
OP_CHECKSIG &&
46 pubkey.
Set(&script[1], &script[66]);
58 memcpy(&out[1], &keyID, 20);
65 memcpy(&out[1], &scriptID, 20);
71 memcpy(&out[1], &pubkey[1], 32);
72 if (pubkey[0] == 0x02 || pubkey[0] == 0x03) {
75 }
else if (pubkey[0] == 0x04) {
76 out[0] = 0x04 | (pubkey[64] & 0x01);
84 if (nSize == 0 || nSize == 1) {
87 if (nSize == 2 || nSize == 3 || nSize == 4 || nSize == 5) {
94 const std::vector<uint8_t> &in) {
101 memcpy(&script[3], in.
data(), 20);
109 memcpy(&script[2], in.
data(), 20);
117 memcpy(&script[2], in.
data(), 32);
122 uint8_t vch[33] = {};
124 memcpy(&vch[1], in.data(), 32);
126 if (!pubkey.Decompress()) {
129 assert(pubkey.size() == 65);
132 memcpy(&script[1], pubkey.
begin(), 65);
156 while (((n % 10) == 0) && e < 9) {
164 return 1 + (n * 9 + d - 1) * 10 + e;
166 return 1 + (n - 1) * 10 + 9;
static constexpr Amount SATOSHI
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
Serialized script, used inside transaction inputs and outputs.
A reference to a CScript: the Hash160 of its serialization (see script.h)
void resize(size_type new_size)
static bool IsToPubKey(const CScript &script, CPubKey &pubkey)
static bool IsToKeyID(const CScript &script, CKeyID &hash)
Amount DecompressAmount(uint64_t x)
static bool IsToScriptID(const CScript &script, CScriptID &hash)
uint64_t CompressAmount(Amount amt)
Compress amount.
unsigned int GetSpecialScriptSize(unsigned int nSize)
bool CompressScript(const CScript &script, std::vector< uint8_t > &out)
bool DecompressScript(CScript &script, unsigned int nSize, const std::vector< uint8_t > &in)
static constexpr Amount zero() noexcept