tx · 3XQTdkT9vwstyExYtVmb4X6CNQ9ENdDo61WLcryyndAC 3N8kB3UEjWWvTRBtGpGUErAevaK2q6u2eCM: -0.01000000 Waves 2023.11.02 12:38 [2825548] smart account 3N8kB3UEjWWvTRBtGpGUErAevaK2q6u2eCM > SELF 0.00000000 Waves
{ "type": 13, "id": "3XQTdkT9vwstyExYtVmb4X6CNQ9ENdDo61WLcryyndAC", "fee": 1000000, "feeAssetId": null, "timestamp": 1698917936940, "version": 2, "chainId": 84, "sender": "3N8kB3UEjWWvTRBtGpGUErAevaK2q6u2eCM", "senderPublicKey": "6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM", "proofs": [ "36gK1aAdkLH2kMrR4nQe97oPVWHVmkbhEc4jCYmtUmX2G7X3vPTdHYvRHiQGrDcgWc4AJEhE18Vn2yxdqCjAKJHa" ], "script": "base64:BgITCAISAwoBAhIAEgMKAQESAwoBAg4AB293bmVyUGsBIFjKQnTzuTU7kMfPWIFrhrNM3EW8gc9F3rO/tY+FuNJcAAtkZW5vbWluYXRvcgCAwtcvAAp0cmFuc2ZlclZrAcQGSYrHhkeDrw+dFMD6Yr/Vrvr2pPyDHCWoMO8w9LxFaQABrVkxqK1PRfgZw0t9bDNsxFEJNHhErc9XHTkkU1OiEYYWiz2VdqW6jQewS86Z3lshxW6Fdf1MU0MDPt1NoikSf2YEIBvI+gscAfqmtvJxZbkVA/Lrr7r+HyVUoZGt1QB46Zv9umeZBwmTWiDHaLPPgOVOWQAVYLMCwpEzEzIdF2C8KzI/CsCeCv3raf56RXmhFAWuJCbMtO6My12PxFQDRv98IWP0FGhY/m6sQ/9r58GInq4bSVYWKlGucbXbayaYF35Fp3o6VaRXVWzJ6FesrH8dS+DxeadscnAN4IQEB4J5YcwZvAX/fjE5JEHNC4WrNfiUe+fe6FAQ4ttHlRgKS+PbN1butH1dDkfQkBKC5Om0WI3D45eaRbN6Taxt7ha5xCUwGVh0LQ+Wf/j9bY+un1Cwur9wx+HmB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HMFB2RhdGFPcHMFBmZlZU9wcwkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAEByRtYXRjaDAFAnR4AwkAAQIFByRtYXRjaDACFFNldFNjcmlwdFRyYW5zYWN0aW9uBAFkBQckbWF0Y2gwCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQdvd25lclBrAwkAAQIFByRtYXRjaDACF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAFkBQckbWF0Y2gwBAckbWF0Y2gxCAUBZAhmdW5jdGlvbgMJAAACAg1zZXRPcGVyYXRvclBrBQckbWF0Y2gxCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQdvd25lclBrAwkAAAICCHRyYW5zYWN0BQckbWF0Y2gxBApvcGVyYXRvclBrCQENZ2V0T3BlcmF0b3JQawAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFCm9wZXJhdG9yUGsJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkHFmmpng==", "height": 2825548, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6VnwRiznJbm2wm3FFpwUmQi9fN8Bo25so8dhNKFFaoJo Next: 9bgCno2uV9NBNaan1MSRAjVzoY9Yidpe6MKPf2XUEbae Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let operatorPk = base58'6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM' | |
5 | - | ||
6 | - | let operatorAddress = addressFromPublicKey(operatorPk) | |
4 | + | let ownerPk = base58'6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM' | |
7 | 5 | ||
8 | 6 | let denominator = 100000000 | |
9 | 7 | ||
26 | 24 | ||
27 | 25 | let allMessagesHashKey = "AllMessagesHash" | |
28 | 26 | ||
27 | + | let operatorKey = "OperatorPk" | |
28 | + | ||
29 | 29 | func takeExt (v,from,to) = drop(take(v, to), from) | |
30 | 30 | ||
31 | 31 | ||
44 | 44 | then throw("Not enough balance") | |
45 | 45 | else [IntegerEntry(currentKey, newAmount)] | |
46 | 46 | } | |
47 | + | ||
48 | + | ||
49 | + | func getOperatorPk () = match getBinary(operatorKey) { | |
50 | + | case a: ByteVector => | |
51 | + | a | |
52 | + | case _ => | |
53 | + | ownerPk | |
54 | + | } | |
55 | + | ||
56 | + | ||
57 | + | @Callable(i) | |
58 | + | func setOperatorPk (pk) = if ((size(pk) != 32)) | |
59 | + | then throw("Operator public key must be 32 bytes long") | |
60 | + | else [BinaryEntry(operatorKey, pk)] | |
61 | + | ||
47 | 62 | ||
48 | 63 | ||
49 | 64 | @Callable(i) | |
87 | 102 | ||
88 | 103 | @Callable(i) | |
89 | 104 | func transact (tx) = { | |
105 | + | let operatorPk = getOperatorPk() | |
106 | + | let operatorAddress = addressFromPublicKey(operatorPk) | |
90 | 107 | let nullifier = takeExt(tx, 0, 32) | |
91 | 108 | let outCommit = takeExt(tx, 32, 64) | |
92 | 109 | let assetId = takeExt(tx, 64, 96) | |
99 | 116 | let treeProof = takeExt(tx, 384, 640) | |
100 | 117 | let rootAfter = takeExt(tx, 640, 672) | |
101 | 118 | let txType = toInt(takeExt(tx, 672, 674)) | |
102 | - | let $ | |
119 | + | let $t060396401 = if ((txType == 0)) | |
103 | 120 | then { | |
104 | 121 | let depositDataSize = (32 + 64) | |
105 | 122 | let depositPk = dropRight(takeRight(tx, depositDataSize), 64) | |
107 | 124 | $Tuple3(takeExt(tx, 674, (size(tx) - depositDataSize)), depositPk, depositSignature) | |
108 | 125 | } | |
109 | 126 | else $Tuple3(takeExt(tx, 674, size(tx)), unit, unit) | |
110 | - | let memo = $ | |
111 | - | let depositPk = $ | |
112 | - | let depositSignature = $ | |
127 | + | let memo = $t060396401._1 | |
128 | + | let depositPk = $t060396401._2 | |
129 | + | let depositSignature = $t060396401._3 | |
113 | 130 | let fee = toInt(takeExt(memo, 0, 8)) | |
114 | 131 | let allMessagesHash = valueOrElse(getBinary(allMessagesHashKey), toBytes(toBigInt(0))) | |
115 | 132 | let memoHash = keccak256(memo) | |
161 | 178 | } | |
162 | 179 | else nil | |
163 | 180 | if ((txIndex > poolIndex)) | |
164 | - | then throw(" | |
181 | + | then throw("Invalid transaction index") | |
165 | 182 | else if (!(bn256Groth16Verify_5inputs(transferVk, txProof, transferInputs))) | |
166 | 183 | then throw("Tx proof is invalid") | |
167 | 184 | else if (!(bn256Groth16Verify_3inputs(treeVk, treeProof, treeInputs))) | |
177 | 194 | @Verifier(tx) | |
178 | 195 | func verify () = match tx { | |
179 | 196 | case d: SetScriptTransaction => | |
180 | - | sigVerify(tx.bodyBytes, tx.proofs[0], operatorPk) | |
197 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPk) | |
198 | + | case d: InvokeScriptTransaction => | |
199 | + | match d.function { | |
200 | + | case _ => | |
201 | + | if (("setOperatorPk" == $match1)) | |
202 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPk) | |
203 | + | else if (("transact" == $match1)) | |
204 | + | then { | |
205 | + | let operatorPk = getOperatorPk() | |
206 | + | sigVerify(tx.bodyBytes, tx.proofs[0], operatorPk) | |
207 | + | } | |
208 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
209 | + | } | |
181 | 210 | case _ => | |
182 | 211 | false | |
183 | 212 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let operatorPk = base58'6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM' | |
5 | - | ||
6 | - | let operatorAddress = addressFromPublicKey(operatorPk) | |
4 | + | let ownerPk = base58'6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM' | |
7 | 5 | ||
8 | 6 | let denominator = 100000000 | |
9 | 7 | ||
10 | 8 | let transferVk = base64'SYrHhkeDrw+dFMD6Yr/Vrvr2pPyDHCWoMO8w9LxFaQABrVkxqK1PRfgZw0t9bDNsxFEJNHhErc9XHTkkU1OiEYYWiz2VdqW6jQewS86Z3lshxW6Fdf1MU0MDPt1NoikSf2YEIBvI+gscAfqmtvJxZbkVA/Lrr7r+HyVUoZGt1QB46Zv9umeZBwmTWiDHaLPPgOVOWQAVYLMCwpEzEzIdF2C8KzI/CsCeCv3raf56RXmhFAWuJCbMtO6My12PxFQDRv98IWP0FGhY/m6sQ/9r58GInq4bSVYWKlGucbXbayaYF35Fp3o6VaRXVWzJ6FesrH8dS+DxeadscnAN4IQEB4J5YcwZvAX/fjE5JEHNC4WrNfiUe+fe6FAQ4ttHlRgKS+PbN1butH1dDkfQkBKC5Om0WI3D45eaRbN6Taxt7ha5xCUwGVh0LQ+Wf/j9bY+un1Cwur9wx+HmB6PPGC2pEFLSQhkZjtvNJTs6e1c0i3FAOhFDSNqEjcqORSer2aUGdJMXhB6YEv/XcumUDyQbem+f0wX2qOgtwVFLtGOq7S65sHzNcHpdJP/htHnhqkQErwmjDG/JTs9oc1mu5jOsGAYAAAAovMt7vHGhKq+EA+6JlSFfVMj7aU/V67EpBI64f73xJKTpnqCOEMhaQMegFHTJ/W5Cp9iTd4i3AqnoTQj+L1UOXKmddpvHhg0WJHFbosaPhv8EY7+cAaHmn1JPO30BBRPqTsN53lfykgE2oF9vGPyU4u0Y3Oh8YG2p7I2Oz+NaKkzrJo2SamjhbLOofkEX14HbjdZLWD5T07/J4qfaYb8Eervvcr/H2IS0GJ7UFTdqJGwWa/1IZZF6RN8rj5y8xg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BDfa99z0alUbwyBBd8odwfJU7bERsH/SfhNempxiwEU1uq6TPQ2NxgN3fgXo5i9dHrSaI2ZQd7R9hyJVeMlBaz6uP4gS1XYlt5LkT+TFGT/vidKlcMHQx945x1Iivq728eKgJ4aBI5Ja1nxj7QC7d98xukukQl' | |
13 | 11 | ||
14 | 12 | let initialRoot = toBytes(parseBigIntValue("11469701942666298368112882412133877458305516134926649826543144744382391691533")) | |
15 | 13 | ||
16 | 14 | func getRootKey (index) = ("R:" + toString(index)) | |
17 | 15 | ||
18 | 16 | ||
19 | 17 | func getNullifierKey (nullifier) = ("N:" + toBase58String(nullifier)) | |
20 | 18 | ||
21 | 19 | ||
22 | 20 | func getDepositKey (address) = ("D:" + toBase58String(address)) | |
23 | 21 | ||
24 | 22 | ||
25 | 23 | let poolIndexKey = "PoolIndex" | |
26 | 24 | ||
27 | 25 | let allMessagesHashKey = "AllMessagesHash" | |
28 | 26 | ||
27 | + | let operatorKey = "OperatorPk" | |
28 | + | ||
29 | 29 | func takeExt (v,from,to) = drop(take(v, to), from) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func spendDeposit (address,amount) = { | |
33 | 33 | let currentKey = getDepositKey(address.bytes) | |
34 | 34 | let currentAmount = match getInteger(currentKey) { | |
35 | 35 | case a: Int => | |
36 | 36 | a | |
37 | 37 | case _ => | |
38 | 38 | 0 | |
39 | 39 | } | |
40 | 40 | let newAmount = (currentAmount - amount) | |
41 | 41 | if ((0 > amount)) | |
42 | 42 | then throw("Can't spend negative amount") | |
43 | 43 | else if ((0 > newAmount)) | |
44 | 44 | then throw("Not enough balance") | |
45 | 45 | else [IntegerEntry(currentKey, newAmount)] | |
46 | 46 | } | |
47 | + | ||
48 | + | ||
49 | + | func getOperatorPk () = match getBinary(operatorKey) { | |
50 | + | case a: ByteVector => | |
51 | + | a | |
52 | + | case _ => | |
53 | + | ownerPk | |
54 | + | } | |
55 | + | ||
56 | + | ||
57 | + | @Callable(i) | |
58 | + | func setOperatorPk (pk) = if ((size(pk) != 32)) | |
59 | + | then throw("Operator public key must be 32 bytes long") | |
60 | + | else [BinaryEntry(operatorKey, pk)] | |
61 | + | ||
47 | 62 | ||
48 | 63 | ||
49 | 64 | @Callable(i) | |
50 | 65 | func deposit () = { | |
51 | 66 | let pmt = value(i.payments[0]) | |
52 | 67 | if (isDefined(pmt.assetId)) | |
53 | 68 | then throw("Only WAVES is allowed at the moment") | |
54 | 69 | else { | |
55 | 70 | let currentKey = getDepositKey(i.caller.bytes) | |
56 | 71 | let currentAmount = match getInteger(this, currentKey) { | |
57 | 72 | case a: Int => | |
58 | 73 | a | |
59 | 74 | case _ => | |
60 | 75 | 0 | |
61 | 76 | } | |
62 | 77 | let newAmount = (currentAmount + pmt.amount) | |
63 | 78 | [IntegerEntry(currentKey, newAmount)] | |
64 | 79 | } | |
65 | 80 | } | |
66 | 81 | ||
67 | 82 | ||
68 | 83 | ||
69 | 84 | @Callable(i) | |
70 | 85 | func withdraw (amount) = { | |
71 | 86 | let currentKey = getDepositKey(i.caller.bytes) | |
72 | 87 | let currentAmount = match getInteger(this, currentKey) { | |
73 | 88 | case a: Int => | |
74 | 89 | a | |
75 | 90 | case _ => | |
76 | 91 | 0 | |
77 | 92 | } | |
78 | 93 | let newAmount = (currentAmount - amount) | |
79 | 94 | if ((0 > amount)) | |
80 | 95 | then throw("Can't withdraw negative amount") | |
81 | 96 | else if ((0 > newAmount)) | |
82 | 97 | then throw("Not enough balance") | |
83 | 98 | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)] | |
84 | 99 | } | |
85 | 100 | ||
86 | 101 | ||
87 | 102 | ||
88 | 103 | @Callable(i) | |
89 | 104 | func transact (tx) = { | |
105 | + | let operatorPk = getOperatorPk() | |
106 | + | let operatorAddress = addressFromPublicKey(operatorPk) | |
90 | 107 | let nullifier = takeExt(tx, 0, 32) | |
91 | 108 | let outCommit = takeExt(tx, 32, 64) | |
92 | 109 | let assetId = takeExt(tx, 64, 96) | |
93 | 110 | let delta = takeExt(tx, 96, 128) | |
94 | 111 | let nativeAmount = toInt(takeExt(delta, 0, 8)) | |
95 | 112 | let nativeEnergy = toInt(takeExt(delta, 8, 22)) | |
96 | 113 | let txIndex = toInt(takeExt(delta, 22, 28)) | |
97 | 114 | let _poolId = takeExt(delta, 28, 31) | |
98 | 115 | let txProof = takeExt(tx, 128, 384) | |
99 | 116 | let treeProof = takeExt(tx, 384, 640) | |
100 | 117 | let rootAfter = takeExt(tx, 640, 672) | |
101 | 118 | let txType = toInt(takeExt(tx, 672, 674)) | |
102 | - | let $ | |
119 | + | let $t060396401 = if ((txType == 0)) | |
103 | 120 | then { | |
104 | 121 | let depositDataSize = (32 + 64) | |
105 | 122 | let depositPk = dropRight(takeRight(tx, depositDataSize), 64) | |
106 | 123 | let depositSignature = takeRight(tx, 64) | |
107 | 124 | $Tuple3(takeExt(tx, 674, (size(tx) - depositDataSize)), depositPk, depositSignature) | |
108 | 125 | } | |
109 | 126 | else $Tuple3(takeExt(tx, 674, size(tx)), unit, unit) | |
110 | - | let memo = $ | |
111 | - | let depositPk = $ | |
112 | - | let depositSignature = $ | |
127 | + | let memo = $t060396401._1 | |
128 | + | let depositPk = $t060396401._2 | |
129 | + | let depositSignature = $t060396401._3 | |
113 | 130 | let fee = toInt(takeExt(memo, 0, 8)) | |
114 | 131 | let allMessagesHash = valueOrElse(getBinary(allMessagesHashKey), toBytes(toBigInt(0))) | |
115 | 132 | let memoHash = keccak256(memo) | |
116 | 133 | let hashes = (allMessagesHash + memoHash) | |
117 | 134 | let newAllMessagesHash = keccak256(hashes) | |
118 | 135 | let rootBefore = valueOrElse(getBinary(getRootKey(txIndex)), initialRoot) | |
119 | 136 | if ((rootBefore == rootBefore)) | |
120 | 137 | then { | |
121 | 138 | let poolIndex = valueOrElse(getInteger(poolIndexKey), 0) | |
122 | 139 | let poolRoot = valueOrElse(getBinary(getRootKey(poolIndex)), initialRoot) | |
123 | 140 | let nullifierExists = match getBinary(getNullifierKey(nullifier)) { | |
124 | 141 | case a: Unit => | |
125 | 142 | false | |
126 | 143 | case _ => | |
127 | 144 | true | |
128 | 145 | } | |
129 | 146 | let transferInputs = ((((memoHash + nullifier) + outCommit) + delta) + memoHash) | |
130 | 147 | let treeInputs = ((poolRoot + rootAfter) + outCommit) | |
131 | 148 | let dataOps = [BinaryEntry(getRootKey(txIndex), rootAfter), BinaryEntry(getNullifierKey(nullifier), keccak256((outCommit + delta))), IntegerEntry(poolIndexKey, (poolIndex + 128)), BinaryEntry(allMessagesHashKey, newAllMessagesHash)] | |
132 | 149 | let txOps = match txType { | |
133 | 150 | case _ => | |
134 | 151 | if ((0 == $match0)) | |
135 | 152 | then { | |
136 | 153 | let depositPkValue = value(depositPk) | |
137 | 154 | let depositAddress = addressFromPublicKey(depositPkValue) | |
138 | 155 | if ((0 > nativeAmount)) | |
139 | 156 | then throw("Can't deposit negative amount") | |
140 | 157 | else if (!(sigVerify_8Kb((nullifier + depositPkValue), value(depositSignature), depositPkValue))) | |
141 | 158 | then throw("Invalid deposit signature") | |
142 | 159 | else spendDeposit(depositAddress, (nativeAmount * denominator)) | |
143 | 160 | } | |
144 | 161 | else if ((1 == $match0)) | |
145 | 162 | then if ((nativeAmount != 0)) | |
146 | 163 | then throw("Native amount must be zero for transfers") | |
147 | 164 | else nil | |
148 | 165 | else if ((2 == $match0)) | |
149 | 166 | then { | |
150 | 167 | let withdrawAmount = (toInt(takeExt(memo, 8, 16)) * denominator) | |
151 | 168 | if ((withdrawAmount > 0)) | |
152 | 169 | then throw("Withdraw amount must be positive") | |
153 | 170 | else [ScriptTransfer(i.caller, -(withdrawAmount), unit)] | |
154 | 171 | } | |
155 | 172 | else throw("Unknown tx type") | |
156 | 173 | } | |
157 | 174 | let feeOps = if ((fee > 0)) | |
158 | 175 | then { | |
159 | 176 | let totalFee = (fee * denominator) | |
160 | 177 | [ScriptTransfer(operatorAddress, fee, unit)] | |
161 | 178 | } | |
162 | 179 | else nil | |
163 | 180 | if ((txIndex > poolIndex)) | |
164 | - | then throw(" | |
181 | + | then throw("Invalid transaction index") | |
165 | 182 | else if (!(bn256Groth16Verify_5inputs(transferVk, txProof, transferInputs))) | |
166 | 183 | then throw("Tx proof is invalid") | |
167 | 184 | else if (!(bn256Groth16Verify_3inputs(treeVk, treeProof, treeInputs))) | |
168 | 185 | then throw("Tree proof is invalid") | |
169 | 186 | else if (nullifierExists) | |
170 | 187 | then throw("Double spend") | |
171 | 188 | else ((txOps ++ dataOps) ++ feeOps) | |
172 | 189 | } | |
173 | 190 | else throw("Strict value is not equal to itself.") | |
174 | 191 | } | |
175 | 192 | ||
176 | 193 | ||
177 | 194 | @Verifier(tx) | |
178 | 195 | func verify () = match tx { | |
179 | 196 | case d: SetScriptTransaction => | |
180 | - | sigVerify(tx.bodyBytes, tx.proofs[0], operatorPk) | |
197 | + | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPk) | |
198 | + | case d: InvokeScriptTransaction => | |
199 | + | match d.function { | |
200 | + | case _ => | |
201 | + | if (("setOperatorPk" == $match1)) | |
202 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], ownerPk) | |
203 | + | else if (("transact" == $match1)) | |
204 | + | then { | |
205 | + | let operatorPk = getOperatorPk() | |
206 | + | sigVerify(tx.bodyBytes, tx.proofs[0], operatorPk) | |
207 | + | } | |
208 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
209 | + | } | |
181 | 210 | case _ => | |
182 | 211 | false | |
183 | 212 | } | |
184 | 213 |
github/deemru/w8io/169f3d6 53.84 ms ◑