mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
FillPSBT: report number of inputs signed (or would sign)
In FillPSBT, optionally report the number of inputs we successfully signed, as an out parameter. If "sign" is false, instead report the number of inputs for which GetSigningProvider does not return nullptr. (This is a potentially overbroad estimate of inputs we could sign.)
This commit is contained in:
parent
9e7b23b733
commit
5dd0c03ffa
8 changed files with 46 additions and 13 deletions
|
|
@ -585,8 +585,11 @@ SigningResult LegacyScriptPubKeyMan::SignMessage(const std::string& message, con
|
|||
return SigningResult::SIGNING_FAILED;
|
||||
}
|
||||
|
||||
TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs) const
|
||||
TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs, int* n_signed) const
|
||||
{
|
||||
if (n_signed) {
|
||||
*n_signed = 0;
|
||||
}
|
||||
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
|
||||
const CTxIn& txin = psbtx.tx->vin[i];
|
||||
PSBTInput& input = psbtx.inputs.at(i);
|
||||
|
|
@ -617,6 +620,14 @@ TransactionError LegacyScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psb
|
|||
SignatureData sigdata;
|
||||
input.FillSignatureData(sigdata);
|
||||
SignPSBTInput(HidingSigningProvider(this, !sign, !bip32derivs), psbtx, i, sighash_type);
|
||||
|
||||
bool signed_one = PSBTInputSigned(input);
|
||||
if (n_signed && (signed_one || !sign)) {
|
||||
// If sign is false, we assume that we _could_ sign if we get here. This
|
||||
// will never have false negatives; it is hard to tell under what i
|
||||
// circumstances it could have false positives.
|
||||
(*n_signed)++;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in the bip32 keypaths and redeemscripts for the outputs so that hardware wallets can identify change
|
||||
|
|
@ -2064,8 +2075,11 @@ SigningResult DescriptorScriptPubKeyMan::SignMessage(const std::string& message,
|
|||
return SigningResult::OK;
|
||||
}
|
||||
|
||||
TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs) const
|
||||
TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction& psbtx, int sighash_type, bool sign, bool bip32derivs, int* n_signed) const
|
||||
{
|
||||
if (n_signed) {
|
||||
*n_signed = 0;
|
||||
}
|
||||
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
|
||||
const CTxIn& txin = psbtx.tx->vin[i];
|
||||
PSBTInput& input = psbtx.inputs.at(i);
|
||||
|
|
@ -2117,6 +2131,14 @@ TransactionError DescriptorScriptPubKeyMan::FillPSBT(PartiallySignedTransaction&
|
|||
}
|
||||
|
||||
SignPSBTInput(HidingSigningProvider(keys.get(), !sign, !bip32derivs), psbtx, i, sighash_type);
|
||||
|
||||
bool signed_one = PSBTInputSigned(input);
|
||||
if (n_signed && (signed_one || !sign)) {
|
||||
// If sign is false, we assume that we _could_ sign if we get here. This
|
||||
// will never have false negatives; it is hard to tell under what i
|
||||
// circumstances it could have false positives.
|
||||
(*n_signed)++;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in the bip32 keypaths and redeemscripts for the outputs so that hardware wallets can identify change
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue