| 600 | } |
| 601 | |
| 602 | void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index) |
| 603 | { |
| 604 | std::optional<CMutableTransaction> unsigned_tx = psbt.GetUnsignedTx(); |
| 605 | if (!unsigned_tx) { |
| 606 | return; |
| 607 | } |
| 608 | CMutableTransaction& tx = *unsigned_tx; |
| 609 | const CTxOut& out = tx.vout.at(index); |
| 610 | PSBTOutput& psbt_out = psbt.outputs.at(index); |
| 611 | |
| 612 | // Fill a SignatureData with output info |
| 613 | SignatureData sigdata; |
| 614 | psbt_out.FillSignatureData(sigdata); |
| 615 | |
| 616 | // Construct a would-be spend of this output, to update sigdata with. |
| 617 | // Note that ProduceSignature is used to fill in metadata (not actual signatures), |
| 618 | // so provider does not need to provide any private keys (it can be a HidingSigningProvider). |
| 619 | MutableTransactionSignatureCreator creator(tx, /*input_idx=*/0, out.nValue, {.sighash_type = SIGHASH_ALL}); |
| 620 | ProduceSignature(provider, creator, out.scriptPubKey, sigdata); |
| 621 | |
| 622 | // Put redeem_script, witness_script, key paths, into PSBTOutput. |
| 623 | psbt_out.FromSignatureData(sigdata); |
| 624 | } |
| 625 | |
| 626 | std::optional<PrecomputedTransactionData> PrecomputePSBTData(const PartiallySignedTransaction& psbt) |
| 627 | { |
no test coverage detected