Merge ElementsProject/elements#1518: Avoid Simplicity header dependency propogation

6c7788adf3 Avoid Simplicity header dependency propogation (Russell O'Connor)

Pull request description:

  The problem with including <simplicity/elements/env.h> in interpreter.h is that now everyone who needs to include interpreter.h also needs access to Simplicity's header files too.

  This commit breaks that dependency chain by using forward declarations.  It will pay signifigant dividends when elements switches to CMake.

ACKs for top commit:
  delta1:
    ACK 6c7788a; built and tested locally
  apoelstra:
    ACK 6c7788adf3; successfully ran local tests

Tree-SHA512: 78d043a094f0a2bb51e0f103313ae568b42ec2852d8fe9a3fbbcad9c0fbf6829ef1347f83bfd361547ec165c01965e7342188a38d8faacfcf90ef70c5b7001f6
This commit is contained in:
merge-script 2026-01-22 14:52:00 +02:00
commit e360a967b6
No known key found for this signature in database
GPG key ID: DE8F6EA20A661697
2 changed files with 10 additions and 7 deletions

View file

@ -13,6 +13,7 @@
#include <script/script.h>
#include <uint256.h>
extern "C" {
#include <simplicity/elements/env.h>
#include <simplicity/elements/exec.h>
#include <simplicity/errorCodes.h>
}
@ -2675,6 +2676,10 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
}
}
void SimplicityTransactionDeleter::operator()(elementsTransaction* ptr) const {
simplicity_elements_freeTransaction(ptr);
}
template <class T>
PrecomputedTransactionData::PrecomputedTransactionData(const T& txTo)
: PrecomputedTransactionData(uint256{})

View file

@ -10,9 +10,6 @@
#include <script/script_error.h>
#include <span.h>
#include <primitives/transaction.h>
extern "C" {
#include <simplicity/elements/env.h>
}
#include <optional>
#include <vector>
@ -169,12 +166,13 @@ enum : uint32_t {
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
// Forward declarations of Simplicity structures.
struct elementsTransaction;
struct rawElementsTapEnv;
struct SimplicityTransactionDeleter
{
void operator()(elementsTransaction* ptr)
{
simplicity_elements_freeTransaction(ptr);
}
void operator()(elementsTransaction* ptr) const;
};
using SimplicityTransactionUniquePtr = std::unique_ptr<elementsTransaction, SimplicityTransactionDeleter>;