#ifndef SIMPLICITY_ELEMENTS_TXENV_H
#define SIMPLICITY_ELEMENTS_TXENV_H
#include <stdbool.h>
#include "../sha256.h"
typedef struct outpoint {
sha256_midstate txid;
uint_fast32_t ix;
} outpoint;
typedef enum confPrefix {
NONE = 0,
EXPLICIT = 1,
EVEN_Y = 2,
ODD_Y = 3
} confPrefix;
static inline bool is_confidential(confPrefix prefix) {
return EVEN_Y == prefix || ODD_Y == prefix;
}
typedef struct confidential {
sha256_midstate data;
confPrefix prefix;
} confidential;
typedef struct confAmount {
union {
sha256_midstate confidential;
uint_fast64_t explicit;
};
confPrefix prefix;
} confAmount;
typedef enum opcodeType {
OP_IMMEDIATE,
OP_PUSHDATA,
OP_PUSHDATA2,
OP_PUSHDATA4,
OP_1NEGATE,
OP_RESERVED,
OP_1,
OP_2,
OP_3,
OP_4,
OP_5,
OP_6,
OP_7,
OP_8,
OP_9,
OP_10,
OP_11,
OP_12,
OP_13,
OP_14,
OP_15,
OP_16
} opcodeType;
typedef struct opcode {
sha256_midstate dataHash;
opcodeType code;
} opcode;
typedef struct parsedNullData {
const opcode* op;
uint_fast32_t len;
} parsedNullData;
typedef struct sigOutput {
confidential asset;
sha256_midstate surjectionProofHash;
sha256_midstate rangeProofHash;
confAmount amt;
confidential nonce;
sha256_midstate scriptPubKey;
uint_fast64_t assetFee;
parsedNullData pnd;
bool isNullData;
bool emptyScript;
} sigOutput;
typedef struct utxo {
sha256_midstate scriptPubKey;
confidential asset;
confAmount amt;
} utxo;
typedef enum issuanceType {
NO_ISSUANCE = 0,
NEW_ISSUANCE,
REISSUANCE
} issuanceType;
typedef struct assetIssuance {
union {
struct {
sha256_midstate contractHash;
confAmount tokenAmt;
};
struct {
sha256_midstate blindingNonce;
};
};
sha256_midstate entropy;
sha256_midstate assetRangeProofHash;
sha256_midstate tokenRangeProofHash;
sha256_midstate assetId;
sha256_midstate tokenId;
confAmount assetAmt;
issuanceType type;
} assetIssuance;
typedef struct sigInput {
sha256_midstate annexHash;
sha256_midstate pegin;
sha256_midstate scriptSigHash;
outpoint prevOutpoint;
utxo txo;
uint_fast32_t sequence;
assetIssuance issuance;
bool hasAnnex;
bool isPegin;
} sigInput;
typedef struct elementsTransaction {
const sigInput* input;
const sigOutput* output;
const sigOutput* const * feeOutputs;
sha256_midstate outputAssetAmountsHash;
sha256_midstate outputNoncesHash;
sha256_midstate outputScriptsHash;
sha256_midstate outputRangeProofsHash;
sha256_midstate outputSurjectionProofsHash;
sha256_midstate outputsHash;
sha256_midstate inputOutpointsHash;
sha256_midstate inputAssetAmountsHash;
sha256_midstate inputScriptsHash;
sha256_midstate inputUTXOsHash;
sha256_midstate inputSequencesHash;
sha256_midstate inputAnnexesHash;
sha256_midstate inputScriptSigsHash;
sha256_midstate inputsHash;
sha256_midstate issuanceAssetAmountsHash;
sha256_midstate issuanceTokenAmountsHash;
sha256_midstate issuanceRangeProofsHash;
sha256_midstate issuanceBlindingEntropyHash;
sha256_midstate issuancesHash;
sha256_midstate txHash;
sha256_midstate txid;
uint_fast32_t numInputs;
uint_fast32_t numOutputs;
uint_fast32_t numFees;
uint_fast32_t version;
uint_fast32_t lockTime;
uint_fast16_t lockDistance;
uint_fast16_t lockDuration;
bool isFinal;
} elementsTransaction;
typedef struct elementsTapEnv {
const sha256_midstate *path;
sha256_midstate tapLeafHash;
sha256_midstate tappathHash;
sha256_midstate tapEnvHash;
sha256_midstate internalKey;
sha256_midstate scriptCMR;
unsigned char pathLen;
unsigned char leafVersion;
} elementsTapEnv;
typedef struct txEnv {
const elementsTransaction* tx;
const elementsTapEnv* taproot;
sha256_midstate genesisHash;
sha256_midstate sigAllHash;
uint_fast32_t ix;
} txEnv;
txEnv rustsimplicity_0_6_elements_build_txEnv(const elementsTransaction* tx, const elementsTapEnv* taproot, const sha256_midstate* genesisHash, uint_fast32_t ix);
#endif