Skip to content

Commit 8da5ab6

Browse files
committed
psbt: Use specified sighash or SIGHASH_DEFAULT when dummy signing
When dummy signing for finalizing, use either the specificed sighash, or SIGHASH_DEFAULT, rather than always SIGHASH_ALL. For outputs, just use SIGHASH_DEFAULT.
1 parent abb8228 commit 8da5ab6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/psbt.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransactio
348348
// Construct a would-be spend of this output, to update sigdata with.
349349
// Note that ProduceSignature is used to fill in metadata (not actual signatures),
350350
// so provider does not need to provide any private keys (it can be a HidingSigningProvider).
351-
MutableTransactionSignatureCreator creator(tx, /*input_idx=*/0, out.nValue, SIGHASH_ALL);
351+
MutableTransactionSignatureCreator creator(tx, /*input_idx=*/0, out.nValue, SIGHASH_DEFAULT);
352352
ProduceSignature(provider, creator, out.scriptPubKey, sigdata);
353353

354354
// Put redeem_script, witness_script, key paths, into PSBTOutput.
@@ -486,7 +486,8 @@ bool FinalizePSBT(PartiallySignedTransaction& psbtx)
486486
bool complete = true;
487487
const PrecomputedTransactionData txdata = PrecomputePSBTData(psbtx);
488488
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
489-
complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, SIGHASH_ALL, nullptr, true);
489+
int sighash_type = psbtx.inputs.at(i).sighash_type.value_or(SIGHASH_DEFAULT);
490+
complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, sighash_type, nullptr, true);
490491
}
491492

492493
return complete;

0 commit comments

Comments
 (0)