From 6e9e4e6130797b721c8df1eabaf46ec25ebb6abe Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Thu, 7 Sep 2023 19:16:57 +1000 Subject: Use ParamsWrapper for witness serialization --- src/script/bitcoinconsensus.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/script') diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp index 71005cfb6e..2ca8dac48c 100644 --- a/src/script/bitcoinconsensus.cpp +++ b/src/script/bitcoinconsensus.cpp @@ -16,8 +16,7 @@ namespace { class TxInputStream { public: - TxInputStream(int nVersionIn, const unsigned char *txTo, size_t txToLen) : - m_version(nVersionIn), + TxInputStream(const unsigned char *txTo, size_t txToLen) : m_data(txTo), m_remaining(txToLen) {} @@ -48,9 +47,7 @@ public: return *this; } - int GetVersion() const { return m_version; } private: - const int m_version; const unsigned char* m_data; size_t m_remaining; }; @@ -84,8 +81,8 @@ static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptP } try { - TxInputStream stream(PROTOCOL_VERSION, txTo, txToLen); - CTransaction tx(deserialize, stream); + TxInputStream stream(txTo, txToLen); + CTransaction tx(deserialize, TX_WITH_WITNESS, stream); std::vector spent_outputs; if (spentOutputs != nullptr) { @@ -102,7 +99,7 @@ static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptP if (nIn >= tx.vin.size()) return set_error(err, bitcoinconsensus_ERR_TX_INDEX); - if (GetSerializeSize(tx, PROTOCOL_VERSION) != txToLen) + if (GetSerializeSize(TX_WITH_WITNESS(tx)) != txToLen) return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH); // Regardless of the verification result, the tx did not error. -- cgit v1.2.3