code: public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, String base58)
              throws AddressFormatException, AddressFormatException.WrongNetwork {
          byte[] versionAndDataBytes = Base58.decodeChecked(base58);
          int version = versionAndDataBytes[0] & 0xFF;
          byte[] bytes = Arrays.copyOfRange(versionAndDataBytes, 1, versionAndDataBytes.length);
          if (params == null) {
              for (NetworkParameters p : Networks.get())
                  if (version == p.getDumpedPrivateKeyHeader())
                      return new DumpedPrivateKey(p, bytes);
              throw new AddressFormatException.InvalidPrefix("No network found for version " + version);
          } else {
              if (version == params.getDumpedPrivateKeyHeader())
                  return new DumpedPrivateKey(params, bytes);
              throw new AddressFormatException.WrongNetwork(version);
          }
      }
docs: Construct a private key from its Base58 representation.
  @param params
  The expected NetworkParameters or null if you don't want validation.
  @param base58
  The textual form of the private key.
  @throws AddressFormatException
  if the given base58 doesn't parse or the checksum is invalid
  @throws AddressFormatException.WrongNetwork
  if the given private key is valid but for a different chain (eg testnet vs mainnet)