本文整理匯總了C++中DecodeBase58函數的典型用法代碼示例。如果您正苦於以下問題:C++ DecodeBase58函數的具體用法?C++ DecodeBase58怎麽用?C++ DecodeBase58使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DecodeBase58函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: IsStealthAddress
bool IsStealthAddress(const std::string& encodedAddress)
{
data_chunk raw;
if (!DecodeBase58(encodedAddress, raw))
{
//printf("IsStealthAddress DecodeBase58 falied.\n");
return false;
};
if (!VerifyChecksum(raw))
{
//printf("IsStealthAddress verify_checksum falied.\n");
return false;
};
if (raw.size() < 1 + 1 + 33 + 1 + 33 + 1 + 1 + 4)
{
//printf("IsStealthAddress too few bytes provided.\n");
return false;
};
uint8_t* p = &raw[0];
uint8_t version = *p++;
if (version != stealth_version_byte)
{
//printf("IsStealthAddress version mismatch 0x%x != 0x%x.\n", version, stealth_version_byte);
return false;
};
return true;
};
示例2: Base58Decode
static void Base58Decode(benchmark::State& state)
{
const char* addr = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem";
std::vector<unsigned char> vch;
while (state.KeepRunning()) {
DecodeBase58(addr, vch);
}
}
示例3: DecodeBase58
std::string DecodeBase58(const char* psz)
{
std::vector<unsigned char> vchRet;
std::string stBuf;
if(DecodeBase58(psz, vchRet)) {
stBuf.assign(vchRet.begin(),vchRet.end());
return stBuf;
}
return stBuf;
}
示例4: DecodeBase58Check
bool DecodeBase58Check(const char *psz, std::vector<uint8_t> &vchRet) {
if (!DecodeBase58(psz, vchRet) || (vchRet.size() < 4)) {
vchRet.clear();
return false;
}
// re-calculate the checksum, insure it matches the included 4-byte checksum
uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4);
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) {
vchRet.clear();
return false;
}
vchRet.resize(vchRet.size() - 4);
return true;
}
示例5: DecodeBase58
std::string DecodeBase58(const char* psz)
{
std::vector<unsigned char> vch;
DecodeBase58(psz, vch);
std::stringstream ss;
ss << std::hex;
for (unsigned int i = 0; i < vch.size(); i++) {
unsigned char* c = &vch[i];
ss << setw(2) << setfill('0') << (int)c[0];
}
return ss.str();
}
示例6: printf
bool CStealthAddress::SetEncoded(const std::string& encodedAddress)
{
data_chunk raw;
if (!DecodeBase58(encodedAddress, raw))
{
if (fDebug)
printf("CStealthAddress::SetEncoded DecodeBase58 falied.\n");
return false;
};
if (!VerifyChecksum(raw))
{
if (fDebug)
printf("CStealthAddress::SetEncoded verify_checksum falied.\n");
return false;
};
if (raw.size() < 1 + 1 + 33 + 1 + 33 + 1 + 1 + 4)
{
if (fDebug)
printf("CStealthAddress::SetEncoded() too few bytes provided.\n");
return false;
};
uint8_t* p = &raw[0];
uint8_t version = *p++;
if (version != stealth_version_byte)
{
printf("CStealthAddress::SetEncoded version mismatch 0x%x != 0x%x.\n", version, stealth_version_byte);
return false;
};
options = *p++;
scan_pubkey.resize(33);
memcpy(&scan_pubkey[0], p, 33);
p += 33;
//uint8_t spend_pubkeys = *p++;
p++;
spend_pubkey.resize(33);
memcpy(&spend_pubkey[0], p, 33);
return true;
};
示例7: DecodeBase58Check
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)
{
if (!DecodeBase58(psz, vchRet) ||
(vchRet.size() < 4)) {
vchRet.clear();
return false;
}
// re-calculate the checksum, ensure it matches the included 4-byte checksum
uint256 hash = doubleSha256(reinterpret_cast<const char*>(vchRet.data()), vchRet.size() - 4);
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) {
vchRet.clear();
return false;
}
vchRet.resize(vchRet.size() - 4);
return true;
}
示例8: DecodeBase58Check
// Decode a base58-encoded string psz that includes a checksum, into byte vector vchRet
// returns true if decoding is successful
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)
{
if (!DecodeBase58(psz, vchRet))
return false;
if (vchRet.size() < 4)
{
vchRet.clear();
return false;
}
uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
{
vchRet.clear();
return false;
}
vchRet.resize(vchRet.size()-4);
return true;
}
示例9: DecodeBase58
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet) {
return DecodeBase58(str.c_str(), vchRet);
}
示例10: DecodeBase58
bool DecodeBase58(const std::string &str, std::vector<uint8_t> &vchRet) {
return DecodeBase58(str.c_str(), vchRet);
}
示例11: IsStealthAddress
// stealth addresses have the ticker suffix
bool IsStealthAddress(const std::string& qualAddress)
{
std::string encodedAddress;
#if USE_QUALIFIED_ADDRESSES
int nColor;
if (!SplitQualifiedAddress(qualAddress, encodedAddress, nColor, fDebug))
{
if (fDebug)
{
printf("StealthAddress::IsStealthAddress: could not split address..\n");
}
return false;
}
#else
encodedAddress = qualAddress;
#endif
data_chunk raw;
if (!DecodeBase58(encodedAddress, raw))
{
if (fDebug)
{
printf("IsStealthAddress: DecodeBase58 falied.\n");
}
return false;
};
if (!VerifyChecksum(raw))
{
if (fDebug)
{
printf("IsStealthAddress: verify_checksum falied.\n");
}
return false;
};
if (raw.size() < N_COLOR_BYTES + 1 + 1 + 33 + 1 + 33 + 1 + 1 + 4)
{
if (fDebug)
{
printf("IsStealthAddress: too few bytes provided.\n");
}
return false;
};
uint8_t* p = &raw[0];
int nColor = 0;
for (int i = 0; i < N_COLOR_BYTES; ++i)
{
nColor += pow(256, (int) i) * ((int) *p);
++p;
}
if (!CheckColor(nColor))
{
if (fDebug)
{
printf("IsStealthAddress: Invalid currency %d.\n", nColor);
}
}
uint8_t version = *p++;
if (version != stealth_version_byte)
{
if (fDebug)
{
printf("IsStealthAddress version mismatch 0x%x != 0x%x.\n", version, stealth_version_byte);
}
return false;
};
return true;
};
示例12: printf
// color information is stored strting in the second byte so that
// addresses for different colors have distinct starting sequences
bool CStealthAddress::SetEncoded(const std::string& encodedAddress)
{
data_chunk raw;
if (!DecodeBase58(encodedAddress, raw))
{
if (fDebug)
printf("CStealthAddress::SetEncoded DecodeBase58 falied.\n");
return false;
};
if (!VerifyChecksum(raw))
{
if (fDebug)
printf("CStealthAddress::SetEncoded verify_checksum falied.\n");
return false;
};
size_t nRawSize = raw.size();
// see CStealthAddress::Encoded()
// Put color first so that stealth addresses of different currencies look different
// N_COLOR_BYTES, 1-version, 1-options, 33-scan_pubkey, 1-#spend_pubkeys,
// 33-spend_pubkey, 1-#sigs, 1-?, 4 checksum
if (nRawSize < N_COLOR_BYTES + 1 + 1 + 33 + 1 + 33 + 1 + 1 + 4)
{
if (fDebug)
printf("CStealthAddress::SetEncoded() too few bytes provided.\n");
return false;
};
uint8_t* p = &raw[0];
// Stealth addresses store color as a simple index little bytes first.
this->nColor = 0;
for (int i = 0; i < N_COLOR_BYTES; ++i)
{
this->nColor += pow(256, (int) i) * ((int) *p);
++p;
}
if (!CheckColor(nColor))
{
printf("CStealthAddress::SetEncoded(): Color %d is not valid (1...%d).\n",
this->nColor, N_COLORS);
}
uint8_t version = *p++;
if (version != stealth_version_byte)
{
printf("CStealthAddress::SetEncoded version mismatch 0x%x != 0x%x.\n", version, stealth_version_byte);
return false;
};
options = *p++;
scan_pubkey.resize(33);
memcpy(&scan_pubkey[0], p, 33);
p += 33;
//uint8_t spend_pubkeys = *p++;
p++;
spend_pubkey.resize(33);
memcpy(&spend_pubkey[0], p, 33);
return true;
};