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 = 50000000 |
---|
11 | | - | let playerBet = 10000000 |
---|
12 | | - | let gameBalance = (casinoBet + playerBet) |
---|
13 | | - | let start = 372357 |
---|
14 | | - | let balance = wavesBalance(me) |
---|
15 | | - | let casinoChoiceHash = base58'GgDo7Z6z89EnYQiNdT1ZvzLxjgKSGZ5MP4RWK236bov4' |
---|
16 | | - | let dice1 = extract(getInteger(me, "dice1")) |
---|
17 | | - | let dice2 = extract(getInteger(me, "dice2")) |
---|
18 | | - | let dice3 = extract(getInteger(me, "dice3")) |
---|
19 | | - | let dice4 = extract(getInteger(me, "dice4")) |
---|
20 | | - | let dice5 = extract(getInteger(me, "dice5")) |
---|
21 | | - | let dice6 = extract(getInteger(me, "dice6")) |
---|
22 | | - | let diceSum = (((((dice1 + dice2) + dice3) + dice4) + dice5) + dice6) |
---|
23 | | - | let casinoDice = extract(getInteger(me, "casinoDice")) |
---|
24 | | - | let isDice1 = if ((dice1 > 0)) |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
30 | | - | let isDice3 = if ((dice3 > 0)) |
---|
31 | | - | then 1 |
---|
32 | | - | else 0 |
---|
33 | | - | let isDice4 = if ((dice4 > 0)) |
---|
34 | | - | then 1 |
---|
35 | | - | else 0 |
---|
36 | | - | let isDice5 = if ((dice5 > 0)) |
---|
37 | | - | then 1 |
---|
38 | | - | else 0 |
---|
39 | | - | let isDice6 = if ((dice6 > 0)) |
---|
40 | | - | then 1 |
---|
41 | | - | else 0 |
---|
42 | | - | let dicesNum = (((((isDice1 + isDice2) + isDice3) + isDice4) + isDice5) + isDice6) |
---|
43 | | - | let playerPlacedBet = (diceSum > 0) |
---|
44 | | - | let casinoOpenedBet = (casinoDice > 0) |
---|
45 | | - | let playerDepositOk = (balance >= (casinoBet + playerBet)) |
---|
46 | | - | let playerDepositTurn = if (if (((start + 50) > height)) |
---|
47 | | - | then (balance >= casinoBet) |
---|
48 | | - | else false) |
---|
49 | | - | then !(playerDepositOk) |
---|
50 | | - | else false |
---|
51 | | - | let playerBetOk = (diceSum > 0) |
---|
52 | | - | let playerBetTurn = if (if (((start + 100) > height)) |
---|
53 | | - | then playerDepositOk |
---|
54 | | - | else false) |
---|
55 | | - | then !(playerBetOk) |
---|
56 | | - | else false |
---|
57 | | - | let casinoBetOk = (casinoDice > 0) |
---|
58 | | - | let casinoBetTurn = if (if (((start + 200) > height)) |
---|
59 | | - | then playerBetOk |
---|
60 | | - | else false) |
---|
61 | | - | then !(casinoBetOk) |
---|
62 | | - | else false |
---|
63 | | - | let prizeTurn = casinoBetOk |
---|
64 | | - | let playerEmergencyTakeTurn = if ((height >= (start + 300))) |
---|
65 | | - | then !(casinoBetOk) |
---|
66 | | - | else false |
---|
67 | | - | let casinoCanEmergencyTakeTurn = if ((height >= (start + 100))) |
---|
68 | | - | then if (!(playerDepositOk)) |
---|
69 | | - | then true |
---|
70 | | - | else !(playerBetOk) |
---|
71 | | - | else false |
---|
72 | | - | match tx { |
---|
73 | | - | case dtx: DataTransaction => |
---|
74 | | - | let num = size(dtx.data) |
---|
75 | | - | let choice1 = extract(getInteger(dtx.data, "dice1")) |
---|
76 | | - | let choice2 = extract(getInteger(dtx.data, "dice2")) |
---|
77 | | - | let choice3 = extract(getInteger(dtx.data, "dice3")) |
---|
78 | | - | let choice4 = extract(getInteger(dtx.data, "dice4")) |
---|
79 | | - | let choice5 = extract(getInteger(dtx.data, "dice5")) |
---|
80 | | - | let choice6 = extract(getInteger(dtx.data, "dice6")) |
---|
81 | | - | let casinoChoice = extract(getInteger(dtx.data, "casinoDice")) |
---|
82 | | - | let salt = extract(getString(dtx.data, "salt")) |
---|
83 | | - | let playerDicesInRange = if (if (if (if (if (if ((choice1 >= 0)) |
---|
84 | | - | then (6 >= choice1) |
---|
85 | | - | else false) |
---|
86 | | - | then if ((choice2 >= 0)) |
---|
87 | | - | then (6 >= choice2) |
---|
88 | | - | else false |
---|
89 | | - | else false) |
---|
90 | | - | then if ((choice3 >= 0)) |
---|
91 | | - | then (6 >= choice3) |
---|
92 | | - | else false |
---|
93 | | - | else false) |
---|
94 | | - | then if ((choice4 >= 0)) |
---|
95 | | - | then (6 >= choice4) |
---|
96 | | - | else false |
---|
97 | | - | else false) |
---|
98 | | - | then if ((choice5 >= 0)) |
---|
99 | | - | then (6 >= choice5) |
---|
100 | | - | else false |
---|
101 | | - | else false) |
---|
102 | | - | then if ((choice6 >= 0)) |
---|
103 | | - | then (6 >= choice6) |
---|
104 | | - | else false |
---|
105 | | - | else false |
---|
106 | | - | let playerChoiceSum = (((((choice1 + choice2) + choice3) + choice4) + choice5) + choice6) |
---|
107 | | - | let playerChoiceMul = (((((choice1 * choice2) * choice3) * choice4) * choice5) * choice6) |
---|
108 | | - | let playerDicesNumberCorrect = if ((playerChoiceSum > 0)) |
---|
109 | | - | then (playerChoiceMul == 0) |
---|
110 | | - | else false |
---|
111 | | - | let casinoDicesInRange = if ((casinoChoice >= 1)) |
---|
112 | | - | then (6 >= casinoChoice) |
---|
113 | | - | else false |
---|
114 | | - | let newHash = keccak256(toBytes((toString(casinoChoice) + salt))) |
---|
115 | | - | let casinoVerified = (newHash == casinoChoiceHash) |
---|
116 | | - | let playerInputCorrect = if (if (playerDicesInRange) |
---|
117 | | - | then playerDicesNumberCorrect |
---|
118 | | - | else false) |
---|
119 | | - | then (num == 6) |
---|
120 | | - | else false |
---|
121 | | - | let casinoInputCorrect = if (if (casinoDicesInRange) |
---|
122 | | - | then casinoVerified |
---|
123 | | - | else false) |
---|
124 | | - | then (num == 2) |
---|
125 | | - | else false |
---|
126 | | - | if (if (if (casinoSigned) |
---|
127 | | - | then casinoBetTurn |
---|
128 | | - | else false) |
---|
129 | | - | then casinoInputCorrect |
---|
130 | | - | else false) |
---|
131 | | - | then true |
---|
132 | | - | else if (if (playerSigned) |
---|
133 | | - | then playerBetTurn |
---|
134 | | - | else false) |
---|
135 | | - | then playerInputCorrect |
---|
136 | | - | else false |
---|
137 | | - | case ttx: TransferTransaction => |
---|
138 | | - | let dicesMatch = if (if (if (if (if ((dice1 == casinoDice)) |
---|
139 | | - | then true |
---|
140 | | - | else (dice2 == casinoDice)) |
---|
141 | | - | then true |
---|
142 | | - | else (dice3 == casinoDice)) |
---|
143 | | - | then true |
---|
144 | | - | else (dice4 == casinoDice)) |
---|
145 | | - | then true |
---|
146 | | - | else (dice5 == casinoDice)) |
---|
147 | | - | then true |
---|
148 | | - | else (dice6 == casinoDice) |
---|
149 | | - | let withdrawCorrect = if ((ttx.amount >= 10000000)) |
---|
150 | | - | then (1000000 >= ttx.fee) |
---|
151 | | - | else false |
---|
152 | | - | let playerWin = if (casinoBetOk) |
---|
153 | | - | then dicesMatch |
---|
154 | | - | else false |
---|
155 | | - | let casinoWin = if (if (casinoBetOk) |
---|
156 | | - | then !(dicesMatch) |
---|
157 | | - | else false) |
---|
158 | | - | then (ttx.recipient == casinoAddr) |
---|
159 | | - | else false |
---|
160 | | - | let playerTakeOnlyPrize = true |
---|
161 | | - | let playerCanTakePrize = if (if (prizeTurn) |
---|
162 | | - | then playerWin |
---|
163 | | - | else false) |
---|
164 | | - | then playerTakeOnlyPrize |
---|
165 | | - | else false |
---|
166 | | - | let playerCanTake = if (if (playerCanTakePrize) |
---|
167 | | - | then true |
---|
168 | | - | else playerEmergencyTakeTurn) |
---|
169 | | - | then (ttx.recipient == playerAddr) |
---|
170 | | - | else false |
---|
171 | | - | let casinoCanTakePrize = if (if (prizeTurn) |
---|
172 | | - | then casinoWin |
---|
173 | | - | else false) |
---|
174 | | - | then (ttx.recipient == casinoAddr) |
---|
175 | | - | else false |
---|
176 | | - | let casinoCanTake = if (if (casinoCanTakePrize) |
---|
177 | | - | then true |
---|
178 | | - | else casinoCanEmergencyTakeTurn) |
---|
179 | | - | then (ttx.recipient == casinoAddr) |
---|
180 | | - | else false |
---|
181 | | - | if (if (playerCanTake) |
---|
182 | | - | then true |
---|
183 | | - | else casinoCanTake) |
---|
184 | | - | then withdrawCorrect |
---|
185 | | - | else false |
---|
186 | | - | case _ => |
---|
187 | | - | true |
---|
188 | | - | } |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|