mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Make SignPSBTInput operate on a private SignatureData object
This commit is contained in:
@@ -237,7 +237,7 @@ bool ProduceSignature(const SigningProvider& provider, const BaseSignatureCreato
|
||||
return sigdata.complete;
|
||||
}
|
||||
|
||||
bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& tx, PSBTInput& input, SignatureData& sigdata, int index, int sighash)
|
||||
bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& tx, PSBTInput& input, int index, int sighash)
|
||||
{
|
||||
// if this input has a final scriptsig or scriptwitness, don't do anything with it
|
||||
if (!input.final_script_sig.empty() || !input.final_script_witness.IsNull()) {
|
||||
@@ -245,6 +245,7 @@ bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& t
|
||||
}
|
||||
|
||||
// Fill SignatureData with input info
|
||||
SignatureData sigdata;
|
||||
input.FillSignatureData(sigdata);
|
||||
|
||||
// Get UTXO
|
||||
@@ -276,6 +277,16 @@ bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& t
|
||||
// Verify that a witness signature was produced in case one was required.
|
||||
if (require_witness_sig && !sigdata.witness) return false;
|
||||
input.FromSignatureData(sigdata);
|
||||
|
||||
// If both UTXO types are present, drop the unnecessary one.
|
||||
if (input.non_witness_utxo && !input.witness_utxo.IsNull()) {
|
||||
if (sigdata.witness) {
|
||||
input.non_witness_utxo = nullptr;
|
||||
} else {
|
||||
input.witness_utxo.SetNull();
|
||||
}
|
||||
}
|
||||
|
||||
return sig_complete;
|
||||
}
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, C
|
||||
bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType);
|
||||
|
||||
/** Signs a PSBTInput, verifying that all provided data matches what is being signed. */
|
||||
bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& tx, PSBTInput& input, SignatureData& sigdata, int index, int sighash = 1);
|
||||
bool SignPSBTInput(const SigningProvider& provider, const CMutableTransaction& tx, PSBTInput& input, int index, int sighash = SIGHASH_ALL);
|
||||
|
||||
/** Extract signature data from a transaction input, and insert it. */
|
||||
SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nIn, const CTxOut& txout);
|
||||
|
||||
Reference in New Issue
Block a user