mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 03:33:32 +01:00
Abstract out UpdatePSBTOutput from FillPSBT
This commit is contained in:
19
src/psbt.cpp
19
src/psbt.cpp
@@ -215,6 +215,25 @@ bool PSBTInputSigned(const PSBTInput& input)
|
||||
return !input.final_script_sig.empty() || !input.final_script_witness.IsNull();
|
||||
}
|
||||
|
||||
void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index)
|
||||
{
|
||||
const CTxOut& out = psbt.tx->vout.at(index);
|
||||
PSBTOutput& psbt_out = psbt.outputs.at(index);
|
||||
|
||||
// Fill a SignatureData with output info
|
||||
SignatureData sigdata;
|
||||
psbt_out.FillSignatureData(sigdata);
|
||||
|
||||
// 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(psbt.tx.get_ptr(), /* index */ 0, out.nValue, SIGHASH_ALL);
|
||||
ProduceSignature(provider, creator, out.scriptPubKey, sigdata);
|
||||
|
||||
// Put redeem_script, witness_script, key paths, into PSBTOutput.
|
||||
psbt_out.FromSignatureData(sigdata);
|
||||
}
|
||||
|
||||
bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, int sighash, SignatureData* out_sigdata, bool use_dummy)
|
||||
{
|
||||
PSBTInput& input = psbt.inputs.at(index);
|
||||
|
||||
Reference in New Issue
Block a user