2010-08-29 18:58:15 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2020-12-31 09:48:25 +01:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2014-10-31 01:43:19 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-10-31 01:43:19 +01: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 16:47:17 +02: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-31 01:43:19 +01:00
|
|
|
* - E-mail usually won't line-break if there's no punctuation to break at.
|
2015-04-28 16:47:17 +02:00
|
|
|
* - Double-clicking selects the whole string as one word if it's all alphanumeric.
|
2014-10-31 01:43:19 +01:00
|
|
|
*/
|
2011-05-15 09:11:04 +02:00
|
|
|
#ifndef BITCOIN_BASE58_H
|
|
|
|
#define BITCOIN_BASE58_H
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2018-09-25 07:00:36 +02:00
|
|
|
#include <attributes.h>
|
2020-08-10 02:52:37 +02:00
|
|
|
#include <span.h>
|
2018-09-25 07:00:36 +02:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
2020-08-10 02:52:37 +02:00
|
|
|
* Encode a byte span as a base58-encoded string
|
2014-04-07 04:30:04 +02:00
|
|
|
*/
|
2020-08-10 02:52:37 +02:00
|
|
|
std::string EncodeBase58(Span<const unsigned char> input);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
2014-04-12 23:34:00 +02:00
|
|
|
* Decode a base58-encoded string (str) into a byte vector (vchRet).
|
|
|
|
* return true if decoding is successful.
|
2014-04-07 04:30:04 +02:00
|
|
|
*/
|
2020-11-26 10:05:59 +01:00
|
|
|
[[nodiscard]] bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02:00
|
|
|
/**
|
2020-08-10 03:03:10 +02:00
|
|
|
* Encode a byte span into a base58-encoded string, including checksum
|
2014-04-07 04:30:04 +02:00
|
|
|
*/
|
2020-08-10 03:03:10 +02:00
|
|
|
std::string EncodeBase58Check(Span<const unsigned char> input);
|
2010-08-29 18:58:15 +02:00
|
|
|
|
2014-04-07 04:30:04 +02: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 10:05:59 +01:00
|
|
|
[[nodiscard]] bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len);
|
2017-08-23 03:02:33 +02:00
|
|
|
|
2012-11-09 12:50:59 +01:00
|
|
|
#endif // BITCOIN_BASE58_H
|