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 bet = 10000000 |
---|
10 | | - | let start = 378412 |
---|
11 | | - | let playerChoiceTime = 100 |
---|
12 | | - | let casinoChoiceTime = 200 |
---|
13 | | - | let playerTakeTimeStart = 1000 |
---|
14 | | - | let casinoTakeTimeStart = 1500 |
---|
15 | | - | let balance = wavesBalance(tx.sender) |
---|
16 | | - | let casinoChoiceHash = base58'CPAGhCPoDmmr3nU7mncidgnUqw8VW7manPSMZfJaBKaF' |
---|
17 | | - | let playerPlacedBet = isDefined(getString(tx.sender, "playerChoice")) |
---|
18 | | - | let casinoPlacedBet = isDefined(getString(tx.sender, "casinoChoice")) |
---|
19 | | - | match tx { |
---|
20 | | - | case dtx: DataTransaction => |
---|
21 | | - | let num = size(dtx.data) |
---|
22 | | - | let key = dtx.data[0].key |
---|
23 | | - | let choice = extract(getString(dtx.data, key)) |
---|
24 | | - | let salt = if (isDefined(dtx.data[1].value)) |
---|
25 | | - | then extract(getString(dtx.data, "salt")) |
---|
26 | | - | else "" |
---|
27 | | - | let inputCorrect = if (if (if (if ((key == "playerChoice")) |
---|
28 | | - | then true |
---|
29 | | - | else (key == "casinoChoice")) |
---|
30 | | - | then if ((choice == "0")) |
---|
31 | | - | then true |
---|
32 | | - | else (choice == "1") |
---|
33 | | - | else false) |
---|
34 | | - | then (balance >= (bet * 2)) |
---|
35 | | - | else false) |
---|
36 | | - | then (2 >= num) |
---|
37 | | - | else false |
---|
38 | | - | let newHash = keccak256(toBytes((choice + salt))) |
---|
39 | | - | let casinoVerified = (newHash == casinoChoiceHash) |
---|
40 | | - | let playerTurn = if (if (if ((key == "playerChoice")) |
---|
41 | | - | then playerSigned |
---|
42 | | - | else false) |
---|
43 | | - | then !(playerPlacedBet) |
---|
44 | | - | else false) |
---|
45 | | - | then ((start + playerChoiceTime) > height) |
---|
46 | | - | else false |
---|
47 | | - | let casinoTurn = if (if (if (if ((key == "casinoChoice")) |
---|
48 | | - | then casinoSigned |
---|
49 | | - | else false) |
---|
50 | | - | then casinoVerified |
---|
51 | | - | else false) |
---|
52 | | - | then !(casinoPlacedBet) |
---|
53 | | - | else false) |
---|
54 | | - | then ((start + casinoChoiceTime) > height) |
---|
55 | | - | else false |
---|
56 | | - | if (inputCorrect) |
---|
57 | | - | then if (playerTurn) |
---|
58 | | - | then true |
---|
59 | | - | else casinoTurn |
---|
60 | | - | else false |
---|
61 | | - | case ttx: TransferTransaction => |
---|
62 | | - | let withdrawCorrect = if ((ttx.amount >= 10000000)) |
---|
63 | | - | then (1000000 >= ttx.fee) |
---|
64 | | - | else false |
---|
65 | | - | let playerTakeTime = if (if ((ttx.recipient == playerAddr)) |
---|
66 | | - | then (height > (start + playerTakeTimeStart)) |
---|
67 | | - | else false) |
---|
68 | | - | then playerPlacedBet |
---|
69 | | - | else false |
---|
70 | | - | let casinoTakeTime = if (if ((ttx.recipient == casinoAddr)) |
---|
71 | | - | then (height > (start + casinoTakeTimeStart)) |
---|
72 | | - | else false) |
---|
73 | | - | then casinoPlacedBet |
---|
74 | | - | else false |
---|
75 | | - | let playerChoise = extract(getString(tx.sender, "playerChoice")) |
---|
76 | | - | let casinoChoise = extract(getString(tx.sender, "casinoChoice")) |
---|
77 | | - | let ready = if (playerPlacedBet) |
---|
78 | | - | then casinoPlacedBet |
---|
79 | | - | else false |
---|
80 | | - | let playerWin = if (if (ready) |
---|
81 | | - | then (playerChoise == casinoChoise) |
---|
82 | | - | else false) |
---|
83 | | - | then (ttx.recipient == playerAddr) |
---|
84 | | - | else false |
---|
85 | | - | let casinoWin = if (if (ready) |
---|
86 | | - | then (playerChoise != casinoChoise) |
---|
87 | | - | else false) |
---|
88 | | - | then (ttx.recipient == casinoAddr) |
---|
89 | | - | else false |
---|
90 | | - | if (if (if (if (playerWin) |
---|
91 | | - | then true |
---|
92 | | - | else casinoWin) |
---|
93 | | - | then true |
---|
94 | | - | else playerTakeTime) |
---|
95 | | - | then true |
---|
96 | | - | else casinoTakeTime) |
---|
97 | | - | then withdrawCorrect |
---|
98 | | - | else false |
---|
99 | | - | case _ => |
---|
100 | | - | true |
---|
101 | | - | } |
---|
| 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) |
---|