Changeset View
Changeset View
Standalone View
Standalone View
src/util/message.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
bool MessageSign(const CKey &privkey, const std::string &message, | bool MessageSign(const CKey &privkey, const std::string &message, | ||||
std::string &signature) { | std::string &signature) { | ||||
std::vector<uint8_t> signature_bytes; | std::vector<uint8_t> signature_bytes; | ||||
if (!privkey.SignCompact(MessageHash(message), signature_bytes)) { | if (!privkey.SignCompact(MessageHash(message), signature_bytes)) { | ||||
return false; | return false; | ||||
} | } | ||||
signature = EncodeBase64(signature_bytes.data(), signature_bytes.size()); | signature = EncodeBase64(signature_bytes); | ||||
return true; | return true; | ||||
} | } | ||||
uint256 MessageHash(const std::string &message) { | uint256 MessageHash(const std::string &message) { | ||||
CHashWriter hasher(SER_GETHASH, 0); | CHashWriter hasher(SER_GETHASH, 0); | ||||
hasher << MESSAGE_MAGIC << message; | hasher << MESSAGE_MAGIC << message; | ||||
Show All 15 Lines |