/** * Deserialize a base-58-encoded HD Key. * * @param parent The parent node in the given key's deterministic hierarchy. */ public static DeterministicKey deserializeB58( @Nullable DeterministicKey parent, String base58, NetworkParameters params) { try { return deserialize(params, Base58.decodeChecked(base58), parent); } catch (AddressFormatException e) { throw new IllegalArgumentException(e); } }
/** * Attempts to parse the given string as arbitrary-length hex or base58 and then return the * results, or null if neither parse was successful. */ public static byte[] parseAsHexOrBase58(String data) { try { return HEX.decode(data); } catch (Exception e) { // Didn't decode as hex, try base58. try { return Base58.decodeChecked(data); } catch (AddressFormatException e1) { return null; } } }