diff --git a/src/main/java/com/sparrowwallet/drongo/Network.java b/src/main/java/com/sparrowwallet/drongo/Network.java index 646de38..4175ac5 100644 --- a/src/main/java/com/sparrowwallet/drongo/Network.java +++ b/src/main/java/com/sparrowwallet/drongo/Network.java @@ -38,6 +38,10 @@ public enum Network { return name; } + public String toDisplayString() { + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + public int getP2PKHAddressHeader() { return p2pkhAddressHeader; } diff --git a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java index cb4dc66..2e3f416 100644 --- a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java +++ b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java @@ -254,6 +254,27 @@ public class OutputDescriptor { return wallet; } + public Wallet toKeystoreWallet(String masterFingerprint) { + Wallet wallet = new Wallet(); + if(isMultisig()) { + throw new IllegalStateException("Multisig output descriptors are unsupported."); + } + + ExtendedKey extendedKey = getSingletonExtendedPublicKey(); + if(masterFingerprint == null) { + masterFingerprint = getKeyDerivation(extendedKey).getMasterFingerprint(); + } + + wallet.setScriptType(getScriptType()); + Keystore keystore = new Keystore(); + keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, KeyDerivation.writePath(getKeyDerivation(extendedKey).getDerivation()))); + keystore.setExtendedPublicKey(extendedKey); + wallet.getKeystores().add(keystore); + wallet.setDefaultPolicy(Policy.getPolicy(isCosigner() ? PolicyType.MULTI : PolicyType.SINGLE, wallet.getScriptType(), wallet.getKeystores(), 1)); + + return wallet; + } + public static OutputDescriptor getOutputDescriptor(Wallet wallet) { return getOutputDescriptor(wallet, null); } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java index fa74ccf..e9b5379 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java @@ -1,7 +1,7 @@ package com.sparrowwallet.drongo.wallet; 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, SEED_TOOL; + 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; public static WalletModel getModel(String model) { return valueOf(model.toUpperCase()); @@ -40,7 +40,7 @@ public enum WalletModel { return "bluewallet"; } - if(this == SEED_TOOL) { + if(this == GORDIAN_SEED_TOOL) { return "seedtool"; } @@ -48,7 +48,7 @@ public enum WalletModel { } public boolean alwaysIncludeNonWitnessUtxo() { - if(this == COLDCARD || this == COBO_VAULT || this == PASSPORT || this == KEYSTONE || this == SEED_TOOL) { + if(this == COLDCARD || this == COBO_VAULT || this == PASSPORT || this == KEYSTONE || this == GORDIAN_SEED_TOOL) { return false; }