tx · 2aaheiHQktyJgXKjX6D5KxxDiKwAFHtaUUi2J4GJBGYQ 3MwyXzxpp65TzAvdJxnexgz9G5kFkcqGLMF: -0.01400000 Waves 2019.06.27 22:04 [560931] smart account 3MwyXzxpp65TzAvdJxnexgz9G5kFkcqGLMF > SELF 0.00000000 Waves
{ "type": 13, "id": "2aaheiHQktyJgXKjX6D5KxxDiKwAFHtaUUi2J4GJBGYQ", "fee": 1400000, "feeAssetId": null, "timestamp": 1561662225342, "version": 1, "sender": "3MwyXzxpp65TzAvdJxnexgz9G5kFkcqGLMF", "senderPublicKey": "7pDDrtFSiQHYSxpdxuBQVCeBQBwa3fFWMBmtJ85aytGX", "proofs": [ "49USH5M2iySECiNhx2LLXazChz2cNav6NpQTg2xmk9ZjWmah9m4GAN3TsdRUwH2Akd7QiiYkGNkGf3yu5FBQ2ns7" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAQAAABNnZXRBZGRyZXNzRnJvbUVudHJ5AAAAAQAAAANrZXkEAAAAB2FkZHJlc3MEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAA3N0cgUAAAAHJG1hdGNoMAUAAAADc3RyCQAAAgAAAAECAAAAFkZpcnN0IGFkZHJlc3Mgbm90IHNldCEFAAAAB2FkZHJlc3MBAAAAGmdldEFkZHJlc3NGcm9tRW50cnlPckVtcHR5AAAAAQAAAANrZXkEAAAAB2FkZHJlc3MEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAA3N0cgUAAAAHJG1hdGNoMAUAAAADc3RyAgAAAAAFAAAAB2FkZHJlc3MBAAAADWdldEludEZyb21LZXkAAAABAAAAA2tleQQAAAASZmlyc3RBZGRyZXNzQW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHR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mRBZGRyZXNzAgAAAAxfY291bnRlcnBhcnQDAwkBAAAAAiE9AAAAAgUAAAATY3VycmVudEZpcnN0QWRkcmVzcwIAAAAABgkBAAAAAiE9AAAAAgUAAAAUY3VycmVudFNlY29uZEFkZHJlc3MCAAAAAAkAAAIAAAABAgAAABtDb250cmFjdCBhbHJlYWR5IGluaXRpYXRlZCEJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAICAAAADGZpcnN0QWRkcmVzcwUAAAAMZmlyc3RBZGRyZXNzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAA1zZWNvbmRBZGRyZXNzBQAAAA1zZWNvbmRBZGRyZXNzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAADGZpcnN0QWRkcmVzcwIAAAAMX2NvdW50ZXJwYXJ0BQAAAA9zZWNvbmRQdWJsaWNLZXkJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAANc2Vjb25kQWRkcmVzcwIAAAAMX2NvdW50ZXJwYXJ0BQAAAA5maXJzdFB1YmxpY0tleQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAOdGltZWxvY2tQZXJpb2QFAAAADnRpbWVsb2NrUGVyaW9kBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAYkGE8b", "chainId": 84, "height": 560931, "spentComplexity": 0 } View: original | compacted Prev: BPubZeJ2S3Tf2FnDypEMhJ1A3z7WW6QWG3cLx7GBkSnf Next: 57bUA9rFgcDWEt7vpy8XQtJ2ve3i8KnRKSijJhqhUjGZ Diff:
Old | New | Differences | |
---|---|---|---|
110 | 110 | let validSender = checkIfMethodCallComesFromValidAccount(sender) | |
111 | 111 | let originalString = ((((recipientA + toString(amountRecipientA)) + recipientB) + toString(amountRecipientB)) + toString(timestamp)) | |
112 | 112 | let counterPart = getAddressFromEntry((sender + "_counterpart")) | |
113 | - | let signedByCounterpart = sigVerify(toBytes(originalString), | |
113 | + | let signedByCounterpart = sigVerify(toBytes(originalString), fromBase58String(signature), fromBase58String(counterPart)) | |
114 | 114 | let timelockPeriod = getIntFromKey("timelockPeriod") | |
115 | 115 | if (if (signedByCounterpart) | |
116 | 116 | then validSender |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getAddressFromEntry (key) = { | |
5 | 5 | let address = match getString(this, key) { | |
6 | 6 | case str: String => | |
7 | 7 | str | |
8 | 8 | case _ => | |
9 | 9 | throw("First address not set!") | |
10 | 10 | } | |
11 | 11 | address | |
12 | 12 | } | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func getAddressFromEntryOrEmpty (key) = { | |
16 | 16 | let address = match getString(this, key) { | |
17 | 17 | case str: String => | |
18 | 18 | str | |
19 | 19 | case _ => | |
20 | 20 | "" | |
21 | 21 | } | |
22 | 22 | address | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getIntFromKey (key) = { | |
27 | 27 | let firstAddressAmount = match getInteger(this, key) { | |
28 | 28 | case n: Int => | |
29 | 29 | n | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | firstAddressAmount | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func checkIfMethodCallComesFromValidAccount (sender) = { | |
38 | 38 | let firstAddress = getAddressFromEntry("firstAddress") | |
39 | 39 | let secondAddress = getAddressFromEntry("secondAddress") | |
40 | 40 | if (if ((firstAddress != sender)) | |
41 | 41 | then (secondAddress != sender) | |
42 | 42 | else false) | |
43 | 43 | then throw(("Method call from invalid account: " + sender)) | |
44 | 44 | else true | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | @Callable(i) | |
49 | 49 | func claimCheating (recipientA,amountRecipientA,recipientB,amountRecipientB,timestamp,signature) = { | |
50 | 50 | let sender = toBase58String(i.caller.bytes) | |
51 | 51 | let validSender = checkIfMethodCallComesFromValidAccount(sender) | |
52 | 52 | let originalString = ((((recipientA + toString(amountRecipientA)) + recipientB) + toString(amountRecipientB)) + toString(timestamp)) | |
53 | 53 | let counterPart = getAddressFromEntry((sender + "_counterpart")) | |
54 | 54 | let signedByCounterpart = sigVerify(fromBase58String(originalString), fromBase58String(signature), fromBase58String(counterPart)) | |
55 | 55 | let oldTimestamp = getIntFromKey("timestamp") | |
56 | 56 | if (if (if (validSender) | |
57 | 57 | then signedByCounterpart | |
58 | 58 | else false) | |
59 | 59 | then (timestamp > oldTimestamp) | |
60 | 60 | else false) | |
61 | 61 | then TransferSet([ScriptTransfer(i.caller, (amountRecipientA + amountRecipientB), unit)]) | |
62 | 62 | else throw("Wrong signature or timestamp not newer!") | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | @Callable(i) | |
68 | 68 | func confirmClose () = { | |
69 | 69 | let sender = toBase58String(i.caller.bytes) | |
70 | 70 | let validSender = checkIfMethodCallComesFromValidAccount(sender) | |
71 | 71 | let initiator = getString(this, "closing_initiated_by") | |
72 | 72 | if (if ((sender != initiator)) | |
73 | 73 | then validSender | |
74 | 74 | else false) | |
75 | 75 | then { | |
76 | 76 | let firstAddress = getAddressFromEntry("firstAddress") | |
77 | 77 | let secondAddress = getAddressFromEntry("secondAddress") | |
78 | 78 | let firstAddressAmount = getIntFromKey(firstAddress) | |
79 | 79 | let secondAddressAmount = getIntFromKey(secondAddress) | |
80 | 80 | TransferSet([ScriptTransfer(Address(fromBase58String(firstAddress)), firstAddressAmount, unit), ScriptTransfer(Address(fromBase58String(secondAddress)), secondAddressAmount, unit)]) | |
81 | 81 | } | |
82 | 82 | else throw("Initiator can not confirm closing of the channel!") | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
87 | 87 | @Callable(i) | |
88 | 88 | func closeAfterTimelock () = { | |
89 | 89 | let sender = toBase58String(i.caller.bytes) | |
90 | 90 | let validSender = checkIfMethodCallComesFromValidAccount(sender) | |
91 | 91 | let timelock = getIntFromKey("timelock") | |
92 | 92 | if (if ((height > timelock)) | |
93 | 93 | then validSender | |
94 | 94 | else false) | |
95 | 95 | then { | |
96 | 96 | let firstAddress = getAddressFromEntry("firstAddress") | |
97 | 97 | let secondAddress = getAddressFromEntry("secondAddress") | |
98 | 98 | let firstAddressAmount = getIntFromKey(firstAddress) | |
99 | 99 | let secondAddressAmount = getIntFromKey(secondAddress) | |
100 | 100 | TransferSet([ScriptTransfer(Address(fromBase58String(firstAddress)), firstAddressAmount, unit), ScriptTransfer(Address(fromBase58String(secondAddress)), secondAddressAmount, unit)]) | |
101 | 101 | } | |
102 | 102 | else throw("Timelock still valid!") | |
103 | 103 | } | |
104 | 104 | ||
105 | 105 | ||
106 | 106 | ||
107 | 107 | @Callable(i) | |
108 | 108 | func initialClosing (recipientA,amountRecipientA,recipientB,amountRecipientB,timestamp,signature) = { | |
109 | 109 | let sender = toBase58String(i.caller.bytes) | |
110 | 110 | let validSender = checkIfMethodCallComesFromValidAccount(sender) | |
111 | 111 | let originalString = ((((recipientA + toString(amountRecipientA)) + recipientB) + toString(amountRecipientB)) + toString(timestamp)) | |
112 | 112 | let counterPart = getAddressFromEntry((sender + "_counterpart")) | |
113 | - | let signedByCounterpart = sigVerify(toBytes(originalString), | |
113 | + | let signedByCounterpart = sigVerify(toBytes(originalString), fromBase58String(signature), fromBase58String(counterPart)) | |
114 | 114 | let timelockPeriod = getIntFromKey("timelockPeriod") | |
115 | 115 | if (if (signedByCounterpart) | |
116 | 116 | then validSender | |
117 | 117 | else false) | |
118 | 118 | then WriteSet([DataEntry(recipientA, amountRecipientA), DataEntry(recipientB, amountRecipientB), DataEntry("closing_initiated_by", sender), DataEntry("timestamp", timestamp), DataEntry("timelock", (height + timelockPeriod))]) | |
119 | 119 | else throw("Wrong signature!") | |
120 | 120 | } | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | 124 | @Callable(i) | |
125 | 125 | func fund () = { | |
126 | 126 | let sender = toBase58String(i.caller.bytes) | |
127 | 127 | let validSender = checkIfMethodCallComesFromValidAccount(sender) | |
128 | 128 | let payment = extract(i.payment) | |
129 | 129 | let amountKey = (sender + "_amount") | |
130 | 130 | let currentAmount = getIntFromKey(amountKey) | |
131 | 131 | if (validSender) | |
132 | 132 | then if ((currentAmount != 0)) | |
133 | 133 | then throw("User has already funded payment channel!") | |
134 | 134 | else WriteSet([DataEntry(amountKey, (currentAmount + payment.amount))]) | |
135 | 135 | else throw("Wrong account tries to fund channel!") | |
136 | 136 | } | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | ||
140 | 140 | @Callable(i) | |
141 | 141 | func init (firstAddress,firstPublicKey,secondAddress,secondPublicKey,timelockPeriod) = { | |
142 | 142 | let currentFirstAddress = getAddressFromEntryOrEmpty((firstAddress + "_counterpart")) | |
143 | 143 | let currentSecondAddress = getAddressFromEntryOrEmpty((secondAddress + "_counterpart")) | |
144 | 144 | if (if ((currentFirstAddress != "")) | |
145 | 145 | then true | |
146 | 146 | else (currentSecondAddress != "")) | |
147 | 147 | then throw("Contract already initiated!") | |
148 | 148 | else WriteSet([DataEntry("firstAddress", firstAddress), DataEntry("secondAddress", secondAddress), DataEntry((firstAddress + "_counterpart"), secondPublicKey), DataEntry((secondAddress + "_counterpart"), firstPublicKey), DataEntry("timelockPeriod", timelockPeriod)]) | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | @Verifier(tx) | |
153 | 153 | func verify () = match tx { | |
154 | 154 | case _ => | |
155 | 155 | true | |
156 | 156 | } | |
157 | 157 |
github/deemru/w8io/026f985 43.04 ms ◑