tx · Ayo5G5Vi6KqUKPoGrEeWJgZs9fpbNRdHJftHp8BsqCLS 3MqQ9ihYKGehfUnXYf5WmkYSZUD71ByeCQe: -0.01500000 Waves 2019.07.10 19:51 [579845] smart account 3MqQ9ihYKGehfUnXYf5WmkYSZUD71ByeCQe > SELF 0.00000000 Waves
{ "type": 13, "id": "Ayo5G5Vi6KqUKPoGrEeWJgZs9fpbNRdHJftHp8BsqCLS", "fee": 1500000, "feeAssetId": null, "timestamp": 1562777464349, "version": 1, "sender": "3MqQ9ihYKGehfUnXYf5WmkYSZUD71ByeCQe", "senderPublicKey": "HcUXEkA9JTGp78LcTKsu4FmEpbDmnqntL4aMNLx1BHMB", "proofs": [ "EW4GN1Pt3Fp5ryGz13QyLiKgDgWEj7nLqeUantFMvDq6nURLbnbnPJQLXhi3RjRQbJZzxnMcuxf6PWx4iCUT3ke" ], "script": "base64:AAIDAAAAAAAAAAAAAAAqAAAAAAlSU0FQVUJMSUMJAAJbAAAAAQIAAAGPYmFzZTY0Ok1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBbGVtcjk1SjFqWlVzN2NKbXJtbWxONHpvN1lWc0JKekllSmRrOExERkdoVUtTSTZ5ZnMyMFp5SmUyMSs2R0p3Tm5LVVUxVXlvYzE3d1NXTUtrclowTU12WUUrWjVBaWlqdkJLNHNTSjNJZ0dqZFU4L05oSThDQkR1MEYreFJNOXEzVEIzTExiRHk1c0JkdWRZZkhmc1VPYytNVHZBRDY5bjI3ZGIyUmg4K3laUU10dWJrdVRRTnA4OXNwaEhRYUxHeVFGYU5sSy9OYTNsRng2b21xemFhMWdqb3BsVXI2cnZZS2dmQUlDVUIzelZtSlNoaUVpN3c3UjBoV2xOUkQzcWNaakNVT05TcEZvNFdiemtuR09henc4NEIrSU1JRm5JcFhXelFMOFJYMHZOY2ZzQnZMRGZNNmsyWmFjcXd5TUthTExxaWdkQmlHZEo3VyswbE9TdE9RSURBUUFCAAAAAAZ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JyDGkTom14LNPTBiq6KtziuMSU8pSRjYZSfVimCi6 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let RSAPUBLIC = fromBase64String("base64: | |
4 | + | let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlemr95J1jZUs7cJmrmmlN4zo7YVsBJzIeJdk8LDFGhUKSI6yfs20ZyJe21+6GJwNnKUU1Uyoc17wSWMKkrZ0MMvYE+Z5AiijvBK4sSJ3IgGjdU8/NhI8CBDu0F+xRM9q3TB3LLbDy5sBdudYfHfsUOc+MTvAD69n27db2Rh8+yZQMtubkuTQNp89sphHQaLGyQFaNlK/Na3lFx6omqzaa1gjoplUr6rvYKgfAICUB3zVmJShiEi7w7R0hWlNRD3qcZjCUONSpFo4WbzknGOazw84B+IMIFnIpXWzQL8RX0vNcfsBvLDfM6k2ZacqwyMKaLLqigdBiGdJ7W+0lOStOQIDAQAB") | |
5 | 5 | ||
6 | 6 | let SERVER = addressFromStringValue("3N4Aib5iubWiGMzdTh6wWiVDVbo32oeVUmH") | |
7 | 7 | ||
254 | 254 | ||
255 | 255 | ||
256 | 256 | @Callable(i) | |
257 | + | func bet (playerChoice) = { | |
258 | + | let newGameNum = IncrementGameNum() | |
259 | + | let gameId = toBase58String(i.transactionId) | |
260 | + | let pmt = extract(i.payment) | |
261 | + | let betNotInWaves = isDefined(pmt.assetId) | |
262 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
263 | + | let winAmt = ValidateBetAndDefineWinAmt(pmt.amount, playerChoice) | |
264 | + | let txIdUsed = isDefined(getString(this, gameId)) | |
265 | + | if (betNotInWaves) | |
266 | + | then throw("Bet amount must be in Waves") | |
267 | + | else if (feeNotInWaves) | |
268 | + | then throw("Transaction's fee must be in Waves") | |
269 | + | else if (txIdUsed) | |
270 | + | then throw("Passed txId had been used before. Game aborted.") | |
271 | + | else { | |
272 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
273 | + | let gameDataStr = FormatGameDataStr(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmt, "") | |
274 | + | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(SERVER, COMMISSION, unit)])) | |
275 | + | } | |
276 | + | } | |
277 | + | ||
278 | + | ||
279 | + | ||
280 | + | @Callable(i) | |
257 | 281 | func withdraw (gameId,rsaSign) = { | |
258 | 282 | let gameDataList = ExtractGameDataList(gameId) | |
259 | 283 | let gameState = gameDataList[IdxGameState] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let RSAPUBLIC = fromBase64String("base64: | |
4 | + | let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlemr95J1jZUs7cJmrmmlN4zo7YVsBJzIeJdk8LDFGhUKSI6yfs20ZyJe21+6GJwNnKUU1Uyoc17wSWMKkrZ0MMvYE+Z5AiijvBK4sSJ3IgGjdU8/NhI8CBDu0F+xRM9q3TB3LLbDy5sBdudYfHfsUOc+MTvAD69n27db2Rh8+yZQMtubkuTQNp89sphHQaLGyQFaNlK/Na3lFx6omqzaa1gjoplUr6rvYKgfAICUB3zVmJShiEi7w7R0hWlNRD3qcZjCUONSpFo4WbzknGOazw84B+IMIFnIpXWzQL8RX0vNcfsBvLDfM6k2ZacqwyMKaLLqigdBiGdJ7W+0lOStOQIDAQAB") | |
5 | 5 | ||
6 | 6 | let SERVER = addressFromStringValue("3N4Aib5iubWiGMzdTh6wWiVDVbo32oeVUmH") | |
7 | 7 | ||
8 | 8 | let RANDORACLETIMEFRAME = 2880 | |
9 | 9 | ||
10 | 10 | let WAVELET = ((100 * 1000) * 1000) | |
11 | 11 | ||
12 | 12 | let COMMISSION = ((5 * WAVELET) / 1000) | |
13 | 13 | ||
14 | 14 | let BET1 = (1 * WAVELET) | |
15 | 15 | ||
16 | 16 | let BET2 = (2 * WAVELET) | |
17 | 17 | ||
18 | 18 | let BET4 = (4 * WAVELET) | |
19 | 19 | ||
20 | 20 | let BET8 = (8 * WAVELET) | |
21 | 21 | ||
22 | 22 | let BET14 = (14 * WAVELET) | |
23 | 23 | ||
24 | 24 | let RATEMULT = 10000 | |
25 | 25 | ||
26 | 26 | let RATE1 = 39655 | |
27 | 27 | ||
28 | 28 | let RATE2 = 24600 | |
29 | 29 | ||
30 | 30 | let RATE3 = 19000 | |
31 | 31 | ||
32 | 32 | let RATE4 = 14200 | |
33 | 33 | ||
34 | 34 | let RATE5 = 11400 | |
35 | 35 | ||
36 | 36 | let IdxGameState = 0 | |
37 | 37 | ||
38 | 38 | let IdxPlayerChoice = 1 | |
39 | 39 | ||
40 | 40 | let IdxPlayerPubKey58 = 2 | |
41 | 41 | ||
42 | 42 | let IdxStartedHeight = 3 | |
43 | 43 | ||
44 | 44 | let IdxWinAmt = 4 | |
45 | 45 | ||
46 | 46 | let IdxRandOrEmpty = 5 | |
47 | 47 | ||
48 | 48 | let RESERVATIONKEY = "$RESERVED_AMOUNT" | |
49 | 49 | ||
50 | 50 | let GAMESCOUNTERKEY = "$GAME_NUM" | |
51 | 51 | ||
52 | 52 | let STATESUBMITTED = "SUBMITTED" | |
53 | 53 | ||
54 | 54 | let STATEWON = "WON" | |
55 | 55 | ||
56 | 56 | let STATELOST = "LOST" | |
57 | 57 | ||
58 | 58 | func IncrementGameNum () = { | |
59 | 59 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
60 | 60 | case num: Int => | |
61 | 61 | num | |
62 | 62 | case _ => | |
63 | 63 | 0 | |
64 | 64 | } | |
65 | 65 | (gameNum + 1) | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) { | |
70 | 70 | case a: Int => | |
71 | 71 | a | |
72 | 72 | case _ => | |
73 | 73 | 0 | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func ValidateAndIncreaseReservedAmt (winAmt) = { | |
78 | 78 | let newReservedAmount = (ExtractReservedAmt() + winAmt) | |
79 | 79 | let balance = wavesBalance(this) | |
80 | 80 | if ((newReservedAmount > balance)) | |
81 | 81 | then throw("Insufficient funds on Dice Roller account. Transaction was rejected for your safety.") | |
82 | 82 | else newReservedAmount | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | func DecreaseReservedAmt (gameId,winAmt) = { | |
87 | 87 | let newReservedAmount = (ExtractReservedAmt() - winAmt) | |
88 | 88 | if ((0 > newReservedAmount)) | |
89 | 89 | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
90 | 90 | else DataEntry(RESERVATIONKEY, newReservedAmount) | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func ValidateBetAndDefineWinAmt (betAmt,playerChoice) = { | |
95 | 95 | let betAmtValid = if (if (if (if ((betAmt == (BET1 + COMMISSION))) | |
96 | 96 | then true | |
97 | 97 | else (betAmt == (BET2 + COMMISSION))) | |
98 | 98 | then true | |
99 | 99 | else (betAmt == (BET4 + COMMISSION))) | |
100 | 100 | then true | |
101 | 101 | else (betAmt == (BET8 + COMMISSION))) | |
102 | 102 | then true | |
103 | 103 | else (betAmt == (BET14 + COMMISSION)) | |
104 | 104 | if (betAmtValid) | |
105 | 105 | then { | |
106 | 106 | let dicesCount = size(playerChoice) | |
107 | 107 | let bet = (betAmt - COMMISSION) | |
108 | 108 | if ((dicesCount == 1)) | |
109 | 109 | then ((bet * RATE1) / RATEMULT) | |
110 | 110 | else if ((dicesCount == 2)) | |
111 | 111 | then ((bet * RATE2) / RATEMULT) | |
112 | 112 | else if ((dicesCount == 3)) | |
113 | 113 | then ((bet * RATE3) / RATEMULT) | |
114 | 114 | else if ((dicesCount == 4)) | |
115 | 115 | then ((bet * RATE4) / RATEMULT) | |
116 | 116 | else if ((dicesCount == 5)) | |
117 | 117 | then ((bet * RATE5) / RATEMULT) | |
118 | 118 | else throw("Invalid dices count in player's choice") | |
119 | 119 | } | |
120 | 120 | else throw("Bet amount is not in range") | |
121 | 121 | } | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func RandToStr (r) = if ((r == 0)) | |
125 | 125 | then "1" | |
126 | 126 | else if ((r == 1)) | |
127 | 127 | then "2" | |
128 | 128 | else if ((r == 2)) | |
129 | 129 | then "3" | |
130 | 130 | else if ((r == 3)) | |
131 | 131 | then "4" | |
132 | 132 | else if ((r == 4)) | |
133 | 133 | then "5" | |
134 | 134 | else if ((r == 5)) | |
135 | 135 | then "6" | |
136 | 136 | else throw(("Unsupported r parameter passed: expected=[0,...,5] actual=" + toString(r))) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func GenerateRandInt (gameId,rsaSign) = { | |
140 | 140 | let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
141 | 141 | if (rsaSigValid) | |
142 | 142 | then { | |
143 | 143 | let rand = (toInt(sha256(rsaSign)) % 6) | |
144 | 144 | if ((0 > rand)) | |
145 | 145 | then (-1 * rand) | |
146 | 146 | else rand | |
147 | 147 | } | |
148 | 148 | else throw("Invalid RSA signature") | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | func IsPlayerWin (playerChoice,randStr) = { | |
153 | 153 | let s = size(playerChoice) | |
154 | 154 | if (if (if (if (if (if ((s >= 1)) | |
155 | 155 | then (take(drop(playerChoice, 0), 1) == randStr) | |
156 | 156 | else false) | |
157 | 157 | then true | |
158 | 158 | else if ((s >= 2)) | |
159 | 159 | then (take(drop(playerChoice, 1), 1) == randStr) | |
160 | 160 | else false) | |
161 | 161 | then true | |
162 | 162 | else if ((s >= 3)) | |
163 | 163 | then (take(drop(playerChoice, 2), 1) == randStr) | |
164 | 164 | else false) | |
165 | 165 | then true | |
166 | 166 | else if ((s >= 4)) | |
167 | 167 | then (take(drop(playerChoice, 3), 1) == randStr) | |
168 | 168 | else false) | |
169 | 169 | then true | |
170 | 170 | else if ((s >= 5)) | |
171 | 171 | then (take(drop(playerChoice, 4), 1) == randStr) | |
172 | 172 | else false) | |
173 | 173 | then true | |
174 | 174 | else if ((s >= 6)) | |
175 | 175 | then (take(drop(playerChoice, 5), 1) == randStr) | |
176 | 176 | else false | |
177 | 177 | } | |
178 | 178 | ||
179 | 179 | ||
180 | 180 | func FormatGameDataParam (p) = { | |
181 | 181 | let s = size(p) | |
182 | 182 | if ((s == 0)) | |
183 | 183 | then throw("Parameter size must be greater then 0") | |
184 | 184 | else if ((s > 99)) | |
185 | 185 | then throw("Parameter size must be less then 100") | |
186 | 186 | else if ((10 > s)) | |
187 | 187 | then (("0" + toString(s)) + p) | |
188 | 188 | else (toString(s) + p) | |
189 | 189 | } | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | func FormatGameDataStr (gameState,playerChoice,playerPubKey58,startedHeight,winAmt,randOrEmpty) = { | |
193 | 193 | let fullStateStr = ((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(playerChoice)) + "_") + FormatGameDataParam(playerPubKey58)) + "_") + FormatGameDataParam(toString(startedHeight))) + "_") + FormatGameDataParam(toString(winAmt))) | |
194 | 194 | if ((randOrEmpty == "")) | |
195 | 195 | then fullStateStr | |
196 | 196 | else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty)) | |
197 | 197 | } | |
198 | 198 | ||
199 | 199 | ||
200 | 200 | func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0)) | |
201 | 201 | then drop(remaining, 1) | |
202 | 202 | else remaining | |
203 | 203 | ||
204 | 204 | ||
205 | 205 | func ParseNextAttribute (remaining) = { | |
206 | 206 | let s = size(remaining) | |
207 | 207 | if ((s > 0)) | |
208 | 208 | then { | |
209 | 209 | let nn = parseIntValue(take(remaining, 2)) | |
210 | 210 | let v = take(drop(remaining, 2), nn) | |
211 | 211 | let tmpRemaining = drop(remaining, (nn + 2)) | |
212 | 212 | let remainingState = RemoveUnderscoreIfPresent(tmpRemaining) | |
213 | 213 | [v, remainingState] | |
214 | 214 | } | |
215 | 215 | else throw("Empty string was passed into parseNextAttribute func") | |
216 | 216 | } | |
217 | 217 | ||
218 | 218 | ||
219 | 219 | func ParseGameRawDataStr (rawStateStr) = { | |
220 | 220 | let gameState = ParseNextAttribute(rawStateStr) | |
221 | 221 | let playerChoice = ParseNextAttribute(gameState[1]) | |
222 | 222 | let playerPubKey58 = ParseNextAttribute(playerChoice[1]) | |
223 | 223 | let startedHeight = ParseNextAttribute(playerPubKey58[1]) | |
224 | 224 | let winAmt = ParseNextAttribute(startedHeight[1]) | |
225 | 225 | [gameState[0], playerChoice[0], playerPubKey58[0], startedHeight[0], winAmt[0]] | |
226 | 226 | } | |
227 | 227 | ||
228 | 228 | ||
229 | 229 | func ExtractGameDataList (gameId) = { | |
230 | 230 | let rawDataStr = match getString(this, gameId) { | |
231 | 231 | case str: String => | |
232 | 232 | str | |
233 | 233 | case _ => | |
234 | 234 | throw(("Couldn't find game by " + gameId)) | |
235 | 235 | } | |
236 | 236 | ParseGameRawDataStr(rawDataStr) | |
237 | 237 | } | |
238 | 238 | ||
239 | 239 | ||
240 | 240 | func WinScriptSet (gameId,playerAddress,winAmt,newGameDataStr,winByTimeout,decreasedReserves) = { | |
241 | 241 | let wSetCommonData = [decreasedReserves] | |
242 | 242 | let tSetCommonData = [ScriptTransfer(playerAddress, winAmt, unit)] | |
243 | 243 | if (winByTimeout) | |
244 | 244 | then { | |
245 | 245 | let newGameDataStrAdjusted = ((newGameDataStr + "_") + FormatGameDataParam("TIMEOUT")) | |
246 | 246 | let gameData = DataEntry(gameId, newGameDataStrAdjusted) | |
247 | 247 | ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData)) | |
248 | 248 | } | |
249 | 249 | else { | |
250 | 250 | let gameData = DataEntry(gameId, newGameDataStr) | |
251 | 251 | ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData)) | |
252 | 252 | } | |
253 | 253 | } | |
254 | 254 | ||
255 | 255 | ||
256 | 256 | @Callable(i) | |
257 | + | func bet (playerChoice) = { | |
258 | + | let newGameNum = IncrementGameNum() | |
259 | + | let gameId = toBase58String(i.transactionId) | |
260 | + | let pmt = extract(i.payment) | |
261 | + | let betNotInWaves = isDefined(pmt.assetId) | |
262 | + | let feeNotInWaves = isDefined(pmt.assetId) | |
263 | + | let winAmt = ValidateBetAndDefineWinAmt(pmt.amount, playerChoice) | |
264 | + | let txIdUsed = isDefined(getString(this, gameId)) | |
265 | + | if (betNotInWaves) | |
266 | + | then throw("Bet amount must be in Waves") | |
267 | + | else if (feeNotInWaves) | |
268 | + | then throw("Transaction's fee must be in Waves") | |
269 | + | else if (txIdUsed) | |
270 | + | then throw("Passed txId had been used before. Game aborted.") | |
271 | + | else { | |
272 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
273 | + | let gameDataStr = FormatGameDataStr(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmt, "") | |
274 | + | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(SERVER, COMMISSION, unit)])) | |
275 | + | } | |
276 | + | } | |
277 | + | ||
278 | + | ||
279 | + | ||
280 | + | @Callable(i) | |
257 | 281 | func withdraw (gameId,rsaSign) = { | |
258 | 282 | let gameDataList = ExtractGameDataList(gameId) | |
259 | 283 | let gameState = gameDataList[IdxGameState] | |
260 | 284 | let playerChoice = gameDataList[IdxPlayerChoice] | |
261 | 285 | let startedHeight = parseIntValue(gameDataList[IdxStartedHeight]) | |
262 | 286 | let winAmt = parseIntValue(gameDataList[IdxWinAmt]) | |
263 | 287 | let playerPubKey58 = gameDataList[IdxPlayerPubKey58] | |
264 | 288 | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
265 | 289 | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
266 | 290 | let decreasedReserves = DecreaseReservedAmt(gameId, winAmt) | |
267 | 291 | if ((gameState != STATESUBMITTED)) | |
268 | 292 | then throw("Invalid game state for passed gameId") | |
269 | 293 | else if (winByTimeout) | |
270 | 294 | then { | |
271 | 295 | let randStr = take(playerChoice, 1) | |
272 | 296 | let newGameDataStr = FormatGameDataStr(STATEWON, playerChoice, playerPubKey58, startedHeight, winAmt, randStr) | |
273 | 297 | WinScriptSet(gameId, playerAddress, winAmt, newGameDataStr, winByTimeout, decreasedReserves) | |
274 | 298 | } | |
275 | 299 | else { | |
276 | 300 | let randStr = RandToStr(GenerateRandInt(gameId, rsaSign)) | |
277 | 301 | if (IsPlayerWin(playerChoice, randStr)) | |
278 | 302 | then { | |
279 | 303 | let newGameDataStr = FormatGameDataStr(STATEWON, playerChoice, playerPubKey58, startedHeight, winAmt, randStr) | |
280 | 304 | WinScriptSet(gameId, playerAddress, winAmt, newGameDataStr, winByTimeout, decreasedReserves) | |
281 | 305 | } | |
282 | 306 | else { | |
283 | 307 | let newGameDataStr = FormatGameDataStr(STATELOST, playerChoice, playerPubKey58, startedHeight, winAmt, randStr) | |
284 | 308 | WriteSet([DataEntry(gameId, newGameDataStr), decreasedReserves]) | |
285 | 309 | } | |
286 | 310 | } | |
287 | 311 | } | |
288 | 312 | ||
289 | 313 | ||
290 | 314 | @Verifier(tx) | |
291 | 315 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
292 | 316 | then match tx { | |
293 | 317 | case ttx: TransferTransaction => | |
294 | 318 | ((wavesBalance(this) - ttx.amount) >= ExtractReservedAmt()) | |
295 | 319 | case stx: SetScriptTransaction => | |
296 | 320 | true | |
297 | 321 | case _ => | |
298 | 322 | false | |
299 | 323 | } | |
300 | 324 | else false | |
301 | 325 |
github/deemru/w8io/026f985 40.55 ms ◑