3 | | - | let NONE = "none" |
---|
4 | | - | let usersPubKey = base58'CH6NGp8BFPQ8gm6cPeVG9S3ZWp7m39eQnZU3eTdZgayU' |
---|
5 | | - | let usersAddr = addressFromPublicKey(usersPubKey) |
---|
6 | | - | let btns = base58'EGh2LufqeTEdihgaDz6iZosJtsyY98sqkHX2WP8Csnw4' |
---|
7 | | - | let btnf = base58'7xAHFCPLRSa7XfNNbnd9DMPd9SkgpNfrptFvE4pJE7J' |
---|
8 | | - | func verifier (account) = if ((account == this)) |
---|
9 | | - | then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
10 | | - | else sigVerify(tx.bodyBytes, tx.proofs[0], usersPubKey) |
---|
11 | | - | |
---|
12 | | - | func getStrVar (key) = { |
---|
13 | | - | let str = match key { |
---|
14 | | - | case s: String => |
---|
15 | | - | s |
---|
16 | | - | case b: Boolean => |
---|
17 | | - | toString(b) |
---|
18 | | - | case i: Int => |
---|
19 | | - | toString(i) |
---|
20 | | - | case bv: ByteVector => |
---|
21 | | - | toBase58String(bv) |
---|
22 | | - | case ap: AssetPair => |
---|
23 | | - | ((toBase58String(extract(ap.amountAsset)) + ",") + toBase58String(extract(ap.priceAsset))) |
---|
24 | | - | case u: Unit => |
---|
25 | | - | "empty" |
---|
26 | | - | case _ => |
---|
27 | | - | NONE |
---|
28 | | - | } |
---|
29 | | - | str |
---|
30 | | - | } |
---|
31 | | - | |
---|
32 | | - | func containAddr (a,b) = { |
---|
33 | | - | let addr = toString(addressFromPublicKey(fromBase58String(b))) |
---|
34 | | - | if ((addr == a)) |
---|
35 | | - | then true |
---|
36 | | - | else if (if ((a == true)) |
---|
37 | | - | then (addr != a) |
---|
38 | | - | else false) |
---|
39 | | - | then true |
---|
40 | | - | else a |
---|
41 | | - | } |
---|
42 | | - | |
---|
43 | | - | func containTokenId (a,b) = if ((b == a)) |
---|
44 | | - | then true |
---|
45 | | - | else if (if ((a == true)) |
---|
46 | | - | then (b != a) |
---|
47 | | - | else false) |
---|
48 | | - | then true |
---|
49 | | - | else a |
---|
50 | | - | |
---|
51 | | - | func allowedTransferTokens (assetId) = { |
---|
52 | | - | let tokensIdList = split(getStringValue(addressFromPublicKey(usersPubKey), "allowedTransfers"), ",") |
---|
53 | | - | let contain = { |
---|
54 | | - | let $list14601531 = tokensIdList |
---|
55 | | - | let $size14601531 = size($list14601531) |
---|
56 | | - | let $acc014601531 = toBase58String(extract(assetId)) |
---|
57 | | - | if (($size14601531 == 0)) |
---|
58 | | - | then $acc014601531 |
---|
59 | | - | else { |
---|
60 | | - | let $acc114601531 = containTokenId($acc014601531, $list14601531[0]) |
---|
61 | | - | if (($size14601531 == 1)) |
---|
62 | | - | then $acc114601531 |
---|
63 | | - | else { |
---|
64 | | - | let $acc214601531 = containTokenId($acc114601531, $list14601531[1]) |
---|
65 | | - | if (($size14601531 == 2)) |
---|
66 | | - | then $acc214601531 |
---|
67 | | - | else { |
---|
68 | | - | let $acc314601531 = containTokenId($acc214601531, $list14601531[2]) |
---|
69 | | - | if (($size14601531 == 3)) |
---|
70 | | - | then $acc314601531 |
---|
71 | | - | else { |
---|
72 | | - | let $acc414601531 = containTokenId($acc314601531, $list14601531[3]) |
---|
73 | | - | if (($size14601531 == 4)) |
---|
74 | | - | then $acc414601531 |
---|
75 | | - | else { |
---|
76 | | - | let $acc514601531 = containTokenId($acc414601531, $list14601531[4]) |
---|
77 | | - | if (($size14601531 == 5)) |
---|
78 | | - | then $acc514601531 |
---|
79 | | - | else { |
---|
80 | | - | let $acc614601531 = containTokenId($acc514601531, $list14601531[5]) |
---|
81 | | - | throw("List size exceed 5") |
---|
82 | | - | } |
---|
83 | | - | } |
---|
84 | | - | } |
---|
85 | | - | } |
---|
86 | | - | } |
---|
87 | | - | } |
---|
88 | | - | } |
---|
89 | | - | if (!(isDefined(assetId))) |
---|
90 | | - | then throw("Waves Identificado") |
---|
91 | | - | else if (if (isDefined(assetId)) |
---|
92 | | - | then (contain == true) |
---|
93 | | - | else false) |
---|
94 | | - | then true |
---|
95 | | - | else if (if (isDefined(assetId)) |
---|
96 | | - | then (contain != true) |
---|
97 | | - | else false) |
---|
98 | | - | then throw((("This token ID " + getStrVar(contain)) + " is not allowed to operate in this account")) |
---|
99 | | - | else verifier(usersAddr) |
---|
100 | | - | } |
---|
101 | | - | |
---|
102 | | - | func allowedAddrSponsoredFee (addr) = { |
---|
103 | | - | let addrsList = split(getStringValue(addressFromPublicKey(usersPubKey), "allowedSponsorFee"), ",") |
---|
104 | | - | let contain = { |
---|
105 | | - | let $list19892036 = addrsList |
---|
106 | | - | let $size19892036 = size($list19892036) |
---|
107 | | - | let $acc019892036 = toString(addr) |
---|
108 | | - | if (($size19892036 == 0)) |
---|
109 | | - | then $acc019892036 |
---|
110 | | - | else { |
---|
111 | | - | let $acc119892036 = containAddr($acc019892036, $list19892036[0]) |
---|
112 | | - | if (($size19892036 == 1)) |
---|
113 | | - | then $acc119892036 |
---|
114 | | - | else { |
---|
115 | | - | let $acc219892036 = containAddr($acc119892036, $list19892036[1]) |
---|
116 | | - | if (($size19892036 == 2)) |
---|
117 | | - | then $acc219892036 |
---|
118 | | - | else { |
---|
119 | | - | let $acc319892036 = containAddr($acc219892036, $list19892036[2]) |
---|
120 | | - | if (($size19892036 == 3)) |
---|
121 | | - | then $acc319892036 |
---|
122 | | - | else { |
---|
123 | | - | let $acc419892036 = containAddr($acc319892036, $list19892036[3]) |
---|
124 | | - | if (($size19892036 == 4)) |
---|
125 | | - | then $acc419892036 |
---|
126 | | - | else { |
---|
127 | | - | let $acc519892036 = containAddr($acc419892036, $list19892036[4]) |
---|
128 | | - | if (($size19892036 == 5)) |
---|
129 | | - | then $acc519892036 |
---|
130 | | - | else { |
---|
131 | | - | let $acc619892036 = containAddr($acc519892036, $list19892036[5]) |
---|
132 | | - | throw("List size exceed 5") |
---|
133 | | - | } |
---|
134 | | - | } |
---|
135 | | - | } |
---|
136 | | - | } |
---|
137 | | - | } |
---|
138 | | - | } |
---|
139 | | - | } |
---|
140 | | - | if ((contain != true)) |
---|
141 | | - | then throw((("This address " + getStrVar(contain)) + " is not allowed to operate with the BitNodes sponsored token")) |
---|
142 | | - | else verifier(this) |
---|
143 | | - | } |
---|
144 | | - | |
---|
145 | | - | match tx { |
---|
146 | | - | case t: TransferTransaction => |
---|
147 | | - | if (if ((t.assetId != btnf)) |
---|
148 | | - | then (t.feeAssetId != btnf) |
---|
149 | | - | else false) |
---|
150 | | - | then allowedTransferTokens(t.assetId) |
---|
151 | | - | else if (if ((t.assetId == btnf)) |
---|
152 | | - | then true |
---|
153 | | - | else (t.feeAssetId == btnf)) |
---|
154 | | - | then allowedAddrSponsoredFee(addressFromRecipient(t.recipient)) |
---|
155 | | - | else throw("Operação não autorizada para contas centralizadas na Plataforma BitNodes") |
---|
156 | | - | case o: Order => |
---|
157 | | - | let buyPairs = o.assetPair |
---|
158 | | - | let sellPairs = o.assetPair |
---|
159 | | - | if (isDefined(buyPairs)) |
---|
160 | | - | then throw(((("Order buyPair defined as amount: " + toBase58String(extract(buyPairs.amountAsset))) + "and price: ") + toBase58String(extract(buyPairs.priceAsset)))) |
---|
161 | | - | else if (isDefined(sellPairs)) |
---|
162 | | - | then throw(((("Order sellPair defined as amount: " + toBase58String(extract(buyPairs.amountAsset))) + "and price: ") + toBase58String(extract(buyPairs.priceAsset)))) |
---|
163 | | - | else throw("nenhum par identificado Order") |
---|
164 | | - | case e: ExchangeTransaction => |
---|
165 | | - | let buyPairs = e.buyOrder.assetPair |
---|
166 | | - | let sellPairs = e.sellOrder.assetPair |
---|
167 | | - | if (isDefined(buyPairs)) |
---|
168 | | - | then throw(((("Exchange buyPair defined as amount: " + toBase58String(extract(buyPairs.amountAsset))) + "and price: ") + toBase58String(extract(buyPairs.priceAsset)))) |
---|
169 | | - | else if (isDefined(sellPairs)) |
---|
170 | | - | then throw(((("Exchange sellPair defined as amount: " + toBase58String(extract(buyPairs.amountAsset))) + "and price: ") + toBase58String(extract(buyPairs.priceAsset)))) |
---|
171 | | - | else throw("nenhum par identificado Exchange") |
---|
172 | | - | case b: BurnTransaction => |
---|
173 | | - | verifier(usersAddr) |
---|
174 | | - | case d: DataTransaction => |
---|
175 | | - | verifier(usersAddr) |
---|
176 | | - | case s: SetScriptTransaction => |
---|
177 | | - | verifier(usersAddr) |
---|
178 | | - | case l: LeaseTransaction => |
---|
179 | | - | allowedAddrSponsoredFee(addressFromRecipient(l.recipient)) |
---|
180 | | - | case c: LeaseCancelTransaction => |
---|
181 | | - | verifier(this) |
---|
182 | | - | case _ => |
---|
183 | | - | false |
---|
184 | | - | } |
---|
| 3 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|