4 #include <cryptoconditions.h>
9 #include "consensus/validation.h"
10 #include "primitives/transaction.h"
14 class NotarisationData;
20 CValidationState state;
22 bool Invalid(std::string s) { return state.Invalid(false, 0, s); }
23 bool Error(std::string s) { return state.Error(s); }
24 bool Valid() { return true; }
27 * Test validity of a CC_Eval node
29 virtual bool Dispatch(const CC *cond, const CTransaction &tx, unsigned int nIn);
32 * Dispute a payout using a VM
34 bool DisputePayout(AppVM &vm, const CC *cond, const CTransaction &disputeTx, unsigned int nIn);
37 * Test an ImportPayout CC Eval condition
39 bool ImportPayout(const CC *cond, const CTransaction &payoutTx, unsigned int nIn);
44 virtual bool GetTx(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow) const;
45 virtual unsigned int GetCurrentHeight() const;
46 virtual bool GetSpends(uint256 hash, std::vector<CTransaction> &spends) const;
47 virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const;
48 virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const;
49 virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const;
50 virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
54 bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn);
58 * Virtual machine to use in the case of on-chain app evaluation
64 * in: header - paramters agreed upon by all players
65 * in: body - gamestate
66 * out: length - length of game (longest wins)
67 * out: payments - vector of CTxOut, always deterministically sorted.
69 virtual std::pair<int,std::vector<CTxOut>>
70 evaluate(std::vector<unsigned char> header, std::vector<unsigned char> body) = 0;
75 * Data from notarisation OP_RETURN
77 class NotarisationData {
86 bool Parse(CScript scriptPubKey);
91 * Serialisation boilerplate
94 std::vector<unsigned char> CheckSerialize(T &in)
96 CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
98 return std::vector<unsigned char>(ss.begin(), ss.end());
102 bool CheckDeserialize(std::vector<unsigned char> vIn, T &out)
104 CDataStream ss(vIn, SER_NETWORK, PROTOCOL_VERSION);
107 if (ss.eof()) return true;
113 #endif /* CC_EVAL_H */