Changeset View
Changeset View
Standalone View
Standalone View
src/base58.h
Show All 11 Lines | |||||
* - E-mail usually won't line-break if there's no punctuation to break at. | * - E-mail usually won't line-break if there's no punctuation to break at. | ||||
* - Double-clicking selects the whole string as one word if it's all | * - Double-clicking selects the whole string as one word if it's all | ||||
* alphanumeric. | * alphanumeric. | ||||
*/ | */ | ||||
#ifndef BITCOIN_BASE58_H | #ifndef BITCOIN_BASE58_H | ||||
#define BITCOIN_BASE58_H | #define BITCOIN_BASE58_H | ||||
#include <attributes.h> | #include <attributes.h> | ||||
#include <span.h> | |||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
/** | /** | ||||
* Encode a byte sequence as a base58-encoded string. | * Encode a byte span as a base58-encoded string | ||||
* pbegin and pend cannot be nullptr, unless both are. | |||||
*/ | */ | ||||
std::string EncodeBase58(const uint8_t *pbegin, const uint8_t *pend); | std::string EncodeBase58(Span<const uint8_t> input); | ||||
/** | |||||
* Encode a byte vector as a base58-encoded string | |||||
*/ | |||||
std::string EncodeBase58(const std::vector<uint8_t> &vch); | |||||
/** | /** | ||||
* Decode a base58-encoded string (psz) into a byte vector (vchRet). | * Decode a base58-encoded string (psz) into a byte vector (vchRet). | ||||
* return true if decoding is successful. | * return true if decoding is successful. | ||||
* psz cannot be nullptr. | * psz cannot be nullptr. | ||||
*/ | */ | ||||
NODISCARD bool DecodeBase58(const char *psz, std::vector<uint8_t> &vchRet, | NODISCARD bool DecodeBase58(const char *psz, std::vector<uint8_t> &vchRet, | ||||
int max_ret_len); | int max_ret_len); | ||||
/** | /** | ||||
* Decode a base58-encoded string (str) into a byte vector (vchRet). | * Decode a base58-encoded string (str) into a byte vector (vchRet). | ||||
* return true if decoding is successful. | * return true if decoding is successful. | ||||
*/ | */ | ||||
NODISCARD bool DecodeBase58(const std::string &str, | NODISCARD bool DecodeBase58(const std::string &str, | ||||
std::vector<uint8_t> &vchRet, int max_ret_len); | std::vector<uint8_t> &vchRet, int max_ret_len); | ||||
/** | /** | ||||
* Encode a byte vector into a base58-encoded string, including checksum | * Encode a byte span into a base58-encoded string, including checksum | ||||
*/ | */ | ||||
std::string EncodeBase58Check(const std::vector<uint8_t> &vchIn); | std::string EncodeBase58Check(Span<const uint8_t> input); | ||||
/** | /** | ||||
* Decode a base58-encoded string (psz) that includes a checksum into a byte | * Decode a base58-encoded string (psz) that includes a checksum into a byte | ||||
* vector (vchRet), return true if decoding is successful | * vector (vchRet), return true if decoding is successful | ||||
*/ | */ | ||||
NODISCARD bool DecodeBase58Check(const char *psz, std::vector<uint8_t> &vchRet, | NODISCARD bool DecodeBase58Check(const char *psz, std::vector<uint8_t> &vchRet, | ||||
int max_ret_len); | int max_ret_len); | ||||
/** | /** | ||||
* Decode a base58-encoded string (str) that includes a checksum into a byte | * Decode a base58-encoded string (str) that includes a checksum into a byte | ||||
* vector (vchRet), return true if decoding is successful | * vector (vchRet), return true if decoding is successful | ||||
*/ | */ | ||||
NODISCARD bool DecodeBase58Check(const std::string &str, | NODISCARD bool DecodeBase58Check(const std::string &str, | ||||
std::vector<uint8_t> &vchRet, int max_ret_len); | std::vector<uint8_t> &vchRet, int max_ret_len); | ||||
#endif // BITCOIN_BASE58_H | #endif // BITCOIN_BASE58_H |