guard against incorrect sighash types when signing txs with sp outputs

This commit is contained in:
Craig Raw 2026-05-15 09:34:43 +02:00
parent e4b63fbd19
commit 7df781c77c

View File

@ -1774,6 +1774,16 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
}
public void sign(PSBT psbt) throws MnemonicException {
if(psbt.getPsbtOutputs().stream().anyMatch(o -> o.getSilentPaymentAddress() != null)) {
List<PSBTInput> psbtInputs = psbt.getPsbtInputs();
for(int i = 0; i < psbtInputs.size(); i++) {
SigHash inputSigHash = psbtInputs.get(i).getSigHash();
if(inputSigHash != null && inputSigHash != SigHash.ALL && inputSigHash != SigHash.DEFAULT) {
throw new IllegalStateException("Silent payment outputs require SIGHASH_ALL/DEFAULT signatures. Input at index " + i + " has sighash type: " + inputSigHash);
}
}
}
sign(getSigningNodes(psbt));
}