mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 09:36:44 +00:00
limit signatures in multisig scriptsig to threshold
This commit is contained in:
parent
f3ee296280
commit
6b1a0bba95
1 changed files with 3 additions and 3 deletions
|
@ -413,7 +413,7 @@ public enum ScriptType {
|
||||||
throw new ProtocolException("Provided scriptPubKey is not a " + getName() + " script");
|
throw new ProtocolException("Provided scriptPubKey is not a " + getName() + " script");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TransactionSignature> signatures = pubKeySignatures.values().stream().filter(Objects::nonNull).collect(Collectors.toList());
|
List<TransactionSignature> signatures = pubKeySignatures.values().stream().filter(Objects::nonNull).limit(threshold).collect(Collectors.toList());
|
||||||
if(signatures.size() < threshold) {
|
if(signatures.size() < threshold) {
|
||||||
throw new ProtocolException("Only " + signatures.size() + " signatures provided to meet a multisig threshold of " + threshold);
|
throw new ProtocolException("Only " + signatures.size() + " signatures provided to meet a multisig threshold of " + threshold);
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ public enum ScriptType {
|
||||||
public TransactionInput addMultisigSpendingInput(Transaction transaction, TransactionOutput prevOutput, int threshold, Map<ECKey, TransactionSignature> pubKeySignatures) {
|
public TransactionInput addMultisigSpendingInput(Transaction transaction, TransactionOutput prevOutput, int threshold, Map<ECKey, TransactionSignature> pubKeySignatures) {
|
||||||
Script scriptSig = getMultisigScriptSig(prevOutput.getScript(), threshold, pubKeySignatures);
|
Script scriptSig = getMultisigScriptSig(prevOutput.getScript(), threshold, pubKeySignatures);
|
||||||
Script witnessScript = MULTISIG.getOutputScript(threshold, pubKeySignatures.keySet());
|
Script witnessScript = MULTISIG.getOutputScript(threshold, pubKeySignatures.keySet());
|
||||||
TransactionWitness witness = new TransactionWitness(transaction, pubKeySignatures.values().stream().filter(Objects::nonNull).collect(Collectors.toList()), witnessScript);
|
TransactionWitness witness = new TransactionWitness(transaction, pubKeySignatures.values().stream().filter(Objects::nonNull).limit(threshold).collect(Collectors.toList()), witnessScript);
|
||||||
return transaction.addInput(prevOutput.getHash(), prevOutput.getIndex(), scriptSig, witness);
|
return transaction.addInput(prevOutput.getHash(), prevOutput.getIndex(), scriptSig, witness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,7 +1001,7 @@ public enum ScriptType {
|
||||||
public TransactionInput addMultisigSpendingInput(Transaction transaction, TransactionOutput prevOutput, int threshold, Map<ECKey, TransactionSignature> pubKeySignatures) {
|
public TransactionInput addMultisigSpendingInput(Transaction transaction, TransactionOutput prevOutput, int threshold, Map<ECKey, TransactionSignature> pubKeySignatures) {
|
||||||
Script scriptSig = getMultisigScriptSig(prevOutput.getScript(), threshold, pubKeySignatures);
|
Script scriptSig = getMultisigScriptSig(prevOutput.getScript(), threshold, pubKeySignatures);
|
||||||
Script witnessScript = MULTISIG.getOutputScript(threshold, pubKeySignatures.keySet());
|
Script witnessScript = MULTISIG.getOutputScript(threshold, pubKeySignatures.keySet());
|
||||||
TransactionWitness witness = new TransactionWitness(transaction, pubKeySignatures.values().stream().filter(Objects::nonNull).collect(Collectors.toList()), witnessScript);
|
TransactionWitness witness = new TransactionWitness(transaction, pubKeySignatures.values().stream().filter(Objects::nonNull).limit(threshold).collect(Collectors.toList()), witnessScript);
|
||||||
return transaction.addInput(prevOutput.getHash(), prevOutput.getIndex(), scriptSig, witness);
|
return transaction.addInput(prevOutput.getHash(), prevOutput.getIndex(), scriptSig, witness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue