diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-01-13 15:09:36 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-03-05 20:22:47 +0000 |
commit | 7e9c7113afbed96cef80c327cc93e82000d6bb69 (patch) | |
tree | 963ec296135e8a7b9798112b3960447a21b1bf6f /src/compressor.h | |
parent | 4a7fd7a7124f84e010b01d0769ef0572bf031ee8 (diff) |
compressor: Make the domain of CompressAmount(...) explicit
Diffstat (limited to 'src/compressor.h')
-rw-r--r-- | src/compressor.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compressor.h b/src/compressor.h index c1eda503c8..acb34da4a0 100644 --- a/src/compressor.h +++ b/src/compressor.h @@ -19,7 +19,17 @@ bool CompressScript(const CScript& script, std::vector<unsigned char> &out); unsigned int GetSpecialScriptSize(unsigned int nSize); bool DecompressScript(CScript& script, unsigned int nSize, const std::vector<unsigned char> &out); +/** + * Compress amount. + * + * nAmount is of type uint64_t and thus cannot be negative. If you're passing in + * a CAmount (int64_t), make sure to properly handle the case where the amount + * is negative before calling CompressAmount(...). + * + * @pre Function defined only for 0 <= nAmount <= MAX_MONEY. + */ uint64_t CompressAmount(uint64_t nAmount); + uint64_t DecompressAmount(uint64_t nAmount); /** Compact serializer for scripts. |