3 | | - | let playerAddr = Address(base58'3MyaPJkHmZy4u57uKcHXgzQxsk9wAP9LTZ5') |
---|
4 | | - | let playerPubKey = base58'EhyhHkMbyNu8PwHoiJVCq2SciN9FmM5KvBeSN2NkTmeL' |
---|
5 | | - | let casinoAddr = Address(base58'3MyaPJkHmZy4u57uKcHXgzQxsk9wAP9LTZ5') |
---|
6 | | - | let casinoPubKey = base58'EhyhHkMbyNu8PwHoiJVCq2SciN9FmM5KvBeSN2NkTmeL' |
---|
7 | | - | let playerSigned = sigVerify(tx.bodyBytes, tx.proofs[0], playerPubKey) |
---|
8 | | - | let casinoSigned = sigVerify(tx.bodyBytes, tx.proofs[0], casinoPubKey) |
---|
9 | | - | let me = tx.sender |
---|
10 | | - | let casinoBet = 303000000 |
---|
11 | | - | let playerBet = 100000000 |
---|
12 | | - | let gameBalance = (casinoBet + playerBet) |
---|
13 | | - | let start = 380204 |
---|
14 | | - | let playerRangeSize = 0 |
---|
15 | | - | let balance = wavesBalance(me) |
---|
16 | | - | let casinoChoiceHash = base58'CKeQzAitXR6CEtwLM2kGFYTk87kFrc1SFANCBPmyx7cM' |
---|
17 | | - | let dice1 = extract(getInteger(me, "dice1")) |
---|
18 | | - | let dice2 = extract(getInteger(me, "dice2")) |
---|
19 | | - | let casinoDice = extract(getInteger(me, "casinoDice")) |
---|
20 | | - | let playerDepositOk = (balance >= (casinoBet + playerBet)) |
---|
21 | | - | let playerDepositTurn = if (if (((start + 50) > height)) |
---|
22 | | - | then (balance >= casinoBet) |
---|
23 | | - | else false) |
---|
24 | | - | then !(playerDepositOk) |
---|
25 | | - | else false |
---|
26 | | - | let playerBetOk = if ((dice1 > 0)) |
---|
27 | | - | then (dice2 > 0) |
---|
28 | | - | else false |
---|
29 | | - | let playerBetTurn = if (if (((start + 100) > height)) |
---|
30 | | - | then playerDepositOk |
---|
31 | | - | else false) |
---|
32 | | - | then !(playerBetOk) |
---|
33 | | - | else false |
---|
34 | | - | let casinoBetOk = (casinoDice > 0) |
---|
35 | | - | let casinoBetTurn = if (if (((start + 200) > height)) |
---|
36 | | - | then playerBetOk |
---|
37 | | - | else false) |
---|
38 | | - | then !(casinoBetOk) |
---|
39 | | - | else false |
---|
40 | | - | let prizeTurn = casinoBetOk |
---|
41 | | - | let playerEmergencyTakeTurn = if ((height >= (start + 300))) |
---|
42 | | - | then !(casinoBetOk) |
---|
43 | | - | else false |
---|
44 | | - | let casinoCanEmergencyTakeTurn = if ((height >= (start + 100))) |
---|
45 | | - | then if (!(playerDepositOk)) |
---|
46 | | - | then true |
---|
47 | | - | else !(playerBetOk) |
---|
48 | | - | else false |
---|
49 | | - | match tx { |
---|
50 | | - | case dtx: DataTransaction => |
---|
51 | | - | let num = size(dtx.data) |
---|
52 | | - | let choice1 = extract(getInteger(dtx.data, "dice1")) |
---|
53 | | - | let choice2 = extract(getInteger(dtx.data, "dice2")) |
---|
54 | | - | let casinoChoice = extract(getInteger(dtx.data, "casinoDice")) |
---|
55 | | - | let salt = extract(getString(dtx.data, "salt")) |
---|
56 | | - | let playerDicesInRange = if (if (if ((choice1 >= 1)) |
---|
57 | | - | then (100 >= choice1) |
---|
58 | | - | else false) |
---|
59 | | - | then if ((choice2 >= 1)) |
---|
60 | | - | then (100 >= choice2) |
---|
61 | | - | else false |
---|
62 | | - | else false) |
---|
63 | | - | then (choice2 >= choice1) |
---|
64 | | - | else false |
---|
65 | | - | let playerRangeCorrect = ((choice2 - choice1) == playerRangeSize) |
---|
66 | | - | let casinoDicesInRange = if ((casinoChoice >= 1)) |
---|
67 | | - | then (100 >= casinoChoice) |
---|
68 | | - | else false |
---|
69 | | - | let newHash = keccak256(toBytes((toString(casinoChoice) + salt))) |
---|
70 | | - | let casinoVerified = (newHash == casinoChoiceHash) |
---|
71 | | - | let playerInputCorrect = if (playerDicesInRange) |
---|
72 | | - | then (num == 2) |
---|
73 | | - | else false |
---|
74 | | - | let casinoInputCorrect = if (if (casinoDicesInRange) |
---|
75 | | - | then casinoVerified |
---|
76 | | - | else false) |
---|
77 | | - | then (num == 2) |
---|
78 | | - | else false |
---|
79 | | - | if (if (if (casinoSigned) |
---|
80 | | - | then casinoBetTurn |
---|
81 | | - | else false) |
---|
82 | | - | then casinoInputCorrect |
---|
83 | | - | else false) |
---|
84 | | - | then true |
---|
85 | | - | else if (if (playerSigned) |
---|
86 | | - | then playerBetTurn |
---|
87 | | - | else false) |
---|
88 | | - | then playerInputCorrect |
---|
89 | | - | else false |
---|
90 | | - | case ttx: TransferTransaction => |
---|
91 | | - | let betInRange = if ((casinoDice >= dice1)) |
---|
92 | | - | then (dice2 >= casinoDice) |
---|
93 | | - | else false |
---|
94 | | - | let withdrawCorrect = if ((ttx.amount >= 10000000)) |
---|
95 | | - | then (1000000 >= ttx.fee) |
---|
96 | | - | else false |
---|
97 | | - | let playerWin = if (casinoBetOk) |
---|
98 | | - | then betInRange |
---|
99 | | - | else false |
---|
100 | | - | let casinoWin = if (casinoBetOk) |
---|
101 | | - | then !(betInRange) |
---|
102 | | - | else false |
---|
103 | | - | let playerCanTakePrize = if (prizeTurn) |
---|
104 | | - | then playerWin |
---|
105 | | - | else false |
---|
106 | | - | let playerCanTake = if (if (playerCanTakePrize) |
---|
107 | | - | then true |
---|
108 | | - | else playerEmergencyTakeTurn) |
---|
109 | | - | then (ttx.recipient == playerAddr) |
---|
110 | | - | else false |
---|
111 | | - | let casinoCanTakePrize = if (if (prizeTurn) |
---|
112 | | - | then casinoWin |
---|
113 | | - | else false) |
---|
114 | | - | then (ttx.recipient == casinoAddr) |
---|
115 | | - | else false |
---|
116 | | - | let casinoCanTake = if (if (casinoCanTakePrize) |
---|
117 | | - | then true |
---|
118 | | - | else casinoCanEmergencyTakeTurn) |
---|
119 | | - | then (ttx.recipient == casinoAddr) |
---|
120 | | - | else false |
---|
121 | | - | if (if (playerCanTake) |
---|
122 | | - | then true |
---|
123 | | - | else casinoCanTake) |
---|
124 | | - | then withdrawCorrect |
---|
125 | | - | else false |
---|
126 | | - | case _ => |
---|
127 | | - | true |
---|
128 | | - | } |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|