// The stake modifier used to hash for a stake kernel is chosen as the stake
// modifier about a selection interval later than the coin generating the kernel
-static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
+static bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
{
nStakeModifier = 0;
if (!mapBlockIndex.count(hashBlockFrom))
return true;
}
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier)
+bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier)
{
int nStakeModifierHeight;
int64_t nStakeModifierTime;
// The stake modifier used to hash for a stake kernel is chosen as the stake
// modifier about a selection interval later than the coin generating the kernel
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier);
+bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier);
// Check whether stake kernel meets hash target
// Sets hashProofOfStake on success return
// Complete first hashing iteration
uint256 hash1;
SHA256_Update(&ctx, (unsigned char*)&nTimeTx, 4);
- SHA256_Final((unsigned char*)&hash1, &ctx);
+ SHA256_Final(hash1.begin(), &ctx);
// Restore context
ctx = workerCtx;
// Finally, calculate kernel hash
- SHA256((unsigned char*)&hash1, sizeof(hashProofOfStake), (unsigned char*)&hashProofOfStake);
+ SHA256(hash1.begin(), sizeof(hashProofOfStake), (unsigned char*)&hashProofOfStake);
// Skip if hash doesn't satisfy the maximum target
if (hashProofOfStake[7] > nMaxTarget32)
// Complete first hashing iteration
uint256 hash1;
SHA256_Update(&ctx, (unsigned char*)&nTimeTx, 4);
- SHA256_Final((unsigned char*)&hash1, &ctx);
+ SHA256_Final(hash1.begin(), &ctx);
// Restore context
ctx = workerCtx;
// Finally, calculate kernel hash
uint256 hashProofOfStake;
- SHA256((unsigned char*)&hash1, sizeof(hashProofOfStake), (unsigned char*)&hashProofOfStake);
+ SHA256(hash1.begin(), hashProofOfStake.size(), hashProofOfStake.begin());
// Skip if hash doesn't satisfy the maximum target
if (hashProofOfStake > nMaxTarget)
bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
vchSig.clear();
- auto sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
+ auto sig = ECDSA_do_sign(hash.begin(), hash.size(), pkey);
if (sig==NULL)
return false;
auto group = EC_KEY_get0_group(pkey);
// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
// 0x1D = second key with even y, 0x1E = second key with odd y
-bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
+bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
{
bool fOk = false;
auto sig = ECDSA_do_sign(hash.begin(), hash.size(), pkey);
// This is only slightly more CPU intensive than just verifying it.
// If this function succeeds, the recovered public key is guaranteed to be valid
// (the signature is a valid signature of the given data for that key)
-bool CPubKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig)
+bool CPubKey::SetCompactSignature(const uint256 &hash, const std::vector<unsigned char>& vchSig)
{
if (vchSig.size() != 65)
return false;
return ret;
}
-bool CPubKey::VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig)
+bool CPubKey::VerifyCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig)
{
CPubKey key;
if (!key.SetCompactSignature(hash, vchSig))
}
bool Verify(const uint256& hash, const std::vector<unsigned char>& vchSig) const;
- bool VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig);
+ bool VerifyCompact(const uint256 &hash, const std::vector<unsigned char>& vchSig);
- bool SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig);
+ bool SetCompactSignature(const uint256 &hash, const std::vector<unsigned char>& vchSig);
// Reserialize to DER
static bool ReserealizeSignature(std::vector<unsigned char>& vchSig);
// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
// 0x1D = second key with even y, 0x1E = second key with odd y
- bool SignCompact(uint256 hash, std::vector<unsigned char>& vchSig);
+ bool SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig);
bool IsValid();
uint256 GetRandHash()
{
uint256 hash;
- RAND_bytes((uint8_t*)&hash, sizeof(hash));
+ RAND_bytes(hash.begin(), hash.size());
return hash;
}
#define UBEGIN(a) ((unsigned char*)&(a))
#define UEND(a) ((unsigned char*)&((&(a))[1]))
-#define UVOIDBEGIN(a) ((void*)&(a))
-#define CVOIDBEGIN(a) ((const void*)&(a))
-#define UINTBEGIN(a) ((uint32_t*)&(a))
-#define CUINTBEGIN(a) ((const uint32_t*)&(a))
-
#ifndef THROW_WITH_STACKTRACE
#define THROW_WITH_STACKTRACE(exception) \
{ \