mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
refactor: use PSBTFillOptions for filling and signing
Replace the sign, finalize , bip32derivs and sighash_type arguments which are passed to FillPSBT() and SignPSBTInput() with a PSBTFillOptions struct. This makes it easier to add additional options later without large code churn, such as avoid_script_path proposed in #32857. It also makes the use of default boolean options safer compared to positional arguments that can easily get mixed up.
This commit is contained in:
@@ -79,10 +79,10 @@ util::Result<void> ExternalSignerScriptPubKeyMan::DisplayAddress(const CTxDestin
|
||||
}
|
||||
|
||||
// If sign is true, transaction must previously have been filled
|
||||
std::optional<PSBTError> ExternalSignerScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, std::optional<int> sighash_type, bool sign, bool bip32derivs, int* n_signed, bool finalize) const
|
||||
std::optional<PSBTError> ExternalSignerScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, const common::PSBTFillOptions& options, int* n_signed) const
|
||||
{
|
||||
if (!sign) {
|
||||
return DescriptorScriptPubKeyMan::FillPSBT(psbt, txdata, sighash_type, false, bip32derivs, n_signed, finalize);
|
||||
if (!options.sign) {
|
||||
return DescriptorScriptPubKeyMan::FillPSBT(psbt, txdata, options, n_signed);
|
||||
}
|
||||
|
||||
// Already complete if every input is now signed
|
||||
@@ -103,7 +103,7 @@ std::optional<PSBTError> ExternalSignerScriptPubKeyMan::FillPSBT(PartiallySigned
|
||||
LogWarning("Failed to sign: %s\n", failure_reason);
|
||||
return PSBTError::EXTERNAL_SIGNER_FAILED;
|
||||
}
|
||||
if (finalize) FinalizePSBT(psbt);
|
||||
if (options.finalize) FinalizePSBT(psbt); // This won't work in a multisig setup
|
||||
return {};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
||||
Reference in New Issue
Block a user