mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
Merge #15427: Add support for descriptors to utxoupdatepsbt
26fe9b9909Add support for descriptors to utxoupdatepsbt (Pieter Wuille)3135c1a2d2Abstract out UpdatePSBTOutput from FillPSBT (Pieter Wuille)fb90ec3c33Abstract out EvalDescriptorStringOrObject from scantxoutset (Pieter Wuille)eaf4f88734Abstract out IsSegWitOutput from utxoupdatepsbt (Pieter Wuille) Pull request description: This adds a descriptors argument to the `utxoupdatepsbt` RPC. This means: * Input and output scripts and keys will be filled in when known. * P2SH-witness inputs will be filled in from the UTXO set when a descriptor is provided that shows they're spending segwit outputs. This also moves some (newly) shared code to separate functions: `UpdatePSBTOutput` (an analogue to `SignPSBTInput`), `IsSegWitOutput`, and `EvalDescriptorStringOrObject` (implementing the string or object notation parsing used in `scantxoutset`). ACKs for top commit: jnewbery: utACK26fe9b9909laanwj: utACK26fe9b9909(will hold merging until response to promag's comments) promag: ACK26fe9b9, checked refactors and tests look comprehensive. Still missing a release note but can be added later. Tree-SHA512: 1d833b7351b59d6c5ded6da399ff371a8a2a6ad04c0a8f90e6e46105dc737fa6f2740b1e5340280d59e01f42896c40b720c042f44417e38dfbee6477b894b245
This commit is contained in:
19
src/psbt.cpp
19
src/psbt.cpp
@@ -212,6 +212,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