15 | | - | func h (g) = valueOrElse(getInteger(this, g), 0) |
---|
16 | | - | |
---|
17 | | - | |
---|
18 | | - | func i (j) = makeString(["%s%d%s", "leaseGroup", toString(j), "nodeList"], c) |
---|
19 | | - | |
---|
20 | | - | |
---|
21 | | - | func k (l) = makeString(["%s%d%s", "lease", toString(l), "amount"], c) |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | func m (l) = makeString(["%s%d%s", "lease", toString(l), "id"], c) |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | func n (o) = makeString(["%s%s%s", "leaseByAddress", o, "id"], c) |
---|
28 | | - | |
---|
29 | | - | |
---|
30 | | - | func p (o) = makeString(["%s%s%s", "leaseByAddress", o, "amount"], c) |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | func q (r) = valueOrElse(getString(makeString(["%s%d%s", "lease", toString(r), "nodeAddress"], c)), "") |
---|
34 | | - | |
---|
35 | | - | |
---|
36 | | - | func s (t) = { |
---|
37 | | - | let o = addressFromStringValue(q(t)) |
---|
38 | | - | let u = k(t) |
---|
39 | | - | let v = h(u) |
---|
40 | | - | let w = m(t) |
---|
41 | | - | let x = value(getBinary(this, w)) |
---|
42 | | - | $Tuple5(o, u, v, w, x) |
---|
| 9 | + | func d (e,f) = { |
---|
| 10 | + | let g = value(blockInfoByHeight(f)) |
---|
| 11 | + | let h = sha256(value(g.vrf)) |
---|
| 12 | + | (toInt(h, 16) % e) |
---|
88 | | - | func Q (R,S) = { |
---|
89 | | - | let T = split(R, c) |
---|
90 | | - | makeString(["%s%d%d%d%d%s%d%d", T[y], T[z], T[A], T[B], T[C], S, toString(lastBlock.height), toString(lastBlock.timestamp)], c) |
---|
91 | | - | } |
---|
92 | | - | |
---|
93 | | - | |
---|
94 | | - | func U (V,W) = { |
---|
95 | | - | let X = addressFromStringValue(e(V, I())) |
---|
96 | | - | if ((scriptHash(V) == unit)) |
---|
97 | | - | then W |
---|
98 | | - | else X |
---|
99 | | - | } |
---|
100 | | - | |
---|
101 | | - | |
---|
102 | | - | func Y (K,Z,aa,ab,ac) = { |
---|
103 | | - | let ad = Lease(K, Z) |
---|
104 | | - | [LeaseCancel(aa), ad, BinaryEntry(ab, calculateLeaseId(ad)), IntegerEntry(ac, Z)] |
---|
105 | | - | } |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | @Callable(ae) |
---|
109 | | - | func rebalanceLeasings (af,j) = { |
---|
110 | | - | let ag = valueOrElse(getString("%s%s__cfg__leasingManagerPub"), "7yMWoR9Je2xrAcgGg9QrqLAQqEGhyfCjfATjktaNdqpk") |
---|
111 | | - | if ((ae.callerPublicKey != fromBase58String(ag))) |
---|
112 | | - | then throw("rebalanceLeasings not authorized") |
---|
113 | | - | else { |
---|
114 | | - | let ah = i(j) |
---|
115 | | - | let ai = split(e(this, ah), c) |
---|
116 | | - | if ((1 > size(ai))) |
---|
117 | | - | then throw(("Empty group " + toString(j))) |
---|
118 | | - | else { |
---|
119 | | - | let aj = ((af / size(ai)) + 1) |
---|
120 | | - | let ak = s(0) |
---|
121 | | - | let al = ak._1 |
---|
122 | | - | let am = ak._2 |
---|
123 | | - | let an = ak._3 |
---|
124 | | - | let ao = ak._4 |
---|
125 | | - | let ap = ak._5 |
---|
126 | | - | func aq (ar,as) = { |
---|
127 | | - | let at = n(as) |
---|
128 | | - | let au = getBinaryValue(this, at) |
---|
129 | | - | let av = p(as) |
---|
130 | | - | let aw = getIntegerValue(this, av) |
---|
131 | | - | (ar ++ Y(addressFromStringValue(as), (aw - aj), au, at, av)) |
---|
132 | | - | } |
---|
133 | | - | |
---|
134 | | - | ({ |
---|
135 | | - | let ax = ai |
---|
136 | | - | let ay = size(ax) |
---|
137 | | - | let az = nil |
---|
138 | | - | func aA (aB,aC) = if ((aC >= ay)) |
---|
139 | | - | then aB |
---|
140 | | - | else aq(aB, ax[aC]) |
---|
141 | | - | |
---|
142 | | - | func aD (aB,aC) = if ((aC >= ay)) |
---|
143 | | - | then aB |
---|
144 | | - | else throw("List size exceeds 8") |
---|
145 | | - | |
---|
146 | | - | aD(aA(aA(aA(aA(aA(aA(aA(aA(az, 0), 1), 2), 3), 4), 5), 6), 7), 8) |
---|
147 | | - | } ++ Y(al, (an + (aj * size(ai))), ap, ao, am)) |
---|
148 | | - | } |
---|
149 | | - | } |
---|
| 22 | + | @Callable(k) |
---|
| 23 | + | func commit () = { |
---|
| 24 | + | let l = (height + a) |
---|
| 25 | + | $Tuple2([IntegerEntry(b(toString(k.caller)), l)], l) |
---|
161 | | - | let aI = i(j) |
---|
162 | | - | let aJ = e(this, aI) |
---|
163 | | - | if (!(contains(aJ, aE))) |
---|
164 | | - | then throw(((("Group " + toString(j)) + " does not contain address ") + aE)) |
---|
165 | | - | else { |
---|
166 | | - | let aK = invoke(a, "replaceApprovedNode", [aE, aF, j, aG], nil) |
---|
167 | | - | if ((aK == aK)) |
---|
168 | | - | then { |
---|
169 | | - | let aL = n(aE) |
---|
170 | | - | let aM = p(aE) |
---|
171 | | - | let aN = getIntegerValue(aM) |
---|
172 | | - | let aO = n(aF) |
---|
173 | | - | let aP = p(aF) |
---|
174 | | - | let aQ = makeString(split(aJ, aE), aF) |
---|
175 | | - | $Tuple2(([DeleteEntry(aL), DeleteEntry(aM), StringEntry(aI, aQ)] ++ Y(addressFromStringValue(aF), aN, getBinaryValue(aL), aO, aP)), unit) |
---|
176 | | - | } |
---|
177 | | - | else throw("Strict value is not equal to itself.") |
---|
178 | | - | } |
---|
| 37 | + | let n = d(e, l) |
---|
| 38 | + | $Tuple2([DeleteEntry(m)], n) |
---|
181 | | - | |
---|
182 | | - | |
---|
183 | | - | |
---|
184 | | - | @Callable(ae) |
---|
185 | | - | func removeCommunityNode (aE,j,aG) = { |
---|
186 | | - | let ag = valueOrElse(getString("%s%s__cfg__leasingManagerPub"), "7yMWoR9Je2xrAcgGg9QrqLAQqEGhyfCjfATjktaNdqpk") |
---|
187 | | - | let aH = fromBase58String(ag) |
---|
188 | | - | if ((ae.callerPublicKey != aH)) |
---|
189 | | - | then throw("removeCommunityNode not authorized") |
---|
190 | | - | else { |
---|
191 | | - | let aI = i(j) |
---|
192 | | - | let aJ = e(this, aI) |
---|
193 | | - | if (!(contains(aJ, aE))) |
---|
194 | | - | then throw(((("Group " + toString(j)) + " does not contain address ") + aE)) |
---|
195 | | - | else { |
---|
196 | | - | let aR = invoke(a, "removeApprovedNode", [aE, aG], nil) |
---|
197 | | - | if ((aR == aR)) |
---|
198 | | - | then { |
---|
199 | | - | let aL = n(aE) |
---|
200 | | - | let aM = p(aE) |
---|
201 | | - | let aN = getIntegerValue(aM) |
---|
202 | | - | let aS = s(0) |
---|
203 | | - | let al = aS._1 |
---|
204 | | - | let am = aS._2 |
---|
205 | | - | let an = aS._3 |
---|
206 | | - | let ao = aS._4 |
---|
207 | | - | let ap = aS._5 |
---|
208 | | - | let aQ = makeString(split(aJ, aE), "") |
---|
209 | | - | $Tuple2(([DeleteEntry(aL), DeleteEntry(aM), StringEntry(aI, aQ)] ++ Y(al, (an + aN), getBinaryValue(aL), ao, am)), unit) |
---|
210 | | - | } |
---|
211 | | - | else throw("Strict value is not equal to itself.") |
---|
212 | | - | } |
---|
213 | | - | } |
---|
214 | | - | } |
---|
215 | | - | |
---|
216 | | - | |
---|
217 | | - | |
---|
218 | | - | @Callable(ae) |
---|
219 | | - | func replaceApprovedNode (aT,aU,j,aG) = if ((ae.caller != b)) |
---|
220 | | - | then throw("permissions denied") |
---|
221 | | - | else { |
---|
222 | | - | let aV = J(aT, "APPROVED") |
---|
223 | | - | let aW = J(aU, "PENDING") |
---|
224 | | - | let aX = e(this, H()) |
---|
225 | | - | if (!(contains(aX, aT))) |
---|
226 | | - | then throw(("approvedNodeList does not contain " + aT)) |
---|
227 | | - | else { |
---|
228 | | - | let aY = makeString_2C(split_4C(aX, aT), aU) |
---|
229 | | - | let aZ = addressFromStringValue(aT) |
---|
230 | | - | let ba = U(aZ, aZ) |
---|
231 | | - | let bb = parseIntValue(split(aV, c)[B]) |
---|
232 | | - | let bc = [StringEntry(H(), aY), DeleteEntry(G(aT)), StringEntry(G(aU), Q(aW, "APPROVED"))] |
---|
233 | | - | $Tuple2(if ((bb > aG)) |
---|
234 | | - | then (bc :+ ScriptTransfer(ba, (bb - aG), unit)) |
---|
235 | | - | else bc, unit) |
---|
236 | | - | } |
---|
237 | | - | } |
---|
238 | | - | |
---|
239 | | - | |
---|
240 | | - | |
---|
241 | | - | @Callable(ae) |
---|
242 | | - | func removeApprovedNode (bd,aG) = if ((ae.caller != b)) |
---|
243 | | - | then throw("permissions denied") |
---|
244 | | - | else { |
---|
245 | | - | let aV = J(bd, "APPROVED") |
---|
246 | | - | let aX = e(this, H()) |
---|
247 | | - | if (!(contains(aX, bd))) |
---|
248 | | - | then throw(("approvedNodeList does not contain " + bd)) |
---|
249 | | - | else { |
---|
250 | | - | let aY = makeString_2C(split_4C(aX, bd), "") |
---|
251 | | - | let K = addressFromStringValue(bd) |
---|
252 | | - | let ba = U(K, K) |
---|
253 | | - | let bb = parseIntValue(split(aV, c)[B]) |
---|
254 | | - | let bc = [StringEntry(H(), aY), DeleteEntry(G(bd))] |
---|
255 | | - | $Tuple2(if ((bb > aG)) |
---|
256 | | - | then (bc :+ ScriptTransfer(ba, (bb - aG), unit)) |
---|
257 | | - | else bc, unit) |
---|
258 | | - | } |
---|
259 | | - | } |
---|
260 | | - | |
---|
261 | | - | |
---|
262 | | - | |
---|
263 | | - | @Callable(ae) |
---|
264 | | - | func returnDeposit (be) = if ((size(ae.payments) != 0)) |
---|
265 | | - | then throw("No payments allowed") |
---|
266 | | - | else { |
---|
267 | | - | let bf = ae.caller |
---|
268 | | - | let bg = G(be) |
---|
269 | | - | let M = getString(this, bg) |
---|
270 | | - | if (!(isDefined(M))) |
---|
271 | | - | then throw(("Address is not applied as neutrino node: " + be)) |
---|
272 | | - | else { |
---|
273 | | - | let bh = e(this, H()) |
---|
274 | | - | if (contains(bh, be)) |
---|
275 | | - | then throw("Impossible to return deposit from approved Node, please contact support team") |
---|
276 | | - | else { |
---|
277 | | - | let O = split(value(M), c) |
---|
278 | | - | let bi = if ((size(O) >= 9)) |
---|
279 | | - | then O[D] |
---|
280 | | - | else "PENDING" |
---|
281 | | - | if ((bi != "PENDING")) |
---|
282 | | - | then throw("Application status is not PENDING!") |
---|
283 | | - | else { |
---|
284 | | - | let bb = parseIntValue(O[B]) |
---|
285 | | - | let o = addressFromStringValue(be) |
---|
286 | | - | let ba = U(o, o) |
---|
287 | | - | if (!(if (if ((bf == this)) |
---|
288 | | - | then true |
---|
289 | | - | else if ((ba != o)) |
---|
290 | | - | then (bf == ba) |
---|
291 | | - | else false) |
---|
292 | | - | then true |
---|
293 | | - | else if ((ba == o)) |
---|
294 | | - | then (bf == o) |
---|
295 | | - | else false)) |
---|
296 | | - | then throw("returnDeposit permissions denied") |
---|
297 | | - | else [DeleteEntry(bg), ScriptTransfer(ba, bb, unit)] |
---|
298 | | - | } |
---|
299 | | - | } |
---|
300 | | - | } |
---|
301 | | - | } |
---|