tron-scanner-app/src/main/kotlin/co/nilin/opex/chainscanner/tron/utils/Base58Check.java
// Converts the given Base58Check string to a byte array, without checking or removing the trailing 4-byte checksum.
Converts the given Base58Check string to a byte array, without checking or removing the trailing 4-byte checksum.
Converts the given Base58Check string to a byte array without checking or removing the trailing 4 - byte checksum .
static byte[] base58ToRawBytes(String s) {
        BigInteger num = BigInteger.ZERO;
        for (int i = 0; i < s.length(); i++) {
            num = num.multiply(ALPHABET_SIZE);
            int digit = ALPHABET.indexOf(s.charAt(i));
            if (digit == -1)
                throw new IllegalArgumentException("Invalid character for Base58Check");
            num = num.add(BigInteger.valueOf(digit));
        }
        byte[] b = num.toByteArray();
        if (b[0] == 0)
            b = Arrays.copyOfRange(b, 1, b.length);
        try {
            ByteArrayOutputStream buf = new ByteArrayOutputStream();
            for (int i = 0; i < s.length() && s.charAt(i) == ALPHABET.charAt(0); i++) buf.write(0);
            buf.write(b);
            return buf.toByteArray();
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    }
static byte [ ] base58ToRawBytes ( String s ) { BigInteger num = BigInteger . ZERO ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { num = num . multiply ( ALPHABET_SIZE ) ; int digit = ALPHABET . indexOf ( s . charAt ( i ) ) ; if ( digit == - 1 ) throw new IllegalArgumentException ( "Invalid character for Base58Check" ) ; num = num . add ( BigInteger . valueOf ( digit ) ) ; } byte [ ] b = num . toByteArray ( ) ; if ( b [ 0 ] == 0 ) b = Arrays . copyOfRange ( b , 1 , b . length ) ; try { ByteArrayOutputStream buf = new ByteArrayOutputStream ( ) ; for ( int i = 0 ; i < s . length ( ) && s . charAt ( i ) == ALPHABET . charAt ( 0 ) ; i ++ ) buf . write ( 0 ) ; buf . write ( b ) ; return buf . toByteArray ( ) ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } }
Converts the given Base58Check string to a byte array, without checking or removing the trailing 4-byte checksum.
Converts the given Base58Check string to a byte array without checking or removing the trailing 4 - byte checksum .
// Parse base-58 string // Strip possible leading zero due to mandatory sign bit // Convert leading '1' characters to leading 0-value bytes