mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 09:36:44 +00:00
add support for creating output descriptors without rendering xpubs
This commit is contained in:
parent
b487396417
commit
d48054ac6b
2 changed files with 19 additions and 13 deletions
|
@ -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,6 +565,7 @@ public class OutputDescriptor {
|
|||
keyBuilder.append("]");
|
||||
}
|
||||
|
||||
if(addKey) {
|
||||
if(pubKey != null) {
|
||||
keyBuilder.append(pubKey.toString());
|
||||
}
|
||||
|
@ -573,6 +578,7 @@ public class OutputDescriptor {
|
|||
|
||||
keyBuilder.append(childDerivation);
|
||||
}
|
||||
}
|
||||
|
||||
return keyBuilder.toString();
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue