mirror of
https://github.com/sparrowwallet/drongo.git
synced 2025-11-05 11:56:38 +00:00
handle invalid/incomplete output descriptors better
This commit is contained in:
parent
5e281982cb
commit
2650dafa66
1 changed files with 12 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ import com.sparrowwallet.drongo.crypto.DeterministicKey;
|
||||||
import com.sparrowwallet.drongo.crypto.ECKey;
|
import com.sparrowwallet.drongo.crypto.ECKey;
|
||||||
import com.sparrowwallet.drongo.policy.Policy;
|
import com.sparrowwallet.drongo.policy.Policy;
|
||||||
import com.sparrowwallet.drongo.policy.PolicyType;
|
import com.sparrowwallet.drongo.policy.PolicyType;
|
||||||
|
import com.sparrowwallet.drongo.protocol.ProtocolException;
|
||||||
import com.sparrowwallet.drongo.protocol.Script;
|
import com.sparrowwallet.drongo.protocol.Script;
|
||||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||||
import com.sparrowwallet.drongo.wallet.Keystore;
|
import com.sparrowwallet.drongo.wallet.Keystore;
|
||||||
|
|
@ -323,9 +324,13 @@ public class OutputDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyDerivation keyDerivation = new KeyDerivation(masterFingerprint, keyDerivationPath);
|
KeyDerivation keyDerivation = new KeyDerivation(masterFingerprint, keyDerivationPath);
|
||||||
ExtendedKey extendedPublicKey = ExtendedKey.fromDescriptor(extPubKey);
|
try {
|
||||||
keyDerivationMap.put(extendedPublicKey, keyDerivation);
|
ExtendedKey extendedPublicKey = ExtendedKey.fromDescriptor(extPubKey);
|
||||||
keyChildDerivationMap.put(extendedPublicKey, childDerivationPath);
|
keyDerivationMap.put(extendedPublicKey, keyDerivation);
|
||||||
|
keyChildDerivationMap.put(extendedPublicKey, childDerivationPath);
|
||||||
|
} catch(ProtocolException e) {
|
||||||
|
throw new ProtocolException("Invalid xPub: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OutputDescriptor(scriptType, multisigThreshold, keyDerivationMap, keyChildDerivationMap);
|
return new OutputDescriptor(scriptType, multisigThreshold, keyDerivationMap, keyChildDerivationMap);
|
||||||
|
|
@ -440,7 +445,10 @@ public class OutputDescriptor {
|
||||||
keyBuilder.append("]");
|
keyBuilder.append("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
keyBuilder.append(pubKey.toString());
|
if(pubKey != null) {
|
||||||
|
keyBuilder.append(pubKey.toString());
|
||||||
|
}
|
||||||
|
|
||||||
String childDerivation = mapChildrenDerivations.get(pubKey);
|
String childDerivation = mapChildrenDerivations.get(pubKey);
|
||||||
if(childDerivation != null) {
|
if(childDerivation != null) {
|
||||||
if(!childDerivation.startsWith("/")) {
|
if(!childDerivation.startsWith("/")) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue