tx · 5CaLUa74ahREByy9m69v3S3i1gsJKHehqX56eLGxxwrE 3MrTMXEvaz63AHA6K7U5hDgTY54gZZe3R4g: -0.01400000 Waves 2019.03.18 19:14 [541903] smart account 3MrTMXEvaz63AHA6K7U5hDgTY54gZZe3R4g > SELF 0.00000000 Waves
{ "type": 13, "id": "5CaLUa74ahREByy9m69v3S3i1gsJKHehqX56eLGxxwrE", "fee": 1400000, "feeAssetId": null, "timestamp": 1552925631292, "version": 1, "sender": "3MrTMXEvaz63AHA6K7U5hDgTY54gZZe3R4g", "senderPublicKey": "CEx6vd7D5Czxcfshd4vLpSw4LEmGULQw5avVZ7Vfrzgo", "proofs": [ "5pPLxLjCY5e8HH7s9j7T36qUYzrTvsiFgdYretkGThEejny3JubzbNZ5SL6ZFg71w51iTdmE6DXL9kPx3SnLujNm" ], "script": "base64:AgQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAACZHQFAAAAByRtYXRjaDADCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCQAEEwAAAAIIBQAAAAJkdAAAAARkYXRhAgAAAAR0eXBlCQAAAgAAAAECAAAAH2R0eCBmYWlsIC0gZHR4IHR5cGUgbm90IGRlZmluZWQDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCQAEEwAAAAIIBQAAAAJkdAAAAARkYXRhAgAAAAZnYW1lSWQJAAACAAAAAQIAAAAeZHR4IGZhaWwgLSBnYW1lIGlkIG5vdCBkZWZpbmVkBAAAAAR0eXBlCQEAAAAHZXh0cmFjdAAAAAEJAAQTAAAAAggFAAAAAmR0AAAABGRhdGECAAAABHR5cGUEAAAABmdhbWVJZAkBAAAAB2V4dHJhY3QAAAABCQAEEwAAAAIIBQAAAAJkdAAAAARkYXRhAgAAAAZnYW1lSWQEAAAADHNlcnZlclNpZ25lZAkAAfQAAAADCAUAAAACZHQAAAAJYm9keUJ5dG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xpY0tleQc0aA98", "chainId": 84, "height": 541903, "spentComplexity": 0 } View: original | compacted Prev: 5Fo1RiybA7PPhNJL7wAu898VfQsbwofTphE5Jnhsbwyg Next: 7unPpKJsW5UzWeU7XXwKLviBQHp5hq4dGdGH5aJPWFuS Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 2 #-} | |
2 | 2 | {-# CONTENT_TYPE EXPRESSION #-} | |
3 | 3 | match tx { | |
4 | 4 | case dt: DataTransaction => | |
5 | - | let type = extract(getString(dt.data, "type")) | |
6 | - | let gameId = extract(getString(dt.data, "gameId")) | |
7 | - | let serverSigned = sigVerify(dt.bodyBytes, dt.proofs[0], tx.senderPublicKey) | |
8 | - | if ((type == "start")) | |
9 | - | then { | |
10 | - | let betAmount = extract(getInteger(dt.data, (gameId + "_amount"))) | |
11 | - | let player1 = extract(getString(dt.data, (gameId + "_player1"))) | |
12 | - | let player1TxId = extract(getString(dt.data, (gameId + "_tx1"))) | |
13 | - | let player2 = extract(getString(dt.data, (gameId + "_player2"))) | |
14 | - | let player2TxId = extract(getString(dt.data, (gameId + "_tx2"))) | |
15 | - | let dtStartDataDefined = if (if (if (isDefined(getInteger(dt.data, (gameId + "_winAmount")))) | |
16 | - | then isDefined(getBinary(dt.data, (gameId + "_squadronHash"))) | |
17 | - | else false) | |
18 | - | then isDefined(getBoolean(dt.data, ("used_tx_" + player1TxId))) | |
19 | - | else false) | |
20 | - | then isDefined(getBoolean(dt.data, ("used_tx_" + player2TxId))) | |
21 | - | else false | |
22 | - | let player1Tx = transactionById(fromBase58String(player1TxId)) | |
23 | - | let player2Tx = transactionById(fromBase58String(player2TxId)) | |
24 | - | let tr1Ok = match player1Tx { | |
25 | - | case t: TransferTransaction => | |
26 | - | if (if (if (if ((t.amount == betAmount)) | |
27 | - | then !(isDefined(getString(tx.sender, ("used_tx_" + player1TxId)))) | |
28 | - | else false) | |
29 | - | then !(isDefined(t.assetId)) | |
30 | - | else false) | |
31 | - | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player1)).bytes)))) == gameId) | |
32 | - | else false) | |
33 | - | then (t.recipient == tx.sender) | |
34 | - | else false | |
35 | - | case _ => | |
36 | - | false | |
37 | - | } | |
38 | - | let tr2Ok = match player2Tx { | |
39 | - | case t: TransferTransaction => | |
40 | - | if (if (if (if ((t.amount == betAmount)) | |
41 | - | then !(isDefined(getString(tx.sender, ("used_tx_" + player2TxId)))) | |
42 | - | else false) | |
43 | - | then !(isDefined(t.assetId)) | |
44 | - | else false) | |
45 | - | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player2)).bytes)))) == gameId) | |
46 | - | else false) | |
47 | - | then (t.recipient == tx.sender) | |
48 | - | else false | |
49 | - | case _ => | |
50 | - | false | |
51 | - | } | |
52 | - | if (!(serverSigned)) | |
53 | - | then throw("dtx:start fail - server did not sign tx") | |
54 | - | else if (!(tr1Ok)) | |
55 | - | then throw("dtx:start fail - player 1 ttx is invalid") | |
56 | - | else if (!(tr2Ok)) | |
57 | - | then throw("dtx:start fail - player 2 ttx is invalid") | |
58 | - | else if (!(dtStartDataDefined)) | |
59 | - | then throw("dtx:start fail - start data is incomplete") | |
60 | - | else true | |
61 | - | } | |
62 | - | else if ((type == "finish")) | |
63 | - | then { | |
64 | - | let winner = extract(getString(dt.data, (gameId + "_winner"))) | |
65 | - | let correctWinner = if ((winner == extract(getString(tx.sender, (gameId + "_player1"))))) | |
66 | - | then true | |
67 | - | else (winner == extract(getString(tx.sender, (gameId + "_player2")))) | |
68 | - | let squadron1 = extract(getBinary(dt.data, (gameId + "_squadron1"))) | |
69 | - | let squadron2 = extract(getBinary(dt.data, (gameId + "_squadron2"))) | |
70 | - | let gameSalt = extract(getBinary(dt.data, (gameId + "_salt"))) | |
71 | - | let correctSquadrons = (sha256(((squadron1 + squadron2) + gameSalt)) == extract(getBinary(tx.sender, (gameId + "_squadronHash")))) | |
72 | - | if (!(serverSigned)) | |
73 | - | then throw("dtx:finish fail - server did not sign tx") | |
74 | - | else if (!(correctWinner)) | |
75 | - | then throw("dtx:finish fail - winner is incorrect") | |
76 | - | else if (!(correctSquadrons)) | |
77 | - | then throw("dtx:finish fail - squadrons are incorrect") | |
78 | - | else true | |
5 | + | if (!(isDefined(getString(dt.data, "type")))) | |
6 | + | then throw("dtx fail - dtx type not defined") | |
7 | + | else if (!(isDefined(getString(dt.data, "gameId")))) | |
8 | + | then throw("dtx fail - game id not defined") | |
9 | + | else { | |
10 | + | let type = extract(getString(dt.data, "type")) | |
11 | + | let gameId = extract(getString(dt.data, "gameId")) | |
12 | + | let serverSigned = sigVerify(dt.bodyBytes, dt.proofs[0], tx.senderPublicKey) | |
13 | + | if ((type == "start")) | |
14 | + | then { | |
15 | + | let betAmount = extract(getInteger(dt.data, (gameId + "_amount"))) | |
16 | + | let player1 = extract(getString(dt.data, (gameId + "_player1"))) | |
17 | + | let player1TxId = extract(getString(dt.data, (gameId + "_tx1"))) | |
18 | + | let player2 = extract(getString(dt.data, (gameId + "_player2"))) | |
19 | + | let player2TxId = extract(getString(dt.data, (gameId + "_tx2"))) | |
20 | + | let dtStartDataDefined = if (if (if (isDefined(getInteger(dt.data, (gameId + "_winAmount")))) | |
21 | + | then isDefined(getBinary(dt.data, (gameId + "_squadronHash"))) | |
22 | + | else false) | |
23 | + | then isDefined(getBoolean(dt.data, ("used_tx_" + player1TxId))) | |
24 | + | else false) | |
25 | + | then isDefined(getBoolean(dt.data, ("used_tx_" + player2TxId))) | |
26 | + | else false | |
27 | + | let player1Tx = transactionById(fromBase58String(player1TxId)) | |
28 | + | let player2Tx = transactionById(fromBase58String(player2TxId)) | |
29 | + | let tr1Ok = match player1Tx { | |
30 | + | case t: TransferTransaction => | |
31 | + | if (if (if (if ((t.amount == betAmount)) | |
32 | + | then !(isDefined(getString(tx.sender, ("used_tx_" + player1TxId)))) | |
33 | + | else false) | |
34 | + | then !(isDefined(t.assetId)) | |
35 | + | else false) | |
36 | + | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player1)).bytes)))) == gameId) | |
37 | + | else false) | |
38 | + | then (t.recipient == tx.sender) | |
39 | + | else false | |
40 | + | case _ => | |
41 | + | false | |
42 | + | } | |
43 | + | let tr2Ok = match player2Tx { | |
44 | + | case t: TransferTransaction => | |
45 | + | if (if (if (if ((t.amount == betAmount)) | |
46 | + | then !(isDefined(getString(tx.sender, ("used_tx_" + player2TxId)))) | |
47 | + | else false) | |
48 | + | then !(isDefined(t.assetId)) | |
49 | + | else false) | |
50 | + | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player2)).bytes)))) == gameId) | |
51 | + | else false) | |
52 | + | then (t.recipient == tx.sender) | |
53 | + | else false | |
54 | + | case _ => | |
55 | + | false | |
56 | + | } | |
57 | + | if (!(serverSigned)) | |
58 | + | then throw("dtx:start fail - server did not sign tx") | |
59 | + | else if (!(tr1Ok)) | |
60 | + | then throw("dtx:start fail - player 1 ttx is invalid") | |
61 | + | else if (!(tr2Ok)) | |
62 | + | then throw("dtx:start fail - player 2 ttx is invalid") | |
63 | + | else if (!(dtStartDataDefined)) | |
64 | + | then throw("dtx:start fail - start data is incomplete") | |
65 | + | else true | |
66 | + | } | |
67 | + | else if ((type == "finish")) | |
68 | + | then { | |
69 | + | let winner = extract(getString(dt.data, (gameId + "_winner"))) | |
70 | + | let correctWinner = if ((winner == extract(getString(tx.sender, (gameId + "_player1"))))) | |
71 | + | then true | |
72 | + | else (winner == extract(getString(tx.sender, (gameId + "_player2")))) | |
73 | + | let squadron1 = extract(getBinary(dt.data, (gameId + "_squadron1"))) | |
74 | + | let squadron2 = extract(getBinary(dt.data, (gameId + "_squadron2"))) | |
75 | + | let gameSalt = extract(getBinary(dt.data, (gameId + "_salt"))) | |
76 | + | let correctSquadrons = (sha256(((squadron1 + squadron2) + gameSalt)) == extract(getBinary(tx.sender, (gameId + "_squadronHash")))) | |
77 | + | if (!(serverSigned)) | |
78 | + | then throw("dtx:finish fail - server did not sign tx") | |
79 | + | else if (!(correctWinner)) | |
80 | + | then throw("dtx:finish fail - winner is incorrect") | |
81 | + | else if (!(correctSquadrons)) | |
82 | + | then throw("dtx:finish fail - squadrons are incorrect") | |
83 | + | else true | |
84 | + | } | |
85 | + | else if ((type == "payout")) | |
86 | + | then if (!(isDefined(getString(tx.sender, (gameId + "_winner"))))) | |
87 | + | then throw("dtx:payout fail - game winner not defined") | |
88 | + | else { | |
89 | + | let winnerPk = extract(getString(tx.sender, (gameId + "_winner"))) | |
90 | + | let winnerSigned = sigVerify(dt.bodyBytes, dt.proofs[0], fromBase58String(winnerPk)) | |
91 | + | let hashPkNotInState = !(isDefined(getBoolean(tx.sender, ((gameId + "_") + winnerPk)))) | |
92 | + | let hashPkInData = isDefined(getBoolean(dt.data, ((gameId + "_") + winnerPk))) | |
93 | + | let ttxIdNotInState = !(isDefined(getBoolean(tx.sender, dt.data[3].key))) | |
94 | + | let data4 = (size(dt.data) == 4) | |
95 | + | if (!(winnerSigned)) | |
96 | + | then throw("dtx:payout fail - winner did not sign tx") | |
97 | + | else if (!(hashPkNotInState)) | |
98 | + | then throw("dtx:payout fail - payout dtx already sent") | |
99 | + | else if (!(hashPkInData)) | |
100 | + | then throw("dtx:payout fail - payout (gameId, winnerPk) pair is not set") | |
101 | + | else if (!(ttxIdNotInState)) | |
102 | + | then throw("dtx:payout fail - payout ttx id is not set") | |
103 | + | else if (!(data4)) | |
104 | + | then throw("dtx:payout fail - data size is invalid") | |
105 | + | else true | |
106 | + | } | |
107 | + | else throw(("dtx:type_unknown " + type)) | |
79 | 108 | } | |
80 | - | else if ((type == "payout")) | |
81 | - | then { | |
82 | - | let winnerPk = extract(getString(tx.sender, (gameId + "_winner"))) | |
83 | - | let winnerSigned = sigVerify(dt.bodyBytes, dt.proofs[0], fromBase58String(winnerPk)) | |
84 | - | let hashPkNotInState = !(isDefined(getBoolean(tx.sender, ((gameId + "_") + winnerPk)))) | |
85 | - | let hashPkInData = isDefined(getBoolean(dt.data, ((gameId + "_") + winnerPk))) | |
86 | - | let ttxIdNotInState = !(isDefined(getBoolean(tx.sender, dt.data[3].key))) | |
87 | - | let data4 = (size(dt.data) == 4) | |
88 | - | if (!(winnerSigned)) | |
89 | - | then throw("dtx:payout fail - winner did not sign tx") | |
90 | - | else if (!(hashPkNotInState)) | |
91 | - | then throw("dtx:payout fail - payout dtx already sent") | |
92 | - | else if (!(hashPkInData)) | |
93 | - | then throw("dtx:payout fail - payout (gameId, winnerPk) pair is not set") | |
94 | - | else if (!(ttxIdNotInState)) | |
95 | - | then throw("dtx:payout fail - payout ttx id is not set") | |
96 | - | else if (!(data4)) | |
97 | - | then throw("dtx:payout fail - data size is invalid") | |
98 | - | else true | |
99 | - | } | |
100 | - | else throw(("dtx:type_unknown " + type)) | |
101 | 109 | case tt: TransferTransaction => | |
102 | 110 | let serverSigned = sigVerify(tt.bodyBytes, tt.proofs[0], tx.senderPublicKey) | |
103 | 111 | if (serverSigned) |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 2 #-} | |
2 | 2 | {-# CONTENT_TYPE EXPRESSION #-} | |
3 | 3 | match tx { | |
4 | 4 | case dt: DataTransaction => | |
5 | - | let type = extract(getString(dt.data, "type")) | |
6 | - | let gameId = extract(getString(dt.data, "gameId")) | |
7 | - | let serverSigned = sigVerify(dt.bodyBytes, dt.proofs[0], tx.senderPublicKey) | |
8 | - | if ((type == "start")) | |
9 | - | then { | |
10 | - | let betAmount = extract(getInteger(dt.data, (gameId + "_amount"))) | |
11 | - | let player1 = extract(getString(dt.data, (gameId + "_player1"))) | |
12 | - | let player1TxId = extract(getString(dt.data, (gameId + "_tx1"))) | |
13 | - | let player2 = extract(getString(dt.data, (gameId + "_player2"))) | |
14 | - | let player2TxId = extract(getString(dt.data, (gameId + "_tx2"))) | |
15 | - | let dtStartDataDefined = if (if (if (isDefined(getInteger(dt.data, (gameId + "_winAmount")))) | |
16 | - | then isDefined(getBinary(dt.data, (gameId + "_squadronHash"))) | |
17 | - | else false) | |
18 | - | then isDefined(getBoolean(dt.data, ("used_tx_" + player1TxId))) | |
19 | - | else false) | |
20 | - | then isDefined(getBoolean(dt.data, ("used_tx_" + player2TxId))) | |
21 | - | else false | |
22 | - | let player1Tx = transactionById(fromBase58String(player1TxId)) | |
23 | - | let player2Tx = transactionById(fromBase58String(player2TxId)) | |
24 | - | let tr1Ok = match player1Tx { | |
25 | - | case t: TransferTransaction => | |
26 | - | if (if (if (if ((t.amount == betAmount)) | |
27 | - | then !(isDefined(getString(tx.sender, ("used_tx_" + player1TxId)))) | |
28 | - | else false) | |
29 | - | then !(isDefined(t.assetId)) | |
30 | - | else false) | |
31 | - | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player1)).bytes)))) == gameId) | |
32 | - | else false) | |
33 | - | then (t.recipient == tx.sender) | |
34 | - | else false | |
35 | - | case _ => | |
36 | - | false | |
37 | - | } | |
38 | - | let tr2Ok = match player2Tx { | |
39 | - | case t: TransferTransaction => | |
40 | - | if (if (if (if ((t.amount == betAmount)) | |
41 | - | then !(isDefined(getString(tx.sender, ("used_tx_" + player2TxId)))) | |
42 | - | else false) | |
43 | - | then !(isDefined(t.assetId)) | |
44 | - | else false) | |
45 | - | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player2)).bytes)))) == gameId) | |
46 | - | else false) | |
47 | - | then (t.recipient == tx.sender) | |
48 | - | else false | |
49 | - | case _ => | |
50 | - | false | |
51 | - | } | |
52 | - | if (!(serverSigned)) | |
53 | - | then throw("dtx:start fail - server did not sign tx") | |
54 | - | else if (!(tr1Ok)) | |
55 | - | then throw("dtx:start fail - player 1 ttx is invalid") | |
56 | - | else if (!(tr2Ok)) | |
57 | - | then throw("dtx:start fail - player 2 ttx is invalid") | |
58 | - | else if (!(dtStartDataDefined)) | |
59 | - | then throw("dtx:start fail - start data is incomplete") | |
60 | - | else true | |
61 | - | } | |
62 | - | else if ((type == "finish")) | |
63 | - | then { | |
64 | - | let winner = extract(getString(dt.data, (gameId + "_winner"))) | |
65 | - | let correctWinner = if ((winner == extract(getString(tx.sender, (gameId + "_player1"))))) | |
66 | - | then true | |
67 | - | else (winner == extract(getString(tx.sender, (gameId + "_player2")))) | |
68 | - | let squadron1 = extract(getBinary(dt.data, (gameId + "_squadron1"))) | |
69 | - | let squadron2 = extract(getBinary(dt.data, (gameId + "_squadron2"))) | |
70 | - | let gameSalt = extract(getBinary(dt.data, (gameId + "_salt"))) | |
71 | - | let correctSquadrons = (sha256(((squadron1 + squadron2) + gameSalt)) == extract(getBinary(tx.sender, (gameId + "_squadronHash")))) | |
72 | - | if (!(serverSigned)) | |
73 | - | then throw("dtx:finish fail - server did not sign tx") | |
74 | - | else if (!(correctWinner)) | |
75 | - | then throw("dtx:finish fail - winner is incorrect") | |
76 | - | else if (!(correctSquadrons)) | |
77 | - | then throw("dtx:finish fail - squadrons are incorrect") | |
78 | - | else true | |
5 | + | if (!(isDefined(getString(dt.data, "type")))) | |
6 | + | then throw("dtx fail - dtx type not defined") | |
7 | + | else if (!(isDefined(getString(dt.data, "gameId")))) | |
8 | + | then throw("dtx fail - game id not defined") | |
9 | + | else { | |
10 | + | let type = extract(getString(dt.data, "type")) | |
11 | + | let gameId = extract(getString(dt.data, "gameId")) | |
12 | + | let serverSigned = sigVerify(dt.bodyBytes, dt.proofs[0], tx.senderPublicKey) | |
13 | + | if ((type == "start")) | |
14 | + | then { | |
15 | + | let betAmount = extract(getInteger(dt.data, (gameId + "_amount"))) | |
16 | + | let player1 = extract(getString(dt.data, (gameId + "_player1"))) | |
17 | + | let player1TxId = extract(getString(dt.data, (gameId + "_tx1"))) | |
18 | + | let player2 = extract(getString(dt.data, (gameId + "_player2"))) | |
19 | + | let player2TxId = extract(getString(dt.data, (gameId + "_tx2"))) | |
20 | + | let dtStartDataDefined = if (if (if (isDefined(getInteger(dt.data, (gameId + "_winAmount")))) | |
21 | + | then isDefined(getBinary(dt.data, (gameId + "_squadronHash"))) | |
22 | + | else false) | |
23 | + | then isDefined(getBoolean(dt.data, ("used_tx_" + player1TxId))) | |
24 | + | else false) | |
25 | + | then isDefined(getBoolean(dt.data, ("used_tx_" + player2TxId))) | |
26 | + | else false | |
27 | + | let player1Tx = transactionById(fromBase58String(player1TxId)) | |
28 | + | let player2Tx = transactionById(fromBase58String(player2TxId)) | |
29 | + | let tr1Ok = match player1Tx { | |
30 | + | case t: TransferTransaction => | |
31 | + | if (if (if (if ((t.amount == betAmount)) | |
32 | + | then !(isDefined(getString(tx.sender, ("used_tx_" + player1TxId)))) | |
33 | + | else false) | |
34 | + | then !(isDefined(t.assetId)) | |
35 | + | else false) | |
36 | + | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player1)).bytes)))) == gameId) | |
37 | + | else false) | |
38 | + | then (t.recipient == tx.sender) | |
39 | + | else false | |
40 | + | case _ => | |
41 | + | false | |
42 | + | } | |
43 | + | let tr2Ok = match player2Tx { | |
44 | + | case t: TransferTransaction => | |
45 | + | if (if (if (if ((t.amount == betAmount)) | |
46 | + | then !(isDefined(getString(tx.sender, ("used_tx_" + player2TxId)))) | |
47 | + | else false) | |
48 | + | then !(isDefined(t.assetId)) | |
49 | + | else false) | |
50 | + | then (extract(getString(dt.data, ("game_" + toBase58String(addressFromPublicKey(fromBase58String(player2)).bytes)))) == gameId) | |
51 | + | else false) | |
52 | + | then (t.recipient == tx.sender) | |
53 | + | else false | |
54 | + | case _ => | |
55 | + | false | |
56 | + | } | |
57 | + | if (!(serverSigned)) | |
58 | + | then throw("dtx:start fail - server did not sign tx") | |
59 | + | else if (!(tr1Ok)) | |
60 | + | then throw("dtx:start fail - player 1 ttx is invalid") | |
61 | + | else if (!(tr2Ok)) | |
62 | + | then throw("dtx:start fail - player 2 ttx is invalid") | |
63 | + | else if (!(dtStartDataDefined)) | |
64 | + | then throw("dtx:start fail - start data is incomplete") | |
65 | + | else true | |
66 | + | } | |
67 | + | else if ((type == "finish")) | |
68 | + | then { | |
69 | + | let winner = extract(getString(dt.data, (gameId + "_winner"))) | |
70 | + | let correctWinner = if ((winner == extract(getString(tx.sender, (gameId + "_player1"))))) | |
71 | + | then true | |
72 | + | else (winner == extract(getString(tx.sender, (gameId + "_player2")))) | |
73 | + | let squadron1 = extract(getBinary(dt.data, (gameId + "_squadron1"))) | |
74 | + | let squadron2 = extract(getBinary(dt.data, (gameId + "_squadron2"))) | |
75 | + | let gameSalt = extract(getBinary(dt.data, (gameId + "_salt"))) | |
76 | + | let correctSquadrons = (sha256(((squadron1 + squadron2) + gameSalt)) == extract(getBinary(tx.sender, (gameId + "_squadronHash")))) | |
77 | + | if (!(serverSigned)) | |
78 | + | then throw("dtx:finish fail - server did not sign tx") | |
79 | + | else if (!(correctWinner)) | |
80 | + | then throw("dtx:finish fail - winner is incorrect") | |
81 | + | else if (!(correctSquadrons)) | |
82 | + | then throw("dtx:finish fail - squadrons are incorrect") | |
83 | + | else true | |
84 | + | } | |
85 | + | else if ((type == "payout")) | |
86 | + | then if (!(isDefined(getString(tx.sender, (gameId + "_winner"))))) | |
87 | + | then throw("dtx:payout fail - game winner not defined") | |
88 | + | else { | |
89 | + | let winnerPk = extract(getString(tx.sender, (gameId + "_winner"))) | |
90 | + | let winnerSigned = sigVerify(dt.bodyBytes, dt.proofs[0], fromBase58String(winnerPk)) | |
91 | + | let hashPkNotInState = !(isDefined(getBoolean(tx.sender, ((gameId + "_") + winnerPk)))) | |
92 | + | let hashPkInData = isDefined(getBoolean(dt.data, ((gameId + "_") + winnerPk))) | |
93 | + | let ttxIdNotInState = !(isDefined(getBoolean(tx.sender, dt.data[3].key))) | |
94 | + | let data4 = (size(dt.data) == 4) | |
95 | + | if (!(winnerSigned)) | |
96 | + | then throw("dtx:payout fail - winner did not sign tx") | |
97 | + | else if (!(hashPkNotInState)) | |
98 | + | then throw("dtx:payout fail - payout dtx already sent") | |
99 | + | else if (!(hashPkInData)) | |
100 | + | then throw("dtx:payout fail - payout (gameId, winnerPk) pair is not set") | |
101 | + | else if (!(ttxIdNotInState)) | |
102 | + | then throw("dtx:payout fail - payout ttx id is not set") | |
103 | + | else if (!(data4)) | |
104 | + | then throw("dtx:payout fail - data size is invalid") | |
105 | + | else true | |
106 | + | } | |
107 | + | else throw(("dtx:type_unknown " + type)) | |
79 | 108 | } | |
80 | - | else if ((type == "payout")) | |
81 | - | then { | |
82 | - | let winnerPk = extract(getString(tx.sender, (gameId + "_winner"))) | |
83 | - | let winnerSigned = sigVerify(dt.bodyBytes, dt.proofs[0], fromBase58String(winnerPk)) | |
84 | - | let hashPkNotInState = !(isDefined(getBoolean(tx.sender, ((gameId + "_") + winnerPk)))) | |
85 | - | let hashPkInData = isDefined(getBoolean(dt.data, ((gameId + "_") + winnerPk))) | |
86 | - | let ttxIdNotInState = !(isDefined(getBoolean(tx.sender, dt.data[3].key))) | |
87 | - | let data4 = (size(dt.data) == 4) | |
88 | - | if (!(winnerSigned)) | |
89 | - | then throw("dtx:payout fail - winner did not sign tx") | |
90 | - | else if (!(hashPkNotInState)) | |
91 | - | then throw("dtx:payout fail - payout dtx already sent") | |
92 | - | else if (!(hashPkInData)) | |
93 | - | then throw("dtx:payout fail - payout (gameId, winnerPk) pair is not set") | |
94 | - | else if (!(ttxIdNotInState)) | |
95 | - | then throw("dtx:payout fail - payout ttx id is not set") | |
96 | - | else if (!(data4)) | |
97 | - | then throw("dtx:payout fail - data size is invalid") | |
98 | - | else true | |
99 | - | } | |
100 | - | else throw(("dtx:type_unknown " + type)) | |
101 | 109 | case tt: TransferTransaction => | |
102 | 110 | let serverSigned = sigVerify(tt.bodyBytes, tt.proofs[0], tx.senderPublicKey) | |
103 | 111 | if (serverSigned) | |
104 | 112 | then true | |
105 | 113 | else { | |
106 | 114 | let recipientAddr = toBase58String(addressFromRecipient(tt.recipient).bytes) | |
107 | 115 | let gameId = extract(getString(tx.sender, ("game_" + recipientAddr))) | |
108 | 116 | let winner = extract(getString(tx.sender, (gameId + "_winner"))) | |
109 | 117 | let winnerAddr = toBase58String(addressFromPublicKey(fromBase58String(winner)).bytes) | |
110 | 118 | let winAmount = extract(getInteger(tx.sender, (gameId + "_winAmount"))) | |
111 | 119 | if ((recipientAddr != winnerAddr)) | |
112 | 120 | then throw("ttx:fail - recipient is not winner") | |
113 | 121 | else if (!(isDefined(getBoolean(tx.sender, toBase58String(tt.id))))) | |
114 | 122 | then throw("ttx:fail - payout ttx not registered") | |
115 | 123 | else if (isDefined(tt.assetId)) | |
116 | 124 | then throw("ttx:fail - asset id is set (not waves)") | |
117 | 125 | else if ((tt.amount != winAmount)) | |
118 | 126 | then throw("ttx:fail - wrong payout amount") | |
119 | 127 | else true | |
120 | 128 | } | |
121 | 129 | case st: SetScriptTransaction => | |
122 | 130 | sigVerify(st.bodyBytes, st.proofs[0], tx.senderPublicKey) | |
123 | 131 | case _ => | |
124 | 132 | false | |
125 | 133 | } |
github/deemru/w8io/026f985 29.97 ms ◑