tx · 6VnwRiznJbm2wm3FFpwUmQi9fN8Bo25so8dhNKFFaoJo 3N8kB3UEjWWvTRBtGpGUErAevaK2q6u2eCM: -0.01000000 Waves 2023.11.02 10:00 [2825387] smart account 3N8kB3UEjWWvTRBtGpGUErAevaK2q6u2eCM > SELF 0.00000000 Waves
{ "type": 13, "id": "6VnwRiznJbm2wm3FFpwUmQi9fN8Bo25so8dhNKFFaoJo", "fee": 1000000, "feeAssetId": null, "timestamp": 1698908417993, "version": 2, "chainId": 84, "sender": "3N8kB3UEjWWvTRBtGpGUErAevaK2q6u2eCM", "senderPublicKey": "6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM", "proofs": [ "3AU4JNQBEBce5ZTUVvAjHcp32ESxqZpDCQBFs335yvesJmjWA6fwVT1iPyNbmzHigZaJEjsBJC663HoRhVDHt2z8" ], "script": "base64:BgIOCAISABIDCgEBEgMKAQINAApvcGVyYXRvclBrASBYykJ087k1O5DHz1iBa4azTNxFvIHPRd6zv7WPhbjSXAAPb3BlcmF0b3JBZGRyZXNzCQCnCAEFCm9wZXJhdG9yUGsAC2Rlbm9taW5hdG9yAIDC1y8ACnRyYW5zZmVyVmsBxAZJiseGR4OvD50UwPpiv9Wu+vak/IMcJagw7zD0vEVpAAGtWTGorU9F+BnDS31sM2zEUQk0eEStz1cdOSRTU6IRhhaLPZV2pbqNB7BLzpneWyHFboV1/UxTQwM+3U2iKRJ/ZgQgG8j6CxwB+qa28nFluRUD8uuvuv4fJVShka3VAHjpm/26Z5kHCZNaIMdos8+A5U5ZABVgswLCkTMTMh0XYLwrMj8KwJ4K/etp/npFeaEUBa4kJsy07ozLXY/EVANG/3whY/QUaFj+bqxD/2vnwYierhtJVhYqUa5xtdtrJpgXfkWnejpVpFdVbMnoV6ysfx1L4PF5p2xycA3ghAQHgnlhzBm8Bf9+MTkkQc0Lhas1+JR7597oUBDi20eVGApL49s3Vu60fV0OR9CQEoLk6bRYjcPjl5pFs3pNrG3uFrnEJTA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ryyndAC Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | ||
24 | 24 | ||
25 | 25 | let poolIndexKey = "PoolIndex" | |
26 | + | ||
27 | + | let allMessagesHashKey = "AllMessagesHash" | |
26 | 28 | ||
27 | 29 | func takeExt (v,from,to) = drop(take(v, to), from) | |
28 | 30 | ||
97 | 99 | let treeProof = takeExt(tx, 384, 640) | |
98 | 100 | let rootAfter = takeExt(tx, 640, 672) | |
99 | 101 | let txType = toInt(takeExt(tx, 672, 674)) | |
100 | - | let $ | |
102 | + | let $t056566018 = if ((txType == 0)) | |
101 | 103 | then { | |
102 | 104 | let depositDataSize = (32 + 64) | |
103 | 105 | let depositPk = dropRight(takeRight(tx, depositDataSize), 64) | |
105 | 107 | $Tuple3(takeExt(tx, 674, (size(tx) - depositDataSize)), depositPk, depositSignature) | |
106 | 108 | } | |
107 | 109 | else $Tuple3(takeExt(tx, 674, size(tx)), unit, unit) | |
108 | - | let memo = $ | |
109 | - | let depositPk = $ | |
110 | - | let depositSignature = $ | |
110 | + | let memo = $t056566018._1 | |
111 | + | let depositPk = $t056566018._2 | |
112 | + | let depositSignature = $t056566018._3 | |
111 | 113 | let fee = toInt(takeExt(memo, 0, 8)) | |
114 | + | let allMessagesHash = valueOrElse(getBinary(allMessagesHashKey), toBytes(toBigInt(0))) | |
112 | 115 | let memoHash = keccak256(memo) | |
116 | + | let hashes = (allMessagesHash + memoHash) | |
117 | + | let newAllMessagesHash = keccak256(hashes) | |
113 | 118 | let rootBefore = valueOrElse(getBinary(getRootKey(txIndex)), initialRoot) | |
114 | 119 | if ((rootBefore == rootBefore)) | |
115 | 120 | then { | |
123 | 128 | } | |
124 | 129 | let transferInputs = ((((memoHash + nullifier) + outCommit) + delta) + memoHash) | |
125 | 130 | let treeInputs = ((poolRoot + rootAfter) + outCommit) | |
126 | - | let | |
127 | - | let | |
131 | + | let dataOps = [BinaryEntry(getRootKey(txIndex), rootAfter), BinaryEntry(getNullifierKey(nullifier), keccak256((outCommit + delta))), IntegerEntry(poolIndexKey, (poolIndex + 128)), BinaryEntry(allMessagesHashKey, newAllMessagesHash)] | |
132 | + | let txOps = match txType { | |
128 | 133 | case _ => | |
129 | 134 | if ((0 == $match0)) | |
130 | 135 | then { | |
149 | 154 | } | |
150 | 155 | else throw("Unknown tx type") | |
151 | 156 | } | |
152 | - | let | |
157 | + | let feeOps = if ((fee > 0)) | |
153 | 158 | then { | |
154 | 159 | let totalFee = (fee * denominator) | |
155 | 160 | [ScriptTransfer(operatorAddress, fee, unit)] | |
163 | 168 | then throw("Tree proof is invalid") | |
164 | 169 | else if (nullifierExists) | |
165 | 170 | then throw("Double spend") | |
166 | - | else (( | |
171 | + | else ((txOps ++ dataOps) ++ feeOps) | |
167 | 172 | } | |
168 | 173 | else throw("Strict value is not equal to itself.") | |
169 | 174 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let operatorPk = base58'6ybktvseycJDGHTjJm3tz9iT2SKaTNtLLCZsJZRemtoM' | |
5 | 5 | ||
6 | 6 | let operatorAddress = addressFromPublicKey(operatorPk) | |
7 | 7 | ||
8 | 8 | let denominator = 100000000 | |
9 | 9 | ||
10 | 10 | let transferVk = base64'SYrHhkeDrw+dFMD6Yr/Vrvr2pPyDHCWoMO8w9LxFaQABrVkxqK1PRfgZw0t9bDNsxFEJNHhErc9XHTkkU1OiEYYWiz2VdqW6jQewS86Z3lshxW6Fdf1MU0MDPt1NoikSf2YEIBvI+gscAfqmtvJxZbkVA/Lrr7r+HyVUoZGt1QB46Zv9umeZBwmTWiDHaLPPgOVOWQAVYLMCwpEzEzIdF2C8KzI/CsCeCv3raf56RXmhFAWuJCbMtO6My12PxFQDRv98IWP0FGhY/m6sQ/9r58GInq4bSVYWKlGucbXbayaYF35Fp3o6VaRXVWzJ6FesrH8dS+DxeadscnAN4I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kY/GlCqIdfdX5Mr+0CMQWnmr8oECA5QgeOJ1ZnSQmO18Jg9rclNx9mhqD3iux0b+o293HkYg4d75ZOBeUqLdx63/eIe/VEuwIkGFBs4sU9WHEsdqpx8QKpByl6ZKgiOcx/wrW0cwTvm34cq5pRVGunz+qu90se2PqAjOjiIRoDvrcCR7qlN0iTvBedZRTlOtbOxAiXOb/nwFrsmf8wFiebpKkjbNkNvTiLGRiea53xusmuNwANOZtfYMT03Kwf1bgRFrkM6TqgEVZq1Vl7wjFhGu3CFrk5popRZ0X8zhJqn5IPLt6g/0ImUPee8frB6VtMYYkmQ7ZCWTwKEPGDIgQAAACMoBtyPY40yogNVj5bF/LbEe5QGKZjwyfMj58AY5ocK00CEsC3Nm1wSKR6xi8NSbjhPZRw0/zChVK9K8ceAO4ijNFpOFuOpTO6aEq0o7spO/E0JTwTStxF0jdD9NCydSTLZi4DdtHHkcph4Sao8AwV4qd50wavb0/hxCXkVWTvErgnIWCgjrfgzQBDfa99z0alUbwyBBd8odwfJU7bERsH/SfhNempxiwEU1uq6TPQ2NxgN3fgXo5i9dHrSaI2ZQd7R9hyJVeMlBaz6uP4gS1XYlt5LkT+TFGT/vidKlcMHQx945x1Iivq728eKgJ4aBI5Ja1nxj7QC7d98xukukQl' | |
13 | 13 | ||
14 | 14 | let initialRoot = toBytes(parseBigIntValue("11469701942666298368112882412133877458305516134926649826543144744382391691533")) | |
15 | 15 | ||
16 | 16 | func getRootKey (index) = ("R:" + toString(index)) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getNullifierKey (nullifier) = ("N:" + toBase58String(nullifier)) | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getDepositKey (address) = ("D:" + toBase58String(address)) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | let poolIndexKey = "PoolIndex" | |
26 | + | ||
27 | + | let allMessagesHashKey = "AllMessagesHash" | |
26 | 28 | ||
27 | 29 | func takeExt (v,from,to) = drop(take(v, to), from) | |
28 | 30 | ||
29 | 31 | ||
30 | 32 | func spendDeposit (address,amount) = { | |
31 | 33 | let currentKey = getDepositKey(address.bytes) | |
32 | 34 | let currentAmount = match getInteger(currentKey) { | |
33 | 35 | case a: Int => | |
34 | 36 | a | |
35 | 37 | case _ => | |
36 | 38 | 0 | |
37 | 39 | } | |
38 | 40 | let newAmount = (currentAmount - amount) | |
39 | 41 | if ((0 > amount)) | |
40 | 42 | then throw("Can't spend negative amount") | |
41 | 43 | else if ((0 > newAmount)) | |
42 | 44 | then throw("Not enough balance") | |
43 | 45 | else [IntegerEntry(currentKey, newAmount)] | |
44 | 46 | } | |
45 | 47 | ||
46 | 48 | ||
47 | 49 | @Callable(i) | |
48 | 50 | func deposit () = { | |
49 | 51 | let pmt = value(i.payments[0]) | |
50 | 52 | if (isDefined(pmt.assetId)) | |
51 | 53 | then throw("Only WAVES is allowed at the moment") | |
52 | 54 | else { | |
53 | 55 | let currentKey = getDepositKey(i.caller.bytes) | |
54 | 56 | let currentAmount = match getInteger(this, currentKey) { | |
55 | 57 | case a: Int => | |
56 | 58 | a | |
57 | 59 | case _ => | |
58 | 60 | 0 | |
59 | 61 | } | |
60 | 62 | let newAmount = (currentAmount + pmt.amount) | |
61 | 63 | [IntegerEntry(currentKey, newAmount)] | |
62 | 64 | } | |
63 | 65 | } | |
64 | 66 | ||
65 | 67 | ||
66 | 68 | ||
67 | 69 | @Callable(i) | |
68 | 70 | func withdraw (amount) = { | |
69 | 71 | let currentKey = getDepositKey(i.caller.bytes) | |
70 | 72 | let currentAmount = match getInteger(this, currentKey) { | |
71 | 73 | case a: Int => | |
72 | 74 | a | |
73 | 75 | case _ => | |
74 | 76 | 0 | |
75 | 77 | } | |
76 | 78 | let newAmount = (currentAmount - amount) | |
77 | 79 | if ((0 > amount)) | |
78 | 80 | then throw("Can't withdraw negative amount") | |
79 | 81 | else if ((0 > newAmount)) | |
80 | 82 | then throw("Not enough balance") | |
81 | 83 | else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, unit)] | |
82 | 84 | } | |
83 | 85 | ||
84 | 86 | ||
85 | 87 | ||
86 | 88 | @Callable(i) | |
87 | 89 | func transact (tx) = { | |
88 | 90 | let nullifier = takeExt(tx, 0, 32) | |
89 | 91 | let outCommit = takeExt(tx, 32, 64) | |
90 | 92 | let assetId = takeExt(tx, 64, 96) | |
91 | 93 | let delta = takeExt(tx, 96, 128) | |
92 | 94 | let nativeAmount = toInt(takeExt(delta, 0, 8)) | |
93 | 95 | let nativeEnergy = toInt(takeExt(delta, 8, 22)) | |
94 | 96 | let txIndex = toInt(takeExt(delta, 22, 28)) | |
95 | 97 | let _poolId = takeExt(delta, 28, 31) | |
96 | 98 | let txProof = takeExt(tx, 128, 384) | |
97 | 99 | let treeProof = takeExt(tx, 384, 640) | |
98 | 100 | let rootAfter = takeExt(tx, 640, 672) | |
99 | 101 | let txType = toInt(takeExt(tx, 672, 674)) | |
100 | - | let $ | |
102 | + | let $t056566018 = if ((txType == 0)) | |
101 | 103 | then { | |
102 | 104 | let depositDataSize = (32 + 64) | |
103 | 105 | let depositPk = dropRight(takeRight(tx, depositDataSize), 64) | |
104 | 106 | let depositSignature = takeRight(tx, 64) | |
105 | 107 | $Tuple3(takeExt(tx, 674, (size(tx) - depositDataSize)), depositPk, depositSignature) | |
106 | 108 | } | |
107 | 109 | else $Tuple3(takeExt(tx, 674, size(tx)), unit, unit) | |
108 | - | let memo = $ | |
109 | - | let depositPk = $ | |
110 | - | let depositSignature = $ | |
110 | + | let memo = $t056566018._1 | |
111 | + | let depositPk = $t056566018._2 | |
112 | + | let depositSignature = $t056566018._3 | |
111 | 113 | let fee = toInt(takeExt(memo, 0, 8)) | |
114 | + | let allMessagesHash = valueOrElse(getBinary(allMessagesHashKey), toBytes(toBigInt(0))) | |
112 | 115 | let memoHash = keccak256(memo) | |
116 | + | let hashes = (allMessagesHash + memoHash) | |
117 | + | let newAllMessagesHash = keccak256(hashes) | |
113 | 118 | let rootBefore = valueOrElse(getBinary(getRootKey(txIndex)), initialRoot) | |
114 | 119 | if ((rootBefore == rootBefore)) | |
115 | 120 | then { | |
116 | 121 | let poolIndex = valueOrElse(getInteger(poolIndexKey), 0) | |
117 | 122 | let poolRoot = valueOrElse(getBinary(getRootKey(poolIndex)), initialRoot) | |
118 | 123 | let nullifierExists = match getBinary(getNullifierKey(nullifier)) { | |
119 | 124 | case a: Unit => | |
120 | 125 | false | |
121 | 126 | case _ => | |
122 | 127 | true | |
123 | 128 | } | |
124 | 129 | let transferInputs = ((((memoHash + nullifier) + outCommit) + delta) + memoHash) | |
125 | 130 | let treeInputs = ((poolRoot + rootAfter) + outCommit) | |
126 | - | let | |
127 | - | let | |
131 | + | let dataOps = [BinaryEntry(getRootKey(txIndex), rootAfter), BinaryEntry(getNullifierKey(nullifier), keccak256((outCommit + delta))), IntegerEntry(poolIndexKey, (poolIndex + 128)), BinaryEntry(allMessagesHashKey, newAllMessagesHash)] | |
132 | + | let txOps = match txType { | |
128 | 133 | case _ => | |
129 | 134 | if ((0 == $match0)) | |
130 | 135 | then { | |
131 | 136 | let depositPkValue = value(depositPk) | |
132 | 137 | let depositAddress = addressFromPublicKey(depositPkValue) | |
133 | 138 | if ((0 > nativeAmount)) | |
134 | 139 | then throw("Can't deposit negative amount") | |
135 | 140 | else if (!(sigVerify_8Kb((nullifier + depositPkValue), value(depositSignature), depositPkValue))) | |
136 | 141 | then throw("Invalid deposit signature") | |
137 | 142 | else spendDeposit(depositAddress, (nativeAmount * denominator)) | |
138 | 143 | } | |
139 | 144 | else if ((1 == $match0)) | |
140 | 145 | then if ((nativeAmount != 0)) | |
141 | 146 | then throw("Native amount must be zero for transfers") | |
142 | 147 | else nil | |
143 | 148 | else if ((2 == $match0)) | |
144 | 149 | then { | |
145 | 150 | let withdrawAmount = (toInt(takeExt(memo, 8, 16)) * denominator) | |
146 | 151 | if ((withdrawAmount > 0)) | |
147 | 152 | then throw("Withdraw amount must be positive") | |
148 | 153 | else [ScriptTransfer(i.caller, -(withdrawAmount), unit)] | |
149 | 154 | } | |
150 | 155 | else throw("Unknown tx type") | |
151 | 156 | } | |
152 | - | let | |
157 | + | let feeOps = if ((fee > 0)) | |
153 | 158 | then { | |
154 | 159 | let totalFee = (fee * denominator) | |
155 | 160 | [ScriptTransfer(operatorAddress, fee, unit)] | |
156 | 161 | } | |
157 | 162 | else nil | |
158 | 163 | if ((txIndex > poolIndex)) | |
159 | 164 | then throw("Transaction index is too big") | |
160 | 165 | else if (!(bn256Groth16Verify_5inputs(transferVk, txProof, transferInputs))) | |
161 | 166 | then throw("Tx proof is invalid") | |
162 | 167 | else if (!(bn256Groth16Verify_3inputs(treeVk, treeProof, treeInputs))) | |
163 | 168 | then throw("Tree proof is invalid") | |
164 | 169 | else if (nullifierExists) | |
165 | 170 | then throw("Double spend") | |
166 | - | else (( | |
171 | + | else ((txOps ++ dataOps) ++ feeOps) | |
167 | 172 | } | |
168 | 173 | else throw("Strict value is not equal to itself.") | |
169 | 174 | } | |
170 | 175 | ||
171 | 176 | ||
172 | 177 | @Verifier(tx) | |
173 | 178 | func verify () = match tx { | |
174 | 179 | case d: SetScriptTransaction => | |
175 | 180 | sigVerify(tx.bodyBytes, tx.proofs[0], operatorPk) | |
176 | 181 | case _ => | |
177 | 182 | false | |
178 | 183 | } | |
179 | 184 |
github/deemru/w8io/169f3d6 42.43 ms ◑