Skip to content

Commit

Permalink
psbt: Use specified sighash or SIGHASH_DEFAULT when dummy signing
Browse files Browse the repository at this point in the history
When dummy signing for finalizing, use either the specificed sighash, or
SIGHASH_DEFAULT, rather than always SIGHASH_ALL.

For outputs, just use SIGHASH_DEFAULT.
  • Loading branch information
achow101 committed Nov 7, 2024
1 parent 0ce4c1c commit 3c63f56
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/psbt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransactio
// Construct a would-be spend of this output, to update sigdata with.
// Note that ProduceSignature is used to fill in metadata (not actual signatures),
// so provider does not need to provide any private keys (it can be a HidingSigningProvider).
MutableTransactionSignatureCreator creator(tx, /*input_idx=*/0, out.nValue, SIGHASH_ALL);
MutableTransactionSignatureCreator creator(tx, /*input_idx=*/0, out.nValue, SIGHASH_DEFAULT);
ProduceSignature(provider, creator, out.scriptPubKey, sigdata);

// Put redeem_script, witness_script, key paths, into PSBTOutput.
Expand Down Expand Up @@ -506,7 +506,8 @@ bool FinalizePSBT(PartiallySignedTransaction& psbtx)
bool complete = true;
const PrecomputedTransactionData txdata = PrecomputePSBTData(psbtx);
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, SIGHASH_ALL, nullptr, true);
int sighash_type = psbtx.inputs.at(i).sighash_type.value_or(SIGHASH_DEFAULT);
complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, sighash_type, nullptr, true);
}

return complete;
Expand Down

0 comments on commit 3c63f56

Please sign in to comment.