3 | | - | let me = tx.sender |
---|
4 | | - | let oracle = extract(addressFromString("3NCzaYTNDGtR8zf9yfcqePFjCqFx9S5zhs4")) |
---|
5 | | - | let dataTxFee = 1000000 |
---|
6 | | - | match tx { |
---|
7 | | - | case withdrawTx: TransferTransaction => |
---|
8 | | - | let txId = extract(getString(me, toBase58String(tx.proofs[1]))) |
---|
9 | | - | match transactionById(tx.proofs[1]) { |
---|
10 | | - | case paymentTx: TransferTransaction => |
---|
11 | | - | let isPaymentTookPlace = if ((txId == toBase58String(tx.id))) |
---|
12 | | - | then sigVerify(tx.bodyBytes, tx.proofs[0], paymentTx.senderPublicKey) |
---|
13 | | - | else false |
---|
14 | | - | let att = paymentTx.attachment |
---|
15 | | - | let type = dropRightBytes(takeRightBytes(att, 2), 1) |
---|
16 | | - | let val = takeRightBytes(att, 1) |
---|
17 | | - | let key = dropRightBytes(att, 2) |
---|
18 | | - | let heightRes = extract(getInteger(oracle, (toBase58String(key) + "height"))) |
---|
19 | | - | let isCheater = (extract(transactionHeightById(paymentTx.id)) >= heightRes) |
---|
20 | | - | let valComplex = extract(getBinary(oracle, toBase58String(key))) |
---|
21 | | - | let koeff = if ((type == drop(toBytes(0), 7))) |
---|
22 | | - | then 35 |
---|
23 | | - | else if ((type == drop(toBytes(1), 7))) |
---|
24 | | - | then 1 |
---|
25 | | - | else if ((type == drop(toBytes(2), 7))) |
---|
26 | | - | then 1 |
---|
27 | | - | else if ((type == drop(toBytes(3), 7))) |
---|
28 | | - | then 1 |
---|
29 | | - | else if ((type == drop(toBytes(4), 7))) |
---|
30 | | - | then 2 |
---|
31 | | - | else if ((type == drop(toBytes(5), 7))) |
---|
32 | | - | then 2 |
---|
33 | | - | 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)) |
---|
52 | | - | let isInWaves = if (!(isDefined(withdrawTx.feeAssetId))) |
---|
53 | | - | then !(isDefined(withdrawTx.assetId)) |
---|
54 | | - | else false |
---|
55 | | - | if (if (if (if (isPaymentTookPlace) |
---|
56 | | - | then isWin |
---|
57 | | - | else false) |
---|
58 | | - | then isAmountOk |
---|
59 | | - | else false) |
---|
60 | | - | then isInWaves |
---|
61 | | - | else false) |
---|
62 | | - | then !(isCheater) |
---|
63 | | - | else false |
---|
64 | | - | case _ => |
---|
65 | | - | false |
---|
66 | | - | } |
---|
67 | | - | case dtx: DataTransaction => |
---|
68 | | - | let paymentTxIdStr = extract(dtx.data[0].key) |
---|
69 | | - | let paymentTx = transactionById(fromBase58String(paymentTxIdStr)) |
---|
70 | | - | let isFeeCorrect = (dataTxFee >= dtx.fee) |
---|
71 | | - | let isPaymentAlreadyMentioned = isDefined(getString(me, paymentTxIdStr)) |
---|
72 | | - | let withdrawTransactionId = fromBase58String(extract(getString(me, paymentTxIdStr))) |
---|
73 | | - | let isWithdrawExist = isDefined(transactionById(withdrawTransactionId)) |
---|
74 | | - | match paymentTx { |
---|
75 | | - | case paymentTx: TransferTransaction => |
---|
76 | | - | let isDtxSignedByPayer = sigVerify(dtx.bodyBytes, dtx.proofs[0], paymentTx.senderPublicKey) |
---|
77 | | - | if (if (if (!(isPaymentAlreadyMentioned)) |
---|
78 | | - | then true |
---|
79 | | - | else !(isWithdrawExist)) |
---|
80 | | - | then isDtxSignedByPayer |
---|
81 | | - | else false) |
---|
82 | | - | then isFeeCorrect |
---|
83 | | - | else false |
---|
84 | | - | case _ => |
---|
85 | | - | false |
---|
86 | | - | } |
---|
87 | | - | case _ => |
---|
88 | | - | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
89 | | - | } |
---|
| 3 | + | true |
---|