2010-08-29 12:58:15 -04:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2020-12-31 05:48:25 -03:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2014-10-30 21:43:19 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 10:02:28 -04:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2010-08-29 12:58:15 -04:00
|
|
|
|
2014-10-30 21:43:19 -03:00
|
|
|
/**
|
|
|
|
* Why base-58 instead of standard base-64 encoding?
|
|
|
|
* - Don't want 0OIl characters that look the same in some fonts and
|
2015-04-28 11:47:17 -03:00
|
|
|
* could be used to create visually identical looking data.
|
|
|
|
* - A string with non-alphanumeric characters is not as easily accepted as input.
|
2014-10-30 21:43:19 -03:00
|
|
|
* - E-mail usually won't line-break if there's no punctuation to break at.
|
2015-04-28 11:47:17 -03:00
|
|
|
* - Double-clicking selects the whole string as one word if it's all alphanumeric.
|
2014-10-30 21:43:19 -03:00
|
|
|
*/
|
2011-05-15 03:11:04 -04:00
|
|
|
#ifndef BITCOIN_BASE58_H
|
|
|
|
#define BITCOIN_BASE58_H
|
2010-08-29 12:58:15 -04:00
|
|
|
|
2020-08-09 20:52:37 -04:00
|
|
|
#include <span.h>
|
2018-09-25 02:00:36 -03:00
|
|
|
|
2013-04-13 02:13:08 -03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-06 23:30:04 -03:00
|
|
|
/**
|
2020-08-09 20:52:37 -04:00
|
|
|
* Encode a byte span as a base58-encoded string
|
2014-04-06 23:30:04 -03:00
|
|
|
*/
|
2020-08-09 20:52:37 -04:00
|
|
|
std::string EncodeBase58(Span<const unsigned char> input);
|
2010-08-29 12:58:15 -04:00
|
|
|
|
2014-04-06 23:30:04 -03:00
|
|
|
/**
|
2014-04-12 18:34:00 -03:00
|
|
|
* Decode a base58-encoded string (str) into a byte vector (vchRet).
|
|
|
|
* return true if decoding is successful.
|
2014-04-06 23:30:04 -03:00
|
|
|
*/
|
2020-11-26 06:05:59 -03:00
|
|
|
[[nodiscard]] bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
|
2010-08-29 12:58:15 -04:00
|
|
|
|
2014-04-06 23:30:04 -03:00
|
|
|
/**
|
2020-08-09 21:03:10 -04:00
|
|
|
* Encode a byte span into a base58-encoded string, including checksum
|
2014-04-06 23:30:04 -03:00
|
|
|
*/
|
2020-08-09 21:03:10 -04:00
|
|
|
std::string EncodeBase58Check(Span<const unsigned char> input);
|
2010-08-29 12:58:15 -04:00
|
|
|
|
2014-04-06 23:30:04 -03:00
|
|
|
/**
|
|
|
|
* Decode a base58-encoded string (str) that includes a checksum into a byte
|
|
|
|
* vector (vchRet), return true if decoding is successful
|
|
|
|
*/
|
2020-11-26 06:05:59 -03:00
|
|
|
[[nodiscard]] bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
|
2017-08-22 22:02:33 -03:00
|
|
|
|
2012-11-09 08:50:59 -03:00
|
|
|
#endif // BITCOIN_BASE58_H
|