mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
detect if output descriptor represents a cosigner
This commit is contained in:
parent
60e989b946
commit
6ac593f161
1 changed files with 6 additions and 2 deletions
|
@ -132,6 +132,10 @@ public class OutputDescriptor {
|
||||||
return extendedPublicKeys.size() > 1;
|
return extendedPublicKeys.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCosigner() {
|
||||||
|
return !isMultisig() && scriptType.isAllowed(PolicyType.MULTI);
|
||||||
|
}
|
||||||
|
|
||||||
public ExtendedKey getSingletonExtendedPublicKey() {
|
public ExtendedKey getSingletonExtendedPublicKey() {
|
||||||
if(isMultisig()) {
|
if(isMultisig()) {
|
||||||
throw new IllegalStateException("Output descriptor contains multiple public keys but singleton requested");
|
throw new IllegalStateException("Output descriptor contains multiple public keys but singleton requested");
|
||||||
|
@ -233,7 +237,7 @@ public class OutputDescriptor {
|
||||||
|
|
||||||
public Wallet toWallet() {
|
public Wallet toWallet() {
|
||||||
Wallet wallet = new Wallet();
|
Wallet wallet = new Wallet();
|
||||||
wallet.setPolicyType(isMultisig() ? PolicyType.MULTI : PolicyType.SINGLE);
|
wallet.setPolicyType(isMultisig() || isCosigner() ? PolicyType.MULTI : PolicyType.SINGLE);
|
||||||
wallet.setScriptType(scriptType);
|
wallet.setScriptType(scriptType);
|
||||||
|
|
||||||
for(Map.Entry<ExtendedKey,KeyDerivation> extKeyEntry : extendedPublicKeys.entrySet()) {
|
for(Map.Entry<ExtendedKey,KeyDerivation> extKeyEntry : extendedPublicKeys.entrySet()) {
|
||||||
|
@ -469,7 +473,7 @@ public class OutputDescriptor {
|
||||||
|
|
||||||
private List<ExtendedKey> sortExtendedPubKeys(Collection<ExtendedKey> keys) {
|
private List<ExtendedKey> sortExtendedPubKeys(Collection<ExtendedKey> keys) {
|
||||||
List<ExtendedKey> sortedKeys = new ArrayList<>(keys);
|
List<ExtendedKey> sortedKeys = new ArrayList<>(keys);
|
||||||
if(mapChildrenDerivations == null || mapChildrenDerivations.isEmpty()) {
|
if(mapChildrenDerivations == null || mapChildrenDerivations.isEmpty() || mapChildrenDerivations.containsKey(null)) {
|
||||||
return sortedKeys;
|
return sortedKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue