@@ -84,21 +84,21 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_
8484 return true ;
8585}
8686
87- std::string EncodeBase58 (const unsigned char * pbegin, const unsigned char * pend )
87+ std::string EncodeBase58 (Span< const unsigned char > input )
8888{
8989 // Skip & count leading zeroes.
9090 int zeroes = 0 ;
9191 int length = 0 ;
92- while (pbegin != pend && *pbegin == 0 ) {
93- pbegin++ ;
92+ while (input. size () > 0 && input[ 0 ] == 0 ) {
93+ input = input. subspan ( 1 ) ;
9494 zeroes++;
9595 }
9696 // Allocate enough space in big-endian base58 representation.
97- int size = (pend - pbegin ) * 138 / 100 + 1 ; // log(256) / log(58), rounded up.
97+ int size = input. size ( ) * 138 / 100 + 1 ; // log(256) / log(58), rounded up.
9898 std::vector<unsigned char > b58 (size);
9999 // Process the bytes.
100- while (pbegin != pend ) {
101- int carry = *pbegin ;
100+ while (input. size () > 0 ) {
101+ int carry = input[ 0 ] ;
102102 int i = 0 ;
103103 // Apply "b58 = b58 * 256 + ch".
104104 for (std::vector<unsigned char >::reverse_iterator it = b58.rbegin (); (carry != 0 || i < length) && (it != b58.rend ()); it++, i++) {
@@ -109,7 +109,7 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
109109
110110 assert (carry == 0 );
111111 length = i;
112- pbegin++ ;
112+ input = input. subspan ( 1 ) ;
113113 }
114114 // Skip leading zeroes in base58 result.
115115 std::vector<unsigned char >::iterator it = b58.begin () + (size - length);
@@ -124,11 +124,6 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
124124 return str;
125125}
126126
127- std::string EncodeBase58 (const std::vector<unsigned char >& vch)
128- {
129- return EncodeBase58 (vch.data (), vch.data () + vch.size ());
130- }
131-
132127bool DecodeBase58 (const std::string& str, std::vector<unsigned char >& vchRet, int max_ret_len)
133128{
134129 if (!ValidAsCString (str)) {
0 commit comments