tx · 4m21MpLuugmVJucmk6mwDGaahTC8cXFgsBiTeFoGu7qD

3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs:  -0.01400000 Waves

2019.09.06 15:59 [664229] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves

{ "type": 13, "id": "4m21MpLuugmVJucmk6mwDGaahTC8cXFgsBiTeFoGu7qD", "fee": 1400000, "feeAssetId": null, "timestamp": 1567774731756, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "GPyS3YAabau6i7rrAJCxSF8MimS9T7xcQFghQqZm9Gs6dvYxJBSyJTiLMoxQikeD5qVpJPqy7LMH4C6orStX4yi" ], "script": "base64:AAIDAAAAAAAAAAAAAAAIAAAAAA9TZXJ2ZXJQdWJsaWNLZXkJAAJZAAAAAQIAAAAsN2ltOWNhaUNtRTRTTDZqVG00S1RpY0hINGJHUGY1djU5cm5mVUEzY0NSRGoAAAAAElNlcnZlckJldFB1YmxpY0tleQkAAlkAAAABAgAAACw3aW05Y2FpQ21FNFNMNmpUbTRLVGljSEg0YkdQZjV2NTlybmZVQTNjQ1JEagAAAAAHV0FWRUxFVAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAA+gAAAAAAAAAA+gAAAAACkNPTU1JU1NJT04JAABpAAAAAgkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAAAAAPoAAAAAAtUaWNrZXRzUmF0ZQAAAAAAAAAAZAEAAAAPR2VuZXJhdGVSYW5kSW50AAAAAwAAAAZnYW1lSWQAAAAHcnNhU2lnbgAAAApsYXN0VGlja2V0BAAAAAtyc2FTaWdWYWxpZAkAAfQAAAADCQABmwAAAAEFAAAABmdhbWVJZAUAAAAHcnNhU2lnbgUAAAAPU2VydmVyUHVibGljS2V5A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JAAACAAAAAQIAAAAWUGxheWVyMSBub3QgdGhlIFdpbm5lcgAAAABEVK4e", "chainId": 84, "height": 664229, "spentComplexity": 0 } View: original | compacted Prev: 4TPt9aJMVsVfVQXjAiM1Wfw5ob8Q6n8emtr6jbTooUkD Next: 6MjK6a8hGxdYsfthntDygKdDQHemsf7ZmNC7B3zz26xs Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
5+
6+let ServerBetPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
57
68 let WAVELET = ((100 * 1000) * 1000)
79
4547
4648
4749 @Callable(i)
48-func bet () = {
49- let gameId = toBase58String(i.transactionId)
50+func bet (gameId,gameIdCrypted,tickets) = {
5051 let pmt = extract(i.payment)
5152 let betNotInWaves = isDefined(pmt.assetId)
5253 let feeNotInWaves = isDefined(pmt.assetId)
5758 else if (feeNotInWaves)
5859 then throw("Transaction's fee must be in Waves")
5960 else {
60- let gameDataStr = toString(playerAddress)
61- let betData = [DataEntry(gameId, gameDataStr)]
62- WriteSet(betData)
61+ let rsaSigValid = sigVerify(toBytes(gameId), gameIdCrypted, ServerBetPublicKey)
62+ if (rsaSigValid)
63+ then {
64+ let playerAddressStr = toString(playerAddress)
65+ let betData = [DataEntry((playerAddressStr + "_tickets"), tickets)]
66+ WriteSet(betData)
67+ }
68+ else throw("Invalid RSA signature")
6369 }
6470 }
6571
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
5+
6+let ServerBetPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
57
68 let WAVELET = ((100 * 1000) * 1000)
79
810 let COMMISSION = ((5 * WAVELET) / 1000)
911
1012 let TicketsRate = 100
1113
1214 func GenerateRandInt (gameId,rsaSign,lastTicket) = {
1315 let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey)
1416 if (rsaSigValid)
1517 then {
1618 let rand = (toInt(sha256(rsaSign)) % lastTicket)
1719 if ((0 > rand))
1820 then ((-1 * rand) + 1)
1921 else (rand + 1)
2022 }
2123 else throw("Invalid RSA signature")
2224 }
2325
2426
2527 func getPlayers (gameId) = {
2628 let rawDataStr = match getString(this, gameId) {
2729 case str: String =>
2830 str
2931 case _ =>
3032 throw(("Couldn't find game by " + gameId))
3133 }
3234 split(rawDataStr, "_")
3335 }
3436
3537
3638 func getPlayersTickets (gameId,Player) = {
3739 let playerTicketsStr = match getString(this, ((gameId + "_") + Player)) {
3840 case str: String =>
3941 str
4042 case _ =>
4143 throw(("Couldn't find game by " + gameId))
4244 }
4345 split(playerTicketsStr, " ")
4446 }
4547
4648
4749 @Callable(i)
48-func bet () = {
49- let gameId = toBase58String(i.transactionId)
50+func bet (gameId,gameIdCrypted,tickets) = {
5051 let pmt = extract(i.payment)
5152 let betNotInWaves = isDefined(pmt.assetId)
5253 let feeNotInWaves = isDefined(pmt.assetId)
5354 let playerPubKey58 = toBase58String(i.callerPublicKey)
5455 let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58))
5556 if (betNotInWaves)
5657 then throw("Bet amount must be in Waves")
5758 else if (feeNotInWaves)
5859 then throw("Transaction's fee must be in Waves")
5960 else {
60- let gameDataStr = toString(playerAddress)
61- let betData = [DataEntry(gameId, gameDataStr)]
62- WriteSet(betData)
61+ let rsaSigValid = sigVerify(toBytes(gameId), gameIdCrypted, ServerBetPublicKey)
62+ if (rsaSigValid)
63+ then {
64+ let playerAddressStr = toString(playerAddress)
65+ let betData = [DataEntry((playerAddressStr + "_tickets"), tickets)]
66+ WriteSet(betData)
67+ }
68+ else throw("Invalid RSA signature")
6369 }
6470 }
6571
6672
6773
6874 @Callable(i)
6975 func generateResult (gameId,rsaSignCrypted,lastTicket) = {
7076 let rsaSign = fromBase58String(rsaSignCrypted)
7177 let randTicket = GenerateRandInt(gameId, rsaSign, lastTicket)
7278 let gameResult = [DataEntry((gameId + "_result"), toString(randTicket))]
7379 let playersList = getPlayers(gameId)
7480 let player1Tickets = getPlayersTickets(gameId, playersList[0])
7581 let player1TicketFirst = parseIntValue(player1Tickets[0])
7682 let player1TicketLast = parseIntValue(player1Tickets[1])
7783 if (if ((randTicket >= player1TicketFirst))
7884 then (player1TicketLast >= randTicket)
7985 else false)
8086 then {
8187 let winAmt = 100000000
8288 ScriptResult(WriteSet(gameResult), TransferSet([ScriptTransfer(addressFromStringValue(playersList[0]), winAmt, unit)]))
8389 }
8490 else throw("Player1 not the Winner")
8591 }
8692
8793

github/deemru/w8io/026f985 
42.17 ms