diff --git a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java index c5d17d7..cf4defe 100644 --- a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java +++ b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java @@ -479,6 +479,10 @@ public class OutputDescriptor { } public String toString(boolean addKeyOrigin, boolean addChecksum) { + return toString(addKeyOrigin, true, addChecksum); + } + + public String toString(boolean addKeyOrigin, boolean addKey, boolean addChecksum) { StringBuilder builder = new StringBuilder(); builder.append(scriptType.getDescriptor()); @@ -487,14 +491,14 @@ public class OutputDescriptor { StringJoiner joiner = new StringJoiner(","); joiner.add(Integer.toString(multisigThreshold)); for(ExtendedKey pubKey : sortExtendedPubKeys(extendedPublicKeys.keySet())) { - String extKeyString = toString(pubKey, addKeyOrigin); + String extKeyString = toString(pubKey, addKeyOrigin, addKey); joiner.add(extKeyString); } builder.append(joiner.toString()); builder.append(ScriptType.MULTISIG.getCloseDescriptor()); } else { ExtendedKey extendedPublicKey = getSingletonExtendedPublicKey(); - builder.append(toString(extendedPublicKey, addKeyOrigin)); + builder.append(toString(extendedPublicKey, addKeyOrigin, addKey)); } builder.append(scriptType.getCloseDescriptor()); @@ -548,7 +552,7 @@ public class OutputDescriptor { } } - private String toString(ExtendedKey pubKey, boolean addKeyOrigin) { + private String toString(ExtendedKey pubKey, boolean addKeyOrigin, boolean addKey) { StringBuilder keyBuilder = new StringBuilder(); KeyDerivation keyDerivation = extendedPublicKeys.get(pubKey); if(keyDerivation != null && keyDerivation.getDerivationPath() != null && addKeyOrigin) { @@ -561,17 +565,19 @@ public class OutputDescriptor { keyBuilder.append("]"); } - if(pubKey != null) { - keyBuilder.append(pubKey.toString()); - } - - String childDerivation = mapChildrenDerivations.get(pubKey); - if(childDerivation != null) { - if(!childDerivation.startsWith("/")) { - keyBuilder.append("/"); + if(addKey) { + if(pubKey != null) { + keyBuilder.append(pubKey.toString()); } - keyBuilder.append(childDerivation); + String childDerivation = mapChildrenDerivations.get(pubKey); + if(childDerivation != null) { + if(!childDerivation.startsWith("/")) { + keyBuilder.append("/"); + } + + keyBuilder.append(childDerivation); + } } return keyBuilder.toString(); diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java index 4abf6c5..fcb4234 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java @@ -4,7 +4,7 @@ import java.util.Locale; public enum WalletModel { SEED, SPARROW, BITCOIN_CORE, ELECTRUM, TREZOR_1, TREZOR_T, COLDCARD, LEDGER_NANO_S, LEDGER_NANO_X, DIGITALBITBOX_01, KEEPKEY, SPECTER_DESKTOP, COBO_VAULT, - BITBOX_02, SPECTER_DIY, PASSPORT, BLUE_WALLET, KEYSTONE, SEEDSIGNER, CARAVAN, GORDIAN_SEED_TOOL, JADE, LEDGER_NANO_S_PLUS, EPS, TAPSIGNER, SATSCARD; + BITBOX_02, SPECTER_DIY, PASSPORT, BLUE_WALLET, KEYSTONE, SEEDSIGNER, CARAVAN, GORDIAN_SEED_TOOL, JADE, LEDGER_NANO_S_PLUS, EPS, TAPSIGNER, SATSCARD, LABELS; public static WalletModel getModel(String model) { return valueOf(model.toUpperCase(Locale.ROOT));