mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
rename gordian seed tool, support retrieving a keystore from an output descriptor more generally
This commit is contained in:
parent
c1f6a1245e
commit
083288061f
3 changed files with 28 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue