aboutsummaryrefslogtreecommitdiff
path: root/src/script/interpreter.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2020-09-11 14:33:00 -0700
committerPieter Wuille <[email protected]>2020-10-12 02:06:32 -0700
commit5d62e3a68b6ea9bb03556ee1fbf5678f20be01a2 (patch)
treede9e5600c4d2a5718861b4331df2344fd8c47838 /src/script/interpreter.cpp
parentrefactor: rename scriptPubKey in VerifyWitnessProgram to exec_script (diff)
downloaddiscoin-5d62e3a68b6ea9bb03556ee1fbf5678f20be01a2.tar.xz
discoin-5d62e3a68b6ea9bb03556ee1fbf5678f20be01a2.zip
refactor: keep spent outputs in PrecomputedTransactionData
A BIP-341 signature message may commit to the scriptPubKeys and amounts of all spent outputs (including other ones than the input being signed for spends), so keep them available to signature hashing code.
Diffstat (limited to 'src/script/interpreter.cpp')
-rw-r--r--src/script/interpreter.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 2fa7e5e1a..c322ecb1a 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1294,10 +1294,12 @@ uint256 GetOutputsSHA256(const T& txTo)
} // namespace
template <class T>
-void PrecomputedTransactionData::Init(const T& txTo)
+void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent_outputs)
{
assert(!m_ready);
+ m_spent_outputs = std::move(spent_outputs);
+
// Cache is calculated only for transactions with witness
if (txTo.HasWitness()) {
hashPrevouts = SHA256Uint256(GetPrevoutsSHA256(txTo));
@@ -1311,12 +1313,12 @@ void PrecomputedTransactionData::Init(const T& txTo)
template <class T>
PrecomputedTransactionData::PrecomputedTransactionData(const T& txTo)
{
- Init(txTo);
+ Init(txTo, {});
}
// explicit instantiation
-template void PrecomputedTransactionData::Init(const CTransaction& txTo);
-template void PrecomputedTransactionData::Init(const CMutableTransaction& txTo);
+template void PrecomputedTransactionData::Init(const CTransaction& txTo, std::vector<CTxOut>&& spent_outputs);
+template void PrecomputedTransactionData::Init(const CMutableTransaction& txTo, std::vector<CTxOut>&& spent_outputs);
template PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo);
template PrecomputedTransactionData::PrecomputedTransactionData(const CMutableTransaction& txTo);