verify segwit psbt partial signatures with only non-witness utxo provided

This commit is contained in:
Craig Raw 2021-04-24 08:55:33 +02:00
parent 0a43f9f6a8
commit db05e09fe5

View file

@ -555,12 +555,8 @@ public class PSBTInput {
Sha256Hash hash; Sha256Hash hash;
ScriptType scriptType = getScriptType(); ScriptType scriptType = getScriptType();
if(getWitnessUtxo() == null && Arrays.asList(WITNESS_TYPES).contains(scriptType)) { if(Arrays.asList(WITNESS_TYPES).contains(scriptType)) {
throw new IllegalStateException("Trying to get signature hash for " + scriptType + " script without a PSBT witness UTXO"); long prevValue = getUtxo().getValue();
}
if(getWitnessUtxo() != null) {
long prevValue = getWitnessUtxo().getValue();
hash = transaction.hashForWitnessSignature(index, connectedScript, prevValue, localSigHash); hash = transaction.hashForWitnessSignature(index, connectedScript, prevValue, localSigHash);
} else { } else {
hash = transaction.hashForLegacySignature(index, connectedScript, localSigHash); hash = transaction.hashForLegacySignature(index, connectedScript, localSigHash);