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