aboutsummaryrefslogtreecommitdiff
path: root/src/psbt.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-07-20 21:24:56 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-09-28 19:13:42 -0400
commita99ed8986554fa1ecc854e43ea373d957e598db8 (patch)
treefd6a13369e76b602f866f185a3ad57b74720634c /src/psbt.cpp
parent6a5381a06b0b9b4490394e42a8e3bc284601a4af (diff)
psbt: sign without finalizing
We don't always want to finalize after signing, so make it possible to do that.
Diffstat (limited to 'src/psbt.cpp')
-rw-r--r--src/psbt.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/psbt.cpp b/src/psbt.cpp
index 5445bc8aa1..0f8b855ba3 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -247,7 +247,7 @@ PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction&
return txdata;
}
-bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, const PrecomputedTransactionData* txdata, int sighash, SignatureData* out_sigdata)
+bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, const PrecomputedTransactionData* txdata, int sighash, SignatureData* out_sigdata, bool finalize)
{
PSBTInput& input = psbt.inputs.at(index);
const CMutableTransaction& tx = *psbt.tx;
@@ -295,6 +295,10 @@ bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction&
}
// Verify that a witness signature was produced in case one was required.
if (require_witness_sig && !sigdata.witness) return false;
+
+ // If we are not finalizing, set sigdata.complete to false to not set the scriptWitness
+ if (!finalize && sigdata.complete) sigdata.complete = false;
+
input.FromSignatureData(sigdata);
// If we have a witness signature, put a witness UTXO.
@@ -324,7 +328,7 @@ bool FinalizePSBT(PartiallySignedTransaction& psbtx)
bool complete = true;
const PrecomputedTransactionData txdata = PrecomputePSBTData(psbtx);
for (unsigned int i = 0; i < psbtx.tx->vin.size(); ++i) {
- complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, SIGHASH_ALL);
+ complete &= SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, &txdata, SIGHASH_ALL, nullptr, true);
}
return complete;