Repository navigation
Expand file tree
/
Copy pathbetprotocol.h
More file actions
70 lines (54 loc) · 2.05 KB
/
Copy pathbetprotocol.h
File metadata and controls
70 lines (54 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef BETPROTOCOL_H
#define BETPROTOCOL_H
#include "cc/eval.h"
#include "pubkey.h"
#include "consensus/merkle.h"
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "cryptoconditions/include/cryptoconditions.h"
class MoMProof
{
public:
unsigned long nIndex;
std::vector<uint256> branch;
uint256 notarisationHash;
MoMProof() {}
MoMProof(unsigned long i, std::vector<uint256> b, uint256 n) :
nIndex(i), branch(b), notarisationHash(n) {}
uint256 Exec(uint256 hash) { return ComputeMerkleRootFromBranch(hash, branch, nIndex); }
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(VARINT(nIndex));
READWRITE(branch);
READWRITE(notarisationHash);
}
};
class BetProtocol
{
protected:
std::vector<CC*> playerConditions();
public:
EvalCode disputeCode;
std::vector<CPubKey> players;
std::vector<unsigned char> vmParams;
uint32_t waitBlocks;
// Utility
BetProtocol(EvalCode dc, std::vector<CPubKey> ps, uint32_t wb, std::vector<uint8_t> vmp)
: disputeCode(dc), waitBlocks(wb), vmParams(vmp), players(ps) {}
std::vector<CC*> PlayerConditions();
// on PANGEA
CC* MakeDisputeCond();
CMutableTransaction MakeSessionTx(CAmount spendFee);
CMutableTransaction MakeDisputeTx(uint256 signedSessionTxHash, uint256 vmResultHash);
CMutableTransaction MakePostEvidenceTx(uint256 signedSessionTxHash,
int playerIndex, std::vector<unsigned char> state);
// on KMD
CC* MakePayoutCond(uint256 signedSessionTxHash);
CMutableTransaction MakeStakeTx(CAmount totalPayout, uint256 signedSessionTx);
CMutableTransaction MakeAgreePayoutTx(std::vector<CTxOut> payouts, uint256 signedStakeTxHash);
CMutableTransaction MakeImportPayoutTx(std::vector<CTxOut> payouts,
CTransaction signedDisputeTx, uint256 signedStakeTxHash, MoMProof momProof);
};
bool GetOpReturnHash(CScript script, uint256 &hash);
#endif /* BETPROTOCOL_H */