6 | | - | case withdrawTx: TransferTransaction => |
---|
7 | | - | let txId = extract(getString(me, toBase58String(tx.proofs[1]))) |
---|
8 | | - | match transactionById(tx.proofs[1]) { |
---|
9 | | - | case paymentTx: TransferTransaction => |
---|
10 | | - | let isPaymentTookPlace = if ((txId == toBase58String(tx.id))) |
---|
11 | | - | then sigVerify(tx.bodyBytes, tx.proofs[0], paymentTx.senderPublicKey) |
---|
12 | | - | else false |
---|
13 | | - | let att = drop(paymentTx.attachment, 22) |
---|
14 | | - | let key = take(att, 8) |
---|
15 | | - | let type = drop(take(att, 9), 8) |
---|
16 | | - | let val = drop(take(att, 10), 9) |
---|
17 | | - | let valComplex = extract(getBinary(oracle, toBase58String(key))) |
---|
18 | | - | let koeff = if ((type == drop(toBytes(0), 7))) |
---|
19 | | - | then 35 |
---|
20 | | - | else if ((type == drop(toBytes(1), 7))) |
---|
| 5 | + | case t: TransferTransaction => |
---|
| 6 | + | let att0 = t.attachment |
---|
| 7 | + | let att = drop(t.attachment, 22) |
---|
| 8 | + | let key = take(att, 8) |
---|
| 9 | + | let type = drop(take(att, 9), 8) |
---|
| 10 | + | let val = drop(take(att, 10), 9) |
---|
| 11 | + | let key58 = toBase58String(key) |
---|
| 12 | + | let valComplex = extract(getBinary(me, key58)) |
---|
| 13 | + | let koeff = if ((type == drop(toBytes(0), 7))) |
---|
| 14 | + | then 35 |
---|
| 15 | + | else if ((type == drop(toBytes(1), 7))) |
---|
| 16 | + | then 1 |
---|
| 17 | + | else if ((type == drop(toBytes(2), 7))) |
---|
| 18 | + | then 1 |
---|
| 19 | + | else if ((type == drop(toBytes(3), 7))) |
---|
28 | | - | else if ((type == drop(toBytes(5), 7))) |
---|
29 | | - | then 2 |
---|
30 | | - | else if ((type == drop(toBytes(6), 7))) |
---|
31 | | - | then 2 |
---|
32 | | - | else 0 |
---|
33 | | - | let ver = take(valComplex, 1) |
---|
34 | | - | let valReal = if ((type == drop(toBytes(0), 7))) |
---|
35 | | - | then drop(take(valComplex, 2), 1) |
---|
36 | | - | else if ((type == drop(toBytes(1), 7))) |
---|
37 | | - | then drop(take(valComplex, 3), 2) |
---|
38 | | - | else if ((type == drop(toBytes(2), 7))) |
---|
39 | | - | then drop(take(valComplex, 4), 3) |
---|
40 | | - | else if ((type == drop(toBytes(3), 7))) |
---|
41 | | - | then drop(take(valComplex, 5), 4) |
---|
42 | | - | else if ((type == drop(toBytes(4), 7))) |
---|
43 | | - | then drop(take(valComplex, 6), 5) |
---|
44 | | - | else if ((type == drop(toBytes(5), 7))) |
---|
45 | | - | then drop(take(valComplex, 7), 5) |
---|
46 | | - | else if ((type == drop(toBytes(6), 7))) |
---|
47 | | - | then drop(take(valComplex, 8), 6) |
---|
48 | | - | else toBytes(38) |
---|
49 | | - | let isWin = if ((val == valReal)) |
---|
50 | | - | then (val != toBytes(38)) |
---|
51 | | - | else false |
---|
52 | | - | let isAmountOk = (withdrawTx.amount == (paymentTx.amount * koeff)) |
---|
53 | | - | if (if (isPaymentTookPlace) |
---|
54 | | - | then isWin |
---|
55 | | - | else false) |
---|
56 | | - | then isAmountOk |
---|
57 | | - | else false |
---|
58 | | - | case _ => |
---|
59 | | - | false |
---|
60 | | - | } |
---|
61 | | - | case dtx: DataTransaction => |
---|
62 | | - | let paymentTxIdStr = extract(dtx.data[0].key) |
---|
63 | | - | let paymentTx = transactionById(fromBase58String(paymentTxIdStr)) |
---|
64 | | - | let isPaymentAlreadyMentioned = isDefined(getString(me, paymentTxIdStr)) |
---|
65 | | - | let withdrawTransactionId = fromBase58String(extract(getString(me, paymentTxIdStr))) |
---|
66 | | - | let isWithdrawExist = isDefined(transactionById(withdrawTransactionId)) |
---|
67 | | - | match paymentTx { |
---|
68 | | - | case paymentTx: TransferTransaction => |
---|
69 | | - | let isDtxSignedByPayer = sigVerify(dtx.bodyBytes, dtx.proofs[0], paymentTx.senderPublicKey) |
---|
70 | | - | if (if (!(isPaymentAlreadyMentioned)) |
---|
71 | | - | then true |
---|
72 | | - | else !(isWithdrawExist)) |
---|
73 | | - | then isDtxSignedByPayer |
---|
74 | | - | else false |
---|
75 | | - | case _ => |
---|
76 | | - | false |
---|
77 | | - | } |
---|
| 27 | + | else 0 |
---|
| 28 | + | let ver = take(valComplex, 1) |
---|
| 29 | + | let valReal = if ((type == drop(toBytes(0), 7))) |
---|
| 30 | + | then drop(take(valComplex, 2), 1) |
---|
| 31 | + | else if ((type == drop(toBytes(1), 7))) |
---|
| 32 | + | then drop(take(valComplex, 3), 2) |
---|
| 33 | + | else if ((type == drop(toBytes(2), 7))) |
---|
| 34 | + | then drop(take(valComplex, 4), 3) |
---|
| 35 | + | else if ((type == drop(toBytes(3), 7))) |
---|
| 36 | + | then drop(take(valComplex, 5), 4) |
---|
| 37 | + | else if ((type == drop(toBytes(4), 7))) |
---|
| 38 | + | then drop(take(valComplex, 6), 5) |
---|
| 39 | + | else if ((type == drop(toBytes(5), 7))) |
---|
| 40 | + | then drop(take(valComplex, 7), 5) |
---|
| 41 | + | else if ((type == drop(toBytes(6), 7))) |
---|
| 42 | + | then drop(take(valComplex, 8), 6) |
---|
| 43 | + | else toBytes(38) |
---|
| 44 | + | if ((val == valReal)) |
---|
| 45 | + | then (val != toBytes(38)) |
---|
| 46 | + | else false |
---|