allow hardened character selection when writing key

This commit is contained in:
Craig Raw 2024-11-15 16:31:50 +02:00
parent 96df6284e1
commit efc9d9d554

View file

@ -623,12 +623,17 @@ public class OutputDescriptor {
} }
public static String writeKey(ExtendedKey pubKey, KeyDerivation keyDerivation, String childDerivation, boolean addKeyOrigin, boolean addKey) { public static String writeKey(ExtendedKey pubKey, KeyDerivation keyDerivation, String childDerivation, boolean addKeyOrigin, boolean addKey) {
return writeKey(pubKey, keyDerivation, childDerivation, addKeyOrigin, addKey, false);
}
public static String writeKey(ExtendedKey pubKey, KeyDerivation keyDerivation, String childDerivation, boolean addKeyOrigin, boolean addKey, boolean useApostrophes) {
StringBuilder keyBuilder = new StringBuilder(); StringBuilder keyBuilder = new StringBuilder();
if(keyDerivation != null && keyDerivation.getMasterFingerprint() != null && keyDerivation.getMasterFingerprint().length() == 8 && Utils.isHex(keyDerivation.getMasterFingerprint()) && addKeyOrigin) { if(keyDerivation != null && keyDerivation.getMasterFingerprint() != null && keyDerivation.getMasterFingerprint().length() == 8 && Utils.isHex(keyDerivation.getMasterFingerprint()) && addKeyOrigin) {
keyBuilder.append("["); keyBuilder.append("[");
keyBuilder.append(keyDerivation.getMasterFingerprint()); keyBuilder.append(keyDerivation.getMasterFingerprint());
if(!keyDerivation.getDerivation().isEmpty()) { if(!keyDerivation.getDerivation().isEmpty()) {
keyBuilder.append(keyDerivation.getDerivationPath().replaceFirst("^m?/", "/").replace('\'', 'h')); String path = keyDerivation.getDerivationPath().replaceFirst("^m?/", "/");
keyBuilder.append(useApostrophes ? path : path.replace('\'', 'h'));
} }
keyBuilder.append("]"); keyBuilder.append("]");
} }