diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2019-02-16 15:49:36 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2019-05-10 14:31:22 -0700 |
commit | 3135c1a2d2e2fb31bc362c848bd2456d576e408b (patch) | |
tree | 7208865e9fd0c744e70e6c30b4bffa9519b81e96 /src/psbt.cpp | |
parent | fb90ec3c33e824f5abb6a68452c683d6ce8b3e4a (diff) |
Abstract out UpdatePSBTOutput from FillPSBT
Diffstat (limited to 'src/psbt.cpp')
-rw-r--r-- | src/psbt.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/psbt.cpp b/src/psbt.cpp index 97bda51a63..2362d4d497 100644 --- a/src/psbt.cpp +++ b/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); |