tx · 35KVwpmxDVBUjuabyihW7iVnAooAQ7kutaKszoDb5LeJ 3N6i9GuByxYceKLWnViaLiRRKhUSjGzxX3w: -0.01400000 Waves 2019.02.02 09:40 [477014] smart account 3N6i9GuByxYceKLWnViaLiRRKhUSjGzxX3w > SELF 0.00000000 Waves
{ "type": 13, "id": "35KVwpmxDVBUjuabyihW7iVnAooAQ7kutaKszoDb5LeJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1549089630275, "version": 1, "sender": "3N6i9GuByxYceKLWnViaLiRRKhUSjGzxX3w", "senderPublicKey": "H5qbKQJj24DNetPBaUed9etUGEPdzh5ef8bPyudKocwX", "proofs": [ "4rAPBPR4EsoV3H388ikJDhsLhFsaq42fWb5B1US77GU86CpfqAk96Qc2yqUwLaYsTSi1ks31gMSAK4YmkswixCRd" ], "script": "base64:AQQAAAACbWUIBQAAAAJ0eAAAAAZzZW5kZXIEAAAABm9yYWNsZQkBAAAAB2V4dHJhY3QAAAABCQEAAAARYWRkcmVzc0Zyb21TdHJpbmcAAAABAgAAACMzTkN6YVlUTkRHdFI4emY5eWZjcWVQRmpDcUZ4OVM1emhzNAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAACndpdGhkcmF3VHgFAAAAByRtYXRjaDAEAAAABHR4SWQJAQAAAAdleHRyYWN0AAAAAQkABB0AAAACBQAAAAJtZQkAAlgAAAABCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAEEAAAAByRtYXRjaDEJAAPoAAAAAQkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAABAwkAAAEAAAACBQAAAAckbWF0Y2gxAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAlwYXltZW50VHgFAAAAByRtYXRjaDEEAAAAEmlzUGF5bWVudFRvb2tQbGFjZQMJAAAAAAAAAgUAAAAEdHhJZAkA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Ym9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkEbbHc", "chainId": 84, "height": 477014, "spentComplexity": 0 } View: original | compacted Prev: HrpNdsUDm5etMKBYuvpuVHL6kZWe9XWGGLY3WBDUvfY1 Next: Hu629T9Fuxf3qJ5mYjdPMbmXNVLQoBGv6dm24spkbr26 Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# CONTENT_TYPE EXPRESSION #-} | |
3 | 3 | let me = tx.sender | |
4 | 4 | let oracle = extract(addressFromString("3NCzaYTNDGtR8zf9yfcqePFjCqFx9S5zhs4")) | |
5 | - | let dataTxFee = 1000000 | |
6 | 5 | match tx { | |
7 | 6 | case withdrawTx: TransferTransaction => | |
8 | 7 | let txId = extract(getString(me, toBase58String(tx.proofs[1]))) | |
12 | 11 | then sigVerify(tx.bodyBytes, tx.proofs[0], paymentTx.senderPublicKey) | |
13 | 12 | else false | |
14 | 13 | let att = paymentTx.attachment | |
14 | + | let feesKey = (toBase58String(tx.proofs[1]) + "_fees") | |
15 | + | let dataTxsFees = extract(getInteger(me, feesKey)) | |
15 | 16 | let type = dropRightBytes(takeRightBytes(att, 2), 1) | |
16 | 17 | let val = takeRightBytes(att, 1) | |
17 | 18 | let key = dropRightBytes(att, 2) | |
18 | - | let heightRes = extract(getInteger(oracle, (toBase58String(key) + "height"))) | |
19 | - | let isCheater = (extract(transactionHeightById(paymentTx.id)) >= heightRes) | |
20 | 19 | let valComplex = extract(getBinary(oracle, toBase58String(key))) | |
21 | 20 | let koeff = if ((type == drop(toBytes(0), 7))) | |
22 | 21 | then 35 | |
31 | 30 | else if ((type == drop(toBytes(5), 7))) | |
32 | 31 | then 2 | |
33 | 32 | else 0 | |
34 | - | let ver = take(valComplex, 1) | |
35 | - | let valReal = if ((type == drop(toBytes(0), 7))) | |
36 | - | then drop(take(valComplex, 2), 1) | |
37 | - | else if ((type == drop(toBytes(1), 7))) | |
38 | - | then drop(take(valComplex, 3), 2) | |
39 | - | else if ((type == drop(toBytes(2), 7))) | |
40 | - | then drop(take(valComplex, 4), 3) | |
41 | - | else if ((type == drop(toBytes(3), 7))) | |
42 | - | then drop(take(valComplex, 5), 4) | |
43 | - | else if ((type == drop(toBytes(4), 7))) | |
44 | - | then drop(take(valComplex, 6), 5) | |
45 | - | else if ((type == drop(toBytes(5), 7))) | |
46 | - | then drop(take(valComplex, 7), 5) | |
47 | - | else toBytes(38) | |
48 | - | let isWin = if ((val == valReal)) | |
49 | - | then (val != toBytes(38)) | |
50 | - | else false | |
51 | - | let isAmountOk = (withdrawTx.amount == (((paymentTx.amount * koeff) - dataTxFee) - withdrawTx.fee)) | |
33 | + | let correctAmount = (((paymentTx.amount * koeff) - dataTxsFees) - withdrawTx.fee) | |
34 | + | let isAmountOk = (withdrawTx.amount == correctAmount) | |
52 | 35 | let isInWaves = if (!(isDefined(withdrawTx.feeAssetId))) | |
53 | 36 | then !(isDefined(withdrawTx.assetId)) | |
54 | 37 | else false | |
55 | - | if (if (if (if (isPaymentTookPlace) | |
56 | - | then isWin | |
57 | - | else false) | |
38 | + | if (if (isPaymentTookPlace) | |
58 | 39 | then isAmountOk | |
59 | 40 | else false) | |
60 | 41 | then isInWaves | |
61 | - | else false) | |
62 | - | then !(isCheater) | |
63 | 42 | else false | |
64 | 43 | case _ => | |
65 | 44 | false | |
66 | 45 | } | |
67 | 46 | case dtx: DataTransaction => | |
68 | 47 | let paymentTxIdStr = extract(dtx.data[0].key) | |
48 | + | let feesKey = (paymentTxIdStr + "_fees") | |
69 | 49 | let paymentTx = transactionById(fromBase58String(paymentTxIdStr)) | |
70 | - | let isFeeCorrect = (dataTxFee >= dtx.fee) | |
50 | + | let newFees = extract(getInteger(dtx.data, feesKey)) | |
51 | + | let oldFees = if (isDefined(getInteger(me, feesKey))) | |
52 | + | then extract(getInteger(me, feesKey)) | |
53 | + | else 0 | |
54 | + | let isFeeCorrect = (newFees == (oldFees + dtx.fee)) | |
71 | 55 | let isPaymentAlreadyMentioned = isDefined(getString(me, paymentTxIdStr)) | |
72 | 56 | let withdrawTransactionId = fromBase58String(extract(getString(me, paymentTxIdStr))) | |
73 | 57 | let isWithdrawExist = isDefined(transactionById(withdrawTransactionId)) | |
74 | 58 | match paymentTx { | |
75 | 59 | case paymentTx: TransferTransaction => | |
76 | 60 | let isDtxSignedByPayer = sigVerify(dtx.bodyBytes, dtx.proofs[0], paymentTx.senderPublicKey) | |
77 | - | if (if (if (!(isPaymentAlreadyMentioned)) | |
61 | + | if (if (if (if (!(isPaymentAlreadyMentioned)) | |
78 | 62 | then true | |
79 | 63 | else !(isWithdrawExist)) | |
80 | 64 | then isDtxSignedByPayer | |
81 | 65 | else false) | |
82 | 66 | then isFeeCorrect | |
67 | + | else false) | |
68 | + | then { | |
69 | + | let att = paymentTx.attachment | |
70 | + | let type = dropRightBytes(takeRightBytes(att, 2), 1) | |
71 | + | let val = takeRightBytes(att, 1) | |
72 | + | let key = dropRightBytes(att, 2) | |
73 | + | let heightRes = extract(getInteger(oracle, (toBase58String(key) + "height"))) | |
74 | + | let isCheater = (extract(transactionHeightById(paymentTx.id)) >= heightRes) | |
75 | + | let valComplex = extract(getBinary(oracle, toBase58String(key))) | |
76 | + | let koeff = if ((type == drop(toBytes(0), 7))) | |
77 | + | then 35 | |
78 | + | else if ((type == drop(toBytes(1), 7))) | |
79 | + | then 1 | |
80 | + | else if ((type == drop(toBytes(2), 7))) | |
81 | + | then 1 | |
82 | + | else if ((type == drop(toBytes(3), 7))) | |
83 | + | then 1 | |
84 | + | else if ((type == drop(toBytes(4), 7))) | |
85 | + | then 2 | |
86 | + | else if ((type == drop(toBytes(5), 7))) | |
87 | + | then 2 | |
88 | + | else 0 | |
89 | + | let ver = take(valComplex, 1) | |
90 | + | let valReal = if ((type == drop(toBytes(0), 7))) | |
91 | + | then drop(take(valComplex, 2), 1) | |
92 | + | else if ((type == drop(toBytes(1), 7))) | |
93 | + | then drop(take(valComplex, 3), 2) | |
94 | + | else if ((type == drop(toBytes(2), 7))) | |
95 | + | then drop(take(valComplex, 4), 3) | |
96 | + | else if ((type == drop(toBytes(3), 7))) | |
97 | + | then drop(take(valComplex, 5), 4) | |
98 | + | else if ((type == drop(toBytes(4), 7))) | |
99 | + | then drop(take(valComplex, 6), 5) | |
100 | + | else if ((type == drop(toBytes(5), 7))) | |
101 | + | then drop(take(valComplex, 7), 5) | |
102 | + | else toBytes(38) | |
103 | + | let isWin = if ((val == valReal)) | |
104 | + | then (val != toBytes(38)) | |
105 | + | else false | |
106 | + | if (isWin) | |
107 | + | then !(isCheater) | |
108 | + | else false | |
109 | + | } | |
83 | 110 | else false | |
84 | 111 | case _ => | |
85 | 112 | false |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 1 #-} | |
2 | 2 | {-# CONTENT_TYPE EXPRESSION #-} | |
3 | 3 | let me = tx.sender | |
4 | 4 | let oracle = extract(addressFromString("3NCzaYTNDGtR8zf9yfcqePFjCqFx9S5zhs4")) | |
5 | - | let dataTxFee = 1000000 | |
6 | 5 | match tx { | |
7 | 6 | case withdrawTx: TransferTransaction => | |
8 | 7 | let txId = extract(getString(me, toBase58String(tx.proofs[1]))) | |
9 | 8 | match transactionById(tx.proofs[1]) { | |
10 | 9 | case paymentTx: TransferTransaction => | |
11 | 10 | let isPaymentTookPlace = if ((txId == toBase58String(tx.id))) | |
12 | 11 | then sigVerify(tx.bodyBytes, tx.proofs[0], paymentTx.senderPublicKey) | |
13 | 12 | else false | |
14 | 13 | let att = paymentTx.attachment | |
14 | + | let feesKey = (toBase58String(tx.proofs[1]) + "_fees") | |
15 | + | let dataTxsFees = extract(getInteger(me, feesKey)) | |
15 | 16 | let type = dropRightBytes(takeRightBytes(att, 2), 1) | |
16 | 17 | let val = takeRightBytes(att, 1) | |
17 | 18 | let key = dropRightBytes(att, 2) | |
18 | - | let heightRes = extract(getInteger(oracle, (toBase58String(key) + "height"))) | |
19 | - | let isCheater = (extract(transactionHeightById(paymentTx.id)) >= heightRes) | |
20 | 19 | let valComplex = extract(getBinary(oracle, toBase58String(key))) | |
21 | 20 | let koeff = if ((type == drop(toBytes(0), 7))) | |
22 | 21 | then 35 | |
23 | 22 | else if ((type == drop(toBytes(1), 7))) | |
24 | 23 | then 1 | |
25 | 24 | else if ((type == drop(toBytes(2), 7))) | |
26 | 25 | then 1 | |
27 | 26 | else if ((type == drop(toBytes(3), 7))) | |
28 | 27 | then 1 | |
29 | 28 | else if ((type == drop(toBytes(4), 7))) | |
30 | 29 | then 2 | |
31 | 30 | else if ((type == drop(toBytes(5), 7))) | |
32 | 31 | then 2 | |
33 | 32 | else 0 | |
34 | - | let ver = take(valComplex, 1) | |
35 | - | let valReal = if ((type == drop(toBytes(0), 7))) | |
36 | - | then drop(take(valComplex, 2), 1) | |
37 | - | else if ((type == drop(toBytes(1), 7))) | |
38 | - | then drop(take(valComplex, 3), 2) | |
39 | - | else if ((type == drop(toBytes(2), 7))) | |
40 | - | then drop(take(valComplex, 4), 3) | |
41 | - | else if ((type == drop(toBytes(3), 7))) | |
42 | - | then drop(take(valComplex, 5), 4) | |
43 | - | else if ((type == drop(toBytes(4), 7))) | |
44 | - | then drop(take(valComplex, 6), 5) | |
45 | - | else if ((type == drop(toBytes(5), 7))) | |
46 | - | then drop(take(valComplex, 7), 5) | |
47 | - | else toBytes(38) | |
48 | - | let isWin = if ((val == valReal)) | |
49 | - | then (val != toBytes(38)) | |
50 | - | else false | |
51 | - | let isAmountOk = (withdrawTx.amount == (((paymentTx.amount * koeff) - dataTxFee) - withdrawTx.fee)) | |
33 | + | let correctAmount = (((paymentTx.amount * koeff) - dataTxsFees) - withdrawTx.fee) | |
34 | + | let isAmountOk = (withdrawTx.amount == correctAmount) | |
52 | 35 | let isInWaves = if (!(isDefined(withdrawTx.feeAssetId))) | |
53 | 36 | then !(isDefined(withdrawTx.assetId)) | |
54 | 37 | else false | |
55 | - | if (if (if (if (isPaymentTookPlace) | |
56 | - | then isWin | |
57 | - | else false) | |
38 | + | if (if (isPaymentTookPlace) | |
58 | 39 | then isAmountOk | |
59 | 40 | else false) | |
60 | 41 | then isInWaves | |
61 | - | else false) | |
62 | - | then !(isCheater) | |
63 | 42 | else false | |
64 | 43 | case _ => | |
65 | 44 | false | |
66 | 45 | } | |
67 | 46 | case dtx: DataTransaction => | |
68 | 47 | let paymentTxIdStr = extract(dtx.data[0].key) | |
48 | + | let feesKey = (paymentTxIdStr + "_fees") | |
69 | 49 | let paymentTx = transactionById(fromBase58String(paymentTxIdStr)) | |
70 | - | let isFeeCorrect = (dataTxFee >= dtx.fee) | |
50 | + | let newFees = extract(getInteger(dtx.data, feesKey)) | |
51 | + | let oldFees = if (isDefined(getInteger(me, feesKey))) | |
52 | + | then extract(getInteger(me, feesKey)) | |
53 | + | else 0 | |
54 | + | let isFeeCorrect = (newFees == (oldFees + dtx.fee)) | |
71 | 55 | let isPaymentAlreadyMentioned = isDefined(getString(me, paymentTxIdStr)) | |
72 | 56 | let withdrawTransactionId = fromBase58String(extract(getString(me, paymentTxIdStr))) | |
73 | 57 | let isWithdrawExist = isDefined(transactionById(withdrawTransactionId)) | |
74 | 58 | match paymentTx { | |
75 | 59 | case paymentTx: TransferTransaction => | |
76 | 60 | let isDtxSignedByPayer = sigVerify(dtx.bodyBytes, dtx.proofs[0], paymentTx.senderPublicKey) | |
77 | - | if (if (if (!(isPaymentAlreadyMentioned)) | |
61 | + | if (if (if (if (!(isPaymentAlreadyMentioned)) | |
78 | 62 | then true | |
79 | 63 | else !(isWithdrawExist)) | |
80 | 64 | then isDtxSignedByPayer | |
81 | 65 | else false) | |
82 | 66 | then isFeeCorrect | |
67 | + | else false) | |
68 | + | then { | |
69 | + | let att = paymentTx.attachment | |
70 | + | let type = dropRightBytes(takeRightBytes(att, 2), 1) | |
71 | + | let val = takeRightBytes(att, 1) | |
72 | + | let key = dropRightBytes(att, 2) | |
73 | + | let heightRes = extract(getInteger(oracle, (toBase58String(key) + "height"))) | |
74 | + | let isCheater = (extract(transactionHeightById(paymentTx.id)) >= heightRes) | |
75 | + | let valComplex = extract(getBinary(oracle, toBase58String(key))) | |
76 | + | let koeff = if ((type == drop(toBytes(0), 7))) | |
77 | + | then 35 | |
78 | + | else if ((type == drop(toBytes(1), 7))) | |
79 | + | then 1 | |
80 | + | else if ((type == drop(toBytes(2), 7))) | |
81 | + | then 1 | |
82 | + | else if ((type == drop(toBytes(3), 7))) | |
83 | + | then 1 | |
84 | + | else if ((type == drop(toBytes(4), 7))) | |
85 | + | then 2 | |
86 | + | else if ((type == drop(toBytes(5), 7))) | |
87 | + | then 2 | |
88 | + | else 0 | |
89 | + | let ver = take(valComplex, 1) | |
90 | + | let valReal = if ((type == drop(toBytes(0), 7))) | |
91 | + | then drop(take(valComplex, 2), 1) | |
92 | + | else if ((type == drop(toBytes(1), 7))) | |
93 | + | then drop(take(valComplex, 3), 2) | |
94 | + | else if ((type == drop(toBytes(2), 7))) | |
95 | + | then drop(take(valComplex, 4), 3) | |
96 | + | else if ((type == drop(toBytes(3), 7))) | |
97 | + | then drop(take(valComplex, 5), 4) | |
98 | + | else if ((type == drop(toBytes(4), 7))) | |
99 | + | then drop(take(valComplex, 6), 5) | |
100 | + | else if ((type == drop(toBytes(5), 7))) | |
101 | + | then drop(take(valComplex, 7), 5) | |
102 | + | else toBytes(38) | |
103 | + | let isWin = if ((val == valReal)) | |
104 | + | then (val != toBytes(38)) | |
105 | + | else false | |
106 | + | if (isWin) | |
107 | + | then !(isCheater) | |
108 | + | else false | |
109 | + | } | |
83 | 110 | else false | |
84 | 111 | case _ => | |
85 | 112 | false | |
86 | 113 | } | |
87 | 114 | case _ => | |
88 | 115 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
89 | 116 | } |
github/deemru/w8io/169f3d6 50.38 ms ◑