Compare commits
813 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd05968077 | ||
|
|
6e730915bd | ||
|
|
c713ea7c22 | ||
|
|
7f5f62aaa0 | ||
|
|
b2f696e025 | ||
|
|
62b43ee0d5 | ||
|
|
a2a60869c8 | ||
|
|
df89233b57 | ||
|
|
ead711779d | ||
|
|
2133f18f15 | ||
|
|
1a6ef5ae58 | ||
|
|
ad03d9801c | ||
|
|
62391ddbeb | ||
|
|
0568e81701 | ||
|
|
32b07e8b1f | ||
|
|
aca39a6498 | ||
|
|
be500b57d2 | ||
|
|
a308f012ba | ||
|
|
311419c7d6 | ||
|
|
63b18027dc | ||
|
|
a1c09b9387 | ||
|
|
05347b3d98 | ||
|
|
75aec8a28d | ||
|
|
24ef83518c | ||
|
|
46891c12ab | ||
|
|
c0010f0220 | ||
|
|
9f98628dc2 | ||
|
|
a6a14f6b71 | ||
|
|
f9eb307216 | ||
|
|
03c7d8fb31 | ||
|
|
2becb99583 | ||
|
|
ad380cd57f | ||
|
|
7b32d2a470 | ||
|
|
f40ff23b7b | ||
|
|
0ac9bbba6c | ||
|
|
d4dce43bff | ||
|
|
056183c056 | ||
|
|
8d41e885e6 | ||
|
|
8bd64f4a1c | ||
|
|
b1c3010bf2 | ||
|
|
aff986958d | ||
|
|
f49d6e5ec0 | ||
|
|
223b950944 | ||
|
|
16f0fb70f1 | ||
|
|
96fb839133 | ||
|
|
3b6c9902f3 | ||
|
|
efe123759a | ||
|
|
8eb646a96d | ||
|
|
c02d5bc5a9 | ||
|
|
71251c7296 | ||
|
|
2469c4ecd4 | ||
|
|
39b0b1a1a6 | ||
|
|
91b7349509 | ||
|
|
52a967cfab | ||
|
|
305ed955db | ||
|
|
72045dff4f | ||
|
|
46b437f39c | ||
|
|
72d5a27a39 | ||
|
|
4f6bf2f1c5 | ||
|
|
49b86a2859 | ||
|
|
cea2c80445 | ||
|
|
67bfc93053 | ||
|
|
ce2da832ac | ||
|
|
b4a4a4db71 | ||
|
|
cfbb969da8 | ||
|
|
1611815b8d | ||
|
|
b8a9457139 | ||
|
|
af16ca177f | ||
|
|
cedf8be435 | ||
|
|
d5bd38384c | ||
|
|
292cf7c649 | ||
|
|
396f1dd87b | ||
|
|
68502595f6 | ||
|
|
a978adfd7c | ||
|
|
cc9eb91d30 | ||
|
|
e39b2a2bde | ||
|
|
c8a1c0a115 | ||
|
|
4aeeddc658 | ||
|
|
e126b0836a | ||
|
|
961aa0533f | ||
|
|
54b271a86d | ||
|
|
b90cdbaa79 | ||
|
|
4d358b9fc0 | ||
|
|
1eaf66ae60 | ||
|
|
4ef5e9746b | ||
|
|
060e33fb4c | ||
|
|
46ec63b849 | ||
|
|
1cd5bf080e | ||
|
|
7c229941ac | ||
|
|
ac23073619 | ||
|
|
8e391cec43 | ||
|
|
5b2c47a575 | ||
|
|
8517dd463d | ||
|
|
22fdbee8ed | ||
|
|
1bccafe5ef | ||
|
|
2890f060b7 | ||
|
|
2ed729d38e | ||
|
|
4aee0d1994 | ||
|
|
039a9c3622 | ||
|
|
3bb9b49afb | ||
|
|
9dfca5df4b | ||
|
|
273b3741b6 | ||
|
|
85d2b0d654 | ||
|
|
7d3b26018b | ||
|
|
dbb03fe989 | ||
|
|
2c50b2c904 | ||
|
|
9bad7fa717 | ||
|
|
26f538b0e5 | ||
|
|
260b177fe3 | ||
|
|
c2c4c9f1e5 | ||
|
|
44c8b9ad37 | ||
|
|
eea66ddbbd | ||
|
|
aaf29095bb | ||
|
|
e76047e9f5 | ||
|
|
34d7503d95 | ||
|
|
9b8d727655 | ||
|
|
df6c08a485 | ||
|
|
423fd5877d | ||
|
|
8657a0d6b5 | ||
|
|
36994e4e0b | ||
|
|
c9cdf144d5 | ||
|
|
081642ed25 | ||
|
|
17589aa75f | ||
|
|
3e993ff64a | ||
|
|
f3478f2899 | ||
|
|
c55e1b495c | ||
|
|
f891fd9875 | ||
|
|
beff5fa578 | ||
|
|
aa6005b469 | ||
|
|
a7de796840 | ||
|
|
947f5f2b15 | ||
|
|
e46a01d56c | ||
|
|
7f3362595a | ||
|
|
140a7e9177 | ||
|
|
96ab8e1575 | ||
|
|
f34a3a6805 | ||
|
|
8812c4d3f9 | ||
|
|
e4232c153b | ||
|
|
389bd75142 | ||
|
|
08e5cd94a9 | ||
|
|
b7b2f60f86 | ||
|
|
530f78e22d | ||
|
|
57d9c93dcd | ||
|
|
4f56790efc | ||
|
|
78ab411aac | ||
|
|
f08eb04896 | ||
|
|
3b96c17fc1 | ||
|
|
4ac941a9fc | ||
|
|
b80c840af3 | ||
|
|
a32a2b933a | ||
|
|
04e175b8ec | ||
|
|
e8141e1685 | ||
|
|
82985075f7 | ||
|
|
b973eddd28 | ||
|
|
1a83114c74 | ||
|
|
364e485e51 | ||
|
|
28fea9c5af | ||
|
|
57fc1d21e1 | ||
|
|
cc3ef1e4f4 | ||
|
|
5183483c53 | ||
|
|
a1f8549262 | ||
|
|
e8c9579fb7 | ||
|
|
433cb564e9 | ||
|
|
8485f7cc7b | ||
|
|
61a20cb56d | ||
|
|
f088c650a5 | ||
|
|
9466b9eec5 | ||
|
|
4ac04ae0fe | ||
|
|
8f80cafa10 | ||
|
|
31a1f164d9 | ||
|
|
6bd896a97f | ||
|
|
49a7ee460e | ||
|
|
252150918c | ||
|
|
72029f0f88 | ||
|
|
52f2461774 | ||
|
|
54d0eeb494 | ||
|
|
c705aac826 | ||
|
|
c6a9616cfd | ||
|
|
8c4bc4f7ef | ||
|
|
e970d60d37 | ||
|
|
2808bc68b9 | ||
|
|
213690cdfd | ||
|
|
7527215a68 | ||
|
|
8c249cb82f | ||
|
|
a966425a1d | ||
|
|
5873c01c3d | ||
|
|
1bed5afd92 | ||
|
|
16e313699f | ||
|
|
fa538ee7ed | ||
|
|
983f92368b | ||
|
|
cc0f0e27a6 | ||
|
|
22060611fb | ||
|
|
cdfe9a3a2a | ||
|
|
5bc9ccfa0a | ||
|
|
f2eb3b1c56 | ||
|
|
7fd82a0e3e | ||
|
|
dcc4adfcd7 | ||
|
|
d9c75cd10e | ||
|
|
6814797173 | ||
|
|
59a3198382 | ||
|
|
8d2cf028a5 | ||
|
|
5f5de49cd9 | ||
|
|
ca6c8c2af4 | ||
|
|
802074cba9 | ||
|
|
32273df0ea | ||
|
|
de6facb966 | ||
|
|
22411919da | ||
|
|
a0943b8932 | ||
|
|
6bf5555c4f | ||
|
|
0b26a826e9 | ||
|
|
f7cdea2bdc | ||
|
|
702f52fb99 | ||
|
|
6069b1a5f5 | ||
|
|
fd072c2fd1 | ||
|
|
54fd263b40 | ||
|
|
2ca89ea479 | ||
|
|
1da5e0ebb0 | ||
|
|
e4a1488b2f | ||
|
|
98099d6fa7 | ||
|
|
92a90d7578 | ||
|
|
f578d41ee6 | ||
|
|
cdadf57bf9 | ||
|
|
60c062e17d | ||
|
|
25c3282cf1 | ||
|
|
1eddd332d2 | ||
|
|
c94068a8bb | ||
|
|
e3ec77f50e | ||
|
|
8d815e365c | ||
|
|
3271a5afa0 | ||
|
|
2b303e7d62 | ||
|
|
96f8be36ad | ||
|
|
38c914be64 | ||
|
|
cf47ee5339 | ||
|
|
2046d66fe5 | ||
|
|
d6ccfd92f7 | ||
|
|
5298eb7519 | ||
|
|
79c90dce20 | ||
|
|
2da6d1e047 | ||
|
|
f213ceb83f | ||
|
|
c8c3ebd593 | ||
|
|
b3f7609d7d | ||
|
|
32dafea1f0 | ||
|
|
3d7d7384ca | ||
|
|
fc4fee8649 | ||
|
|
3675b8545d | ||
|
|
50e3795eef | ||
|
|
c4e8806d9b | ||
|
|
2b54666018 | ||
|
|
c420dcb39c | ||
|
|
c0a034ec89 | ||
|
|
3d3e83ecff | ||
|
|
b02958b9c5 | ||
|
|
f9c0e093ed | ||
|
|
6f80629383 | ||
|
|
afb9e6513f | ||
|
|
e83c3ccc47 | ||
|
|
896322bf88 | ||
|
|
1b15c6da33 | ||
|
|
ce43c2366d | ||
|
|
9805288cdd | ||
|
|
a4eeeedb37 | ||
|
|
19fa9064d7 | ||
|
|
f01f3f266c | ||
|
|
c52390d078 | ||
|
|
2823ce0086 | ||
|
|
30c2b1b06d | ||
|
|
2fae1bde42 | ||
|
|
b8ca3cb7d2 | ||
|
|
7c9307c683 | ||
|
|
7641bbe535 | ||
|
|
645756cda5 | ||
|
|
d97f0372b1 | ||
|
|
de38a1dbd4 | ||
|
|
5d68400cad | ||
|
|
42b81f94ad | ||
|
|
15f24ff189 | ||
|
|
17381ecc66 | ||
|
|
b4cc7b660c | ||
|
|
4799b5abd4 | ||
|
|
7a22da98b9 | ||
|
|
30263ad37d | ||
|
|
f2612ac948 | ||
|
|
58497f46bd | ||
|
|
3d58268bba | ||
|
|
008d250e3c | ||
|
|
cf38a3dc65 | ||
|
|
048df258dc | ||
|
|
2388e425f2 | ||
|
|
5429dc75bd | ||
|
|
c4de228e18 | ||
|
|
f0bced30bb | ||
|
|
f8a4e37968 | ||
|
|
17cf0e5863 | ||
|
|
7bc1cb3677 | ||
|
|
75a860880c | ||
|
|
9cd338054f | ||
|
|
fc85777a21 | ||
|
|
a184ab7a61 | ||
|
|
db0cc211f7 | ||
|
|
7392f59e7c | ||
|
|
611113e967 | ||
|
|
4e0c1a1a6b | ||
|
|
922e757f19 | ||
|
|
fec3b56f7f | ||
|
|
9efc1a847e | ||
|
|
4b622b277e | ||
|
|
2cd6059e51 | ||
|
|
a54142987c | ||
|
|
4cf8505d22 | ||
|
|
97d3615612 | ||
|
|
e687d063c3 | ||
|
|
509facd631 | ||
|
|
c3b317a4fc | ||
|
|
2f855bfa28 | ||
|
|
8cce620311 | ||
|
|
f35975ea21 | ||
|
|
f5d89cdb72 | ||
|
|
60386b3545 | ||
|
|
9eba3a9fff | ||
|
|
1e067202a2 | ||
|
|
536b3b416c | ||
|
|
37d280da41 | ||
|
|
42c746d6f4 | ||
|
|
331de17e4d | ||
|
|
80469bea0c | ||
|
|
b6cac42e9f | ||
|
|
b69bdc2a4f | ||
|
|
006c21efc7 | ||
|
|
0c5f8c078a | ||
|
|
b548b5aeb0 | ||
|
|
4b9c3bd39a | ||
|
|
9b0d1b9ab2 | ||
|
|
350a87dd3c | ||
|
|
8deec2e45a | ||
|
|
184af72e4e | ||
|
|
07d2d83c31 | ||
|
|
9effd64290 | ||
|
|
f22c00b161 | ||
|
|
40cdcf8c47 | ||
|
|
f4fb1a1801 | ||
|
|
751effa35e | ||
|
|
a0b81097ad | ||
|
|
ec2131c8d3 | ||
|
|
95263914fc | ||
|
|
db83ba4067 | ||
|
|
c8a77d8604 | ||
|
|
7744241886 | ||
|
|
6ec6b29051 | ||
|
|
494f5d448a | ||
|
|
9b1543c282 | ||
|
|
297fa1855c | ||
|
|
84dfaea246 | ||
|
|
3e9ba57669 | ||
|
|
7f753461ca | ||
|
|
8802b9ce7f | ||
|
|
ad6c39012f | ||
|
|
3030893a21 | ||
|
|
12240baf61 | ||
|
|
f8eb8fe64c | ||
|
|
a1cd7e6e92 | ||
|
|
c1213bd00c | ||
|
|
993b145f25 | ||
|
|
996755c4a8 | ||
|
|
c94d582aa7 | ||
|
|
ab10c15578 | ||
|
|
9454508b23 | ||
|
|
be4d74f8d2 | ||
|
|
c113723fdb | ||
|
|
78477e4118 | ||
|
|
e770f62445 | ||
|
|
9b831d74fb | ||
|
|
85726fdb02 | ||
|
|
107c67d74e | ||
|
|
c8cf360f29 | ||
|
|
14868a37fb | ||
|
|
abeba0a1de | ||
|
|
b6c0234e0b | ||
|
|
5036992b06 | ||
|
|
4c90efdf57 | ||
|
|
dba1750eda | ||
|
|
a43ec8bba5 | ||
|
|
befca7e8b0 | ||
|
|
af96b6644e | ||
|
|
ed47f29bc8 | ||
|
|
504f88b65b | ||
|
|
3873a7314d | ||
|
|
92a849a509 | ||
|
|
937417527c | ||
|
|
7c91038bff | ||
|
|
0758d7fe5c | ||
|
|
749ccab9a4 | ||
|
|
6269e5574c | ||
|
|
d9403690ec | ||
|
|
d8dc37c85b | ||
|
|
29bba5d0b2 | ||
|
|
78ec90717a | ||
|
|
f496927a93 | ||
|
|
38f6b85638 | ||
|
|
921b3160db | ||
|
|
c9d9a2d48a | ||
|
|
04a75a1863 | ||
|
|
85b6823d16 | ||
|
|
78d90c47f7 | ||
|
|
ce9a289fa4 | ||
|
|
73fc65bb5b | ||
|
|
7221cb1434 | ||
|
|
6b0ddd141e | ||
|
|
d9d60a5a7f | ||
|
|
4a4abc41d4 | ||
|
|
1528b791ac | ||
|
|
d5af3a584c | ||
|
|
26b50e3ebe | ||
|
|
54dfce8af7 | ||
|
|
31bc2a2434 | ||
|
|
74acde4b08 | ||
|
|
b7dd225179 | ||
|
|
a1c5017bc5 | ||
|
|
ae7344d799 | ||
|
|
8cf764da89 | ||
|
|
f0b878d56d | ||
|
|
3fa76298e4 | ||
|
|
e4cb7b80d5 | ||
|
|
22e1d2ce03 | ||
|
|
da99c0691c | ||
|
|
cf1a6d7c56 | ||
|
|
33d28f37c7 | ||
|
|
60ab5faf54 | ||
|
|
1fc3e44ffe | ||
|
|
5fc5971438 | ||
|
|
f538d15241 | ||
|
|
7c28ecbcc3 | ||
|
|
86806d8b24 | ||
|
|
5b947c5004 | ||
|
|
8ee5bb2289 | ||
|
|
7c08e48141 | ||
|
|
e2f3465e83 | ||
|
|
ed97517ff4 | ||
|
|
5b30aa59d6 | ||
|
|
6f21520a82 | ||
|
|
fc3000d649 | ||
|
|
d2daff4258 | ||
|
|
aae61ab16e | ||
|
|
df5409c952 | ||
|
|
3b3e1bc07e | ||
|
|
8c786a1f99 | ||
|
|
79f4cfac2e | ||
|
|
1d1bee528e | ||
|
|
28c8f41b90 | ||
|
|
714675cd2a | ||
|
|
35b80f1865 | ||
|
|
bcf3c52ac9 | ||
|
|
2625057fe3 | ||
|
|
189a032987 | ||
|
|
ec4fba83d4 | ||
|
|
0a0b93708d | ||
|
|
21b01f590d | ||
|
|
9b66a8520a | ||
|
|
e273031dce | ||
|
|
7ec6fa03d3 | ||
|
|
42c76a2ba1 | ||
|
|
5617dca1c9 | ||
|
|
ae82c58631 | ||
|
|
7b230b7ef1 | ||
|
|
a900e80a89 | ||
|
|
7d5886dcf4 | ||
|
|
386943943f | ||
|
|
114de0fe2a | ||
|
|
475e8719ba | ||
|
|
78375608a4 | ||
|
|
f7027dd68c | ||
|
|
64f9c1ea09 | ||
|
|
5515f364ae | ||
|
|
3996bc1ad9 | ||
|
|
2a8a07c2b3 | ||
|
|
dd0cfe5e11 | ||
|
|
d763b49ae3 | ||
|
|
78644f0377 | ||
|
|
de195bf152 | ||
|
|
212b25869d | ||
|
|
bca140b73d | ||
|
|
8b427296c9 | ||
|
|
4bf0d11e7c | ||
|
|
da19f302b8 | ||
|
|
ee376f6766 | ||
|
|
29bc982d75 | ||
|
|
36f81118f6 | ||
|
|
7dd3194710 | ||
|
|
a8dd1f93c6 | ||
|
|
43631aa1d6 | ||
|
|
690bd8a417 | ||
|
|
d5cae48bae | ||
|
|
9b3601cfce | ||
|
|
36b78abe61 | ||
|
|
5164274872 | ||
|
|
0b4fe8d192 | ||
|
|
e14f8a408c | ||
|
|
88d7119ebb | ||
|
|
3baed8dd9a | ||
|
|
c4109d790f | ||
|
|
6caf35684d | ||
|
|
ccffad5553 | ||
|
|
72c98dc41f | ||
|
|
0529015091 | ||
|
|
92faf1bf7a | ||
|
|
9294b8f10f | ||
|
|
cd79bc61a9 | ||
|
|
ed34a5e08a | ||
|
|
bb9631c399 | ||
|
|
86e77900c5 | ||
|
|
fbe7caf136 | ||
|
|
157f09e5b6 | ||
|
|
5b0d3fa393 | ||
|
|
67fc0377e1 | ||
|
|
7fb89697fd | ||
|
|
42e2c586fd | ||
|
|
b17e4a8713 | ||
|
|
ac3e7c9b3d | ||
|
|
dba336e612 | ||
|
|
a732c93309 | ||
|
|
59e1953246 | ||
|
|
df717abc99 | ||
|
|
b8b4fb004c | ||
|
|
f03402232c | ||
|
|
435020f9b3 | ||
|
|
acbb8a1439 | ||
|
|
88c756c83d | ||
|
|
71cb816a74 | ||
|
|
86989e3fcd | ||
|
|
e852505ace | ||
|
|
2f5b6cb442 | ||
|
|
876f357364 | ||
|
|
8d04154691 | ||
|
|
09924cbcaa | ||
|
|
3585351888 | ||
|
|
650ad19c2d | ||
|
|
baded64d88 | ||
|
|
c53c5e616f | ||
|
|
e7d1867964 | ||
|
|
fb458280d1 | ||
|
|
47c03c0f8c | ||
|
|
211ec46284 | ||
|
|
54cd3e89a4 | ||
|
|
def1b0d7e1 | ||
|
|
acebccc3bf | ||
|
|
6e401792ce | ||
|
|
3d067b0cea | ||
|
|
f180981273 | ||
|
|
4b4f03ca37 | ||
|
|
df488975bd | ||
|
|
91eec1251c | ||
|
|
e270a753be | ||
|
|
5ce192ce44 | ||
|
|
7640c9c933 | ||
|
|
6c312a24b6 | ||
|
|
95b2ec7169 | ||
|
|
768b4c2e6b | ||
|
|
1a29bf0ee2 | ||
|
|
1591b63306 | ||
|
|
aa69ec64d0 | ||
|
|
4f457859a2 | ||
|
|
8a03bf2155 | ||
|
|
b87a68407b | ||
|
|
8111b9dda5 | ||
|
|
7504dbd6eb | ||
|
|
da5de012c3 | ||
|
|
04a4a23c2d | ||
|
|
1a3e25e4c1 | ||
|
|
9a58a9b91a | ||
|
|
f82185a4a1 | ||
|
|
bb55b0fb53 | ||
|
|
2cfe0bed9f | ||
|
|
ceeb047e69 | ||
|
|
a6e5c6a2cc | ||
|
|
4687391213 | ||
|
|
316b63daf0 | ||
|
|
2eed46dadf | ||
|
|
1612267a4b | ||
|
|
2fa9e99fc1 | ||
|
|
5f94f8c7e7 | ||
|
|
eb199f1fc2 | ||
|
|
d45f8d1880 | ||
|
|
a87776a5fe | ||
|
|
72b21db2d3 | ||
|
|
f2d6310354 | ||
|
|
ce3ea8c9b1 | ||
|
|
054412e335 | ||
|
|
2f24e254a9 | ||
|
|
15eee47ebf | ||
|
|
34c85def3e | ||
|
|
81ed700157 | ||
|
|
216bd2ceba | ||
|
|
a1099bb7e9 | ||
|
|
603a85218b | ||
|
|
e2d322b25a | ||
|
|
f9aa1cd21f | ||
|
|
b797dd07d2 | ||
|
|
729bf365b5 | ||
|
|
4e9230ea7a | ||
|
|
94eca08ad8 | ||
|
|
0594deb652 | ||
|
|
696a65b016 | ||
|
|
5c03baaf6f | ||
|
|
994326ba00 | ||
|
|
509ea3ef9b | ||
|
|
313576530f | ||
|
|
0f41356b95 | ||
|
|
39bd2609ca | ||
|
|
1bc7f3f906 | ||
|
|
dac7cbcf21 | ||
|
|
dd28ba378a | ||
|
|
62d9d63858 | ||
|
|
505a49e689 | ||
|
|
2b6158a51e | ||
|
|
e43bc36226 | ||
|
|
7ebd2fa5db | ||
|
|
f0233948d2 | ||
|
|
b7e0dec6bd | ||
|
|
6d652ce1b7 | ||
|
|
c2003ed63b | ||
|
|
c2b33a117f | ||
|
|
a42afa766c | ||
|
|
647692fbfe | ||
|
|
c83ba9e794 | ||
|
|
340a53a98b | ||
|
|
badaf43019 | ||
|
|
f5f742d1ac | ||
|
|
7d881e45bd | ||
|
|
872370e3bc | ||
|
|
81babe1509 | ||
|
|
4e87b444ca | ||
|
|
90b6cdaadf | ||
|
|
64d10c0872 | ||
|
|
02c28046a0 | ||
|
|
d9adcd3a27 | ||
|
|
1993227311 | ||
|
|
c8da76e63d | ||
|
|
836c846812 | ||
|
|
b9808e392f | ||
|
|
7fd0ccaa68 | ||
|
|
8577b5b020 | ||
|
|
628a0bde3f | ||
|
|
fbedf62f3d | ||
|
|
9d5e10f5bb | ||
|
|
e38b227ce6 | ||
|
|
d36e974ba3 | ||
|
|
460d206f30 | ||
|
|
ba2dfa5ce4 | ||
|
|
f49f95e2b0 | ||
|
|
d3ccedc767 | ||
|
|
2e8a5e5659 | ||
|
|
8af6c9e6a2 | ||
|
|
514a9472ad | ||
|
|
57f959af41 | ||
|
|
cf147c71d5 | ||
|
|
f1537b774c | ||
|
|
bf42535d31 | ||
|
|
b5e5b3567c | ||
|
|
f7f6a46029 | ||
|
|
d2256244c4 | ||
|
|
26d3a8ca80 | ||
|
|
c283d9b5e8 | ||
|
|
4a090a1bab | ||
|
|
9c7e65c435 | ||
|
|
c5eccaefb8 | ||
|
|
d88c6ce6b0 | ||
|
|
3c62f965e7 | ||
|
|
2a0e1bb32b | ||
|
|
f57c80d22e | ||
|
|
7b3e3d549e | ||
|
|
3930f3795b | ||
|
|
a1f366ecf6 | ||
|
|
df7c4618cd | ||
|
|
62d7688d0a | ||
|
|
b6ce358a9b | ||
|
|
c0b9c763bb | ||
|
|
75a931470e | ||
|
|
37e5a908e7 | ||
|
|
50b872bf05 | ||
|
|
12ca3b172a | ||
|
|
4f85c2b88b | ||
|
|
5b8ae7885e | ||
|
|
7f6b05aa43 | ||
|
|
fa87929a2f | ||
|
|
e26a119c9b | ||
|
|
9d3ea8df1c | ||
|
|
2b75fa9d61 | ||
|
|
2af24724dd | ||
|
|
fab8c5a1cd | ||
|
|
dcc045f03c | ||
|
|
ba90a4aaa4 | ||
|
|
325334f61a | ||
|
|
a8ddf7ad83 | ||
|
|
7d24a73192 | ||
|
|
e6c06a1da8 | ||
|
|
3ee09ba035 | ||
|
|
e9f70c9064 | ||
|
|
3fd6db2bf6 | ||
|
|
d596bea2d5 | ||
|
|
555b3652dc | ||
|
|
3d22a46c94 | ||
|
|
b30109df3c | ||
|
|
8771fbf3c8 | ||
|
|
b5d471a739 | ||
|
|
75d292bcf6 | ||
|
|
edf976ee8e | ||
|
|
f48da43bae | ||
|
|
3de19c8b31 | ||
|
|
6cb7d52a29 | ||
|
|
27e3f96819 | ||
|
|
cde02e017e | ||
|
|
0c10d37606 | ||
|
|
0436412412 | ||
|
|
940e317094 | ||
|
|
da1efdae0c | ||
|
|
4f3d22f06c | ||
|
|
41597c2856 | ||
|
|
33d0a0efa6 | ||
|
|
685eec3128 | ||
|
|
9fa4c3ce94 | ||
|
|
d212535ddd | ||
|
|
7f55b0cbd8 | ||
|
|
d6225ab846 | ||
|
|
85b3b1c8d6 | ||
|
|
159e991196 | ||
|
|
53b823afc8 | ||
|
|
2ac61a9914 | ||
|
|
6f714ed73e | ||
|
|
7c339ff442 | ||
|
|
4097ba6a00 | ||
|
|
26aea73673 | ||
|
|
81801ccc2b | ||
|
|
c57166caa3 | ||
|
|
9747df295e | ||
|
|
3eff652a7b | ||
|
|
75c9570c31 | ||
|
|
572baae10a | ||
|
|
7c60d0a6a2 | ||
|
|
1c3aa8d9b1 | ||
|
|
f413a3dbb2 | ||
|
|
43e8efe895 | ||
|
|
520024dfd6 | ||
|
|
a0fd4b7e57 | ||
|
|
822dc1bfb1 | ||
|
|
b0ed083ead | ||
|
|
245f3146c2 | ||
|
|
ec3432bccb | ||
|
|
bb7c786b09 | ||
|
|
98e0bedcd7 | ||
|
|
05d21438de | ||
|
|
597597e8b2 | ||
|
|
a89170cfb2 | ||
|
|
43e1b7b124 | ||
|
|
8cfe1a6832 | ||
|
|
592bf6a59c | ||
|
|
c5c9cef5c0 | ||
|
|
f9401ae011 | ||
|
|
b91bf08876 | ||
|
|
d88441025f | ||
|
|
f4094d09cd | ||
|
|
1a19c596bf | ||
|
|
f0c6f92140 | ||
|
|
74c38902ec | ||
|
|
a0ac3b6a1a | ||
|
|
e9daed189e | ||
|
|
4eee99aac5 | ||
|
|
21acf0bc8d | ||
|
|
b04da9d482 | ||
|
|
104e6b2050 | ||
|
|
616cf78203 | ||
|
|
277a8c975b | ||
|
|
dddd6ef006 | ||
|
|
2209fede4e | ||
|
|
17723a5294 | ||
|
|
f28da4f602 | ||
|
|
2abeb35d54 | ||
|
|
c512d6054d | ||
|
|
6167dd65b5 | ||
|
|
684facedb8 | ||
|
|
0a454554ae | ||
|
|
ad13d2d407 | ||
|
|
3591fc603f | ||
|
|
6f45fa66d8 | ||
|
|
769657060e | ||
|
|
b8f9b3779f | ||
|
|
fa34429a26 | ||
|
|
bbd120354a | ||
|
|
ecb781297b | ||
|
|
dc43ea8d03 | ||
|
|
a50b471b6b | ||
|
|
ad849c01d3 | ||
|
|
9bc0138ded | ||
|
|
85a79b3ad3 | ||
|
|
a6e0285320 | ||
|
|
f91312dbdb | ||
|
|
105008b6a1 | ||
|
|
15b9b39e6c | ||
|
|
560957799a | ||
|
|
a0b0db6305 | ||
|
|
632135ce4c | ||
|
|
257bfff316 | ||
|
|
66f0c464cc | ||
|
|
19bfcbf911 | ||
|
|
4f8ec44565 | ||
|
|
81e26d5a48 | ||
|
|
ba6349d39a | ||
|
|
bcb2594151 | ||
|
|
34f11e752f | ||
|
|
f728837ee6 | ||
|
|
96c7c18b18 | ||
|
|
d37f987639 | ||
|
|
f50d66f2d8 | ||
|
|
24d66944cb | ||
|
|
f25f776c9f |
@@ -1,7 +1,3 @@
|
|||||||
**/.git
|
|
||||||
.git
|
|
||||||
!.git/HEAD
|
|
||||||
!.git/refs/heads
|
|
||||||
**/*_test.go
|
**/*_test.go
|
||||||
|
|
||||||
build/_workspace
|
build/_workspace
|
||||||
|
|||||||
20
.github/CODEOWNERS
vendored
20
.github/CODEOWNERS
vendored
@@ -2,12 +2,22 @@
|
|||||||
# Each line is a file pattern followed by one or more owners.
|
# Each line is a file pattern followed by one or more owners.
|
||||||
|
|
||||||
accounts/usbwallet @karalabe
|
accounts/usbwallet @karalabe
|
||||||
|
accounts/scwallet @gballet
|
||||||
accounts/abi @gballet
|
accounts/abi @gballet
|
||||||
|
cmd/clef @holiman
|
||||||
|
cmd/puppeth @karalabe
|
||||||
consensus @karalabe
|
consensus @karalabe
|
||||||
core/ @karalabe @holiman
|
core/ @karalabe @holiman @rjl493456442
|
||||||
eth/ @karalabe
|
dashboard/ @kurkomisi
|
||||||
les/ @zsfelfoldi
|
eth/ @karalabe @holiman @rjl493456442
|
||||||
light/ @zsfelfoldi
|
graphql/ @gballet
|
||||||
mobile/ @karalabe
|
les/ @zsfelfoldi @rjl493456442
|
||||||
|
light/ @zsfelfoldi @rjl493456442
|
||||||
|
mobile/ @karalabe @ligi
|
||||||
p2p/ @fjl @zsfelfoldi
|
p2p/ @fjl @zsfelfoldi
|
||||||
|
rpc/ @fjl @holiman
|
||||||
|
p2p/simulations @zelig @nonsense @janos @justelad
|
||||||
|
p2p/protocols @zelig @nonsense @janos @justelad
|
||||||
|
p2p/testing @zelig @nonsense @janos @justelad
|
||||||
|
signer/ @holiman
|
||||||
whisper/ @gballet @gluk256
|
whisper/ @gballet @gluk256
|
||||||
|
|||||||
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,6 +1,6 @@
|
|||||||
Hi there,
|
Hi there,
|
||||||
|
|
||||||
please note that this is an issue tracker reserved for bug reports and feature requests.
|
Please note that this is an issue tracker reserved for bug reports and feature requests.
|
||||||
|
|
||||||
For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.
|
For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -42,6 +42,7 @@ profile.cov
|
|||||||
/dashboard/assets/node_modules
|
/dashboard/assets/node_modules
|
||||||
/dashboard/assets/stats.json
|
/dashboard/assets/stats.json
|
||||||
/dashboard/assets/bundle.js
|
/dashboard/assets/bundle.js
|
||||||
|
/dashboard/assets/bundle.js.map
|
||||||
/dashboard/assets/package-lock.json
|
/dashboard/assets/package-lock.json
|
||||||
|
|
||||||
**/yarn-error.log
|
**/yarn-error.log
|
||||||
|
|||||||
99
.travis.yml
99
.travis.yml
@@ -1,33 +1,48 @@
|
|||||||
language: go
|
language: go
|
||||||
go_import_path: github.com/ethereum/go-ethereum
|
go_import_path: github.com/ethereum/go-ethereum
|
||||||
sudo: false
|
sudo: false
|
||||||
matrix:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
# This builder only tests code linters on latest version of Go
|
||||||
|
- stage: lint
|
||||||
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
sudo: required
|
go: 1.12.x
|
||||||
go: 1.10.x
|
env:
|
||||||
|
- lint
|
||||||
|
git:
|
||||||
|
submodules: false # avoid cloning ethereum/tests
|
||||||
script:
|
script:
|
||||||
- sudo modprobe fuse
|
- go run build/ci.go lint
|
||||||
- sudo chmod 666 /dev/fuse
|
|
||||||
- sudo chown root:$USER /etc/fuse.conf
|
|
||||||
- go run build/ci.go install
|
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
|
||||||
|
|
||||||
# These are the latest Go versions.
|
- stage: build
|
||||||
- os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
sudo: required
|
|
||||||
go: 1.11.x
|
go: 1.11.x
|
||||||
script:
|
script:
|
||||||
- sudo modprobe fuse
|
|
||||||
- sudo chmod 666 /dev/fuse
|
|
||||||
- sudo chown root:$USER /etc/fuse.conf
|
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
- os: osx
|
- stage: build
|
||||||
go: 1.11.x
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
go: 1.12.x
|
||||||
|
script:
|
||||||
|
- go run build/ci.go install
|
||||||
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
|
# These are the latest Go versions.
|
||||||
|
- stage: build
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
go: 1.13.x
|
||||||
|
script:
|
||||||
|
- go run build/ci.go install
|
||||||
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
|
- stage: build
|
||||||
|
os: osx
|
||||||
|
go: 1.13.x
|
||||||
script:
|
script:
|
||||||
- echo "Increase the maximum number of open file descriptors on macOS"
|
- echo "Increase the maximum number of open file descriptors on macOS"
|
||||||
- NOFILE=20480
|
- NOFILE=20480
|
||||||
@@ -41,22 +56,12 @@ matrix:
|
|||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go test -coverage $TEST_PACKAGES
|
- go run build/ci.go test -coverage $TEST_PACKAGES
|
||||||
|
|
||||||
# This builder only tests code linters on latest version of Go
|
|
||||||
- os: linux
|
|
||||||
dist: xenial
|
|
||||||
go: 1.11.x
|
|
||||||
env:
|
|
||||||
- lint
|
|
||||||
git:
|
|
||||||
submodules: false # avoid cloning ethereum/tests
|
|
||||||
script:
|
|
||||||
- go run build/ci.go lint
|
|
||||||
|
|
||||||
# This builder does the Ubuntu PPA upload
|
# This builder does the Ubuntu PPA upload
|
||||||
- if: type = push
|
- stage: build
|
||||||
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
go: 1.11.x
|
go: 1.13.x
|
||||||
env:
|
env:
|
||||||
- ubuntu-ppa
|
- ubuntu-ppa
|
||||||
git:
|
git:
|
||||||
@@ -75,11 +80,12 @@ matrix:
|
|||||||
- go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"
|
- go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>"
|
||||||
|
|
||||||
# This builder does the Linux Azure uploads
|
# This builder does the Linux Azure uploads
|
||||||
- if: type = push
|
- stage: build
|
||||||
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
sudo: required
|
sudo: required
|
||||||
go: 1.11.x
|
go: 1.13.x
|
||||||
env:
|
env:
|
||||||
- azure-linux
|
- azure-linux
|
||||||
git:
|
git:
|
||||||
@@ -109,12 +115,13 @@ matrix:
|
|||||||
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the Linux Azure MIPS xgo uploads
|
# This builder does the Linux Azure MIPS xgo uploads
|
||||||
- if: type = push
|
- stage: build
|
||||||
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
go: 1.11.x
|
go: 1.13.x
|
||||||
env:
|
env:
|
||||||
- azure-linux-mips
|
- azure-linux-mips
|
||||||
git:
|
git:
|
||||||
@@ -137,7 +144,8 @@ matrix:
|
|||||||
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the Android Maven and Azure uploads
|
# This builder does the Android Maven and Azure uploads
|
||||||
- if: type = push
|
- stage: build
|
||||||
|
if: type = push
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
addons:
|
addons:
|
||||||
@@ -159,25 +167,25 @@ matrix:
|
|||||||
git:
|
git:
|
||||||
submodules: false # avoid cloning ethereum/tests
|
submodules: false # avoid cloning ethereum/tests
|
||||||
before_install:
|
before_install:
|
||||||
- curl https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz | tar -xz
|
- curl https://dl.google.com/go/go1.13.linux-amd64.tar.gz | tar -xz
|
||||||
- export PATH=`pwd`/go/bin:$PATH
|
- export PATH=`pwd`/go/bin:$PATH
|
||||||
- export GOROOT=`pwd`/go
|
- export GOROOT=`pwd`/go
|
||||||
- export GOPATH=$HOME/go
|
- export GOPATH=$HOME/go
|
||||||
script:
|
script:
|
||||||
# Build the Android archive and upload it to Maven Central and Azure
|
# Build the Android archive and upload it to Maven Central and Azure
|
||||||
- curl https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip -o android-ndk-r17b.zip
|
- curl https://dl.google.com/android/repository/android-ndk-r19b-linux-x86_64.zip -o android-ndk-r19b.zip
|
||||||
- unzip -q android-ndk-r17b.zip && rm android-ndk-r17b.zip
|
- unzip -q android-ndk-r19b.zip && rm android-ndk-r19b.zip
|
||||||
- mv android-ndk-r17b $HOME
|
- mv android-ndk-r19b $ANDROID_HOME/ndk-bundle
|
||||||
- export ANDROID_NDK=$HOME/android-ndk-r17b
|
|
||||||
|
|
||||||
- mkdir -p $GOPATH/src/github.com/ethereum
|
- mkdir -p $GOPATH/src/github.com/ethereum
|
||||||
- ln -s `pwd` $GOPATH/src/github.com/ethereum
|
- ln -s `pwd` $GOPATH/src/github.com/ethereum/go-ethereum
|
||||||
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
|
- go run build/ci.go aar -signer ANDROID_SIGNING_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
|
# This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
|
||||||
- if: type = push
|
- stage: build
|
||||||
|
if: type = push
|
||||||
os: osx
|
os: osx
|
||||||
go: 1.11.x
|
go: 1.13.x
|
||||||
env:
|
env:
|
||||||
- azure-osx
|
- azure-osx
|
||||||
- azure-ios
|
- azure-ios
|
||||||
@@ -204,10 +212,11 @@ matrix:
|
|||||||
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -deploy trunk -upload gethstore/builds
|
- go run build/ci.go xcode -signer IOS_SIGNING_KEY -deploy trunk -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the Azure archive purges to avoid accumulating junk
|
# This builder does the Azure archive purges to avoid accumulating junk
|
||||||
- if: type = cron
|
- stage: build
|
||||||
|
if: type = cron
|
||||||
os: linux
|
os: linux
|
||||||
dist: xenial
|
dist: xenial
|
||||||
go: 1.11.x
|
go: 1.13.x
|
||||||
env:
|
env:
|
||||||
- azure-purge
|
- azure-purge
|
||||||
git:
|
git:
|
||||||
|
|||||||
247
AUTHORS
247
AUTHORS
@@ -1,5 +1,11 @@
|
|||||||
# This is the official list of go-ethereum authors for copyright purposes.
|
# This is the official list of go-ethereum authors for copyright purposes.
|
||||||
|
|
||||||
|
a e r t h <aerth@users.noreply.github.com>
|
||||||
|
Abel Nieto <abel.nieto90@gmail.com>
|
||||||
|
Abel Nieto <anietoro@uwaterloo.ca>
|
||||||
|
Adam Babik <a.babik@designfortress.com>
|
||||||
|
Aditya <adityasripal@gmail.com>
|
||||||
|
Adrià Cidre <adria.cidre@gmail.com>
|
||||||
Afri Schoedon <5chdn@users.noreply.github.com>
|
Afri Schoedon <5chdn@users.noreply.github.com>
|
||||||
Agustin Armellini Fischer <armellini13@gmail.com>
|
Agustin Armellini Fischer <armellini13@gmail.com>
|
||||||
Airead <fgh1987168@gmail.com>
|
Airead <fgh1987168@gmail.com>
|
||||||
@@ -10,165 +16,354 @@ Alex Leverington <alex@ethdev.com>
|
|||||||
Alex Wu <wuyiding@gmail.com>
|
Alex Wu <wuyiding@gmail.com>
|
||||||
Alexandre Van de Sande <alex.vandesande@ethdev.com>
|
Alexandre Van de Sande <alex.vandesande@ethdev.com>
|
||||||
Ali Hajimirza <Ali92hm@users.noreply.github.com>
|
Ali Hajimirza <Ali92hm@users.noreply.github.com>
|
||||||
|
am2rican5 <am2rican5@gmail.com>
|
||||||
|
Andrea Franz <andrea@gravityblast.com>
|
||||||
|
Andrey Petrov <andrey.petrov@shazow.net>
|
||||||
|
Andrey Petrov <shazow@gmail.com>
|
||||||
|
ANOTHEL <anothel1@naver.com>
|
||||||
|
Antoine Rondelet <rondelet.antoine@gmail.com>
|
||||||
Anton Evangelatov <anton.evangelatov@gmail.com>
|
Anton Evangelatov <anton.evangelatov@gmail.com>
|
||||||
|
Antonio Salazar Cardozo <savedfastcool@gmail.com>
|
||||||
Arba Sasmoyo <arba.sasmoyo@gmail.com>
|
Arba Sasmoyo <arba.sasmoyo@gmail.com>
|
||||||
Armani Ferrante <armaniferrante@berkeley.edu>
|
Armani Ferrante <armaniferrante@berkeley.edu>
|
||||||
Armin Braun <me@obrown.io>
|
Armin Braun <me@obrown.io>
|
||||||
Aron Fischer <github@aron.guru>
|
Aron Fischer <github@aron.guru>
|
||||||
|
atsushi-ishibashi <atsushi.ishibashi@finatext.com>
|
||||||
|
ayeowch <ayeowch@gmail.com>
|
||||||
|
b00ris <b00ris@mail.ru>
|
||||||
|
bailantaotao <Edwin@maicoin.com>
|
||||||
|
baizhenxuan <nkbai@163.com>
|
||||||
|
Balint Gabor <balint.g@gmail.com>
|
||||||
Bas van Kervel <bas@ethdev.com>
|
Bas van Kervel <bas@ethdev.com>
|
||||||
Benjamin Brent <benjamin@benjaminbrent.com>
|
Benjamin Brent <benjamin@benjaminbrent.com>
|
||||||
|
benma <mbencun@gmail.com>
|
||||||
Benoit Verkindt <benoit.verkindt@gmail.com>
|
Benoit Verkindt <benoit.verkindt@gmail.com>
|
||||||
|
bloonfield <bloonfield@163.com>
|
||||||
Bo <bohende@gmail.com>
|
Bo <bohende@gmail.com>
|
||||||
Bo Ye <boy.e.computer.1982@outlook.com>
|
Bo Ye <boy.e.computer.1982@outlook.com>
|
||||||
Bob Glickstein <bobg@users.noreply.github.com>
|
Bob Glickstein <bobg@users.noreply.github.com>
|
||||||
|
Brent <bmperrea@gmail.com>
|
||||||
Brian Schroeder <bts@gmail.com>
|
Brian Schroeder <bts@gmail.com>
|
||||||
|
Bruno Škvorc <bruno@skvorc.me>
|
||||||
|
C. Brown <hackdom@majoolr.io>
|
||||||
|
Caesar Chad <BLUE.WEB.GEEK@gmail.com>
|
||||||
Casey Detrio <cdetrio@gmail.com>
|
Casey Detrio <cdetrio@gmail.com>
|
||||||
|
CDsigma <cdsigma271@gmail.com>
|
||||||
|
changhong <changhong.yu@shanbay.com>
|
||||||
Chase Wright <mysticryuujin@gmail.com>
|
Chase Wright <mysticryuujin@gmail.com>
|
||||||
|
Chen Quan <terasum@163.com>
|
||||||
|
chenyufeng <yufengcode@gmail.com>
|
||||||
|
Christian Muehlhaeuser <muesli@gmail.com>
|
||||||
Christoph Jentzsch <jentzsch.software@gmail.com>
|
Christoph Jentzsch <jentzsch.software@gmail.com>
|
||||||
|
cong <ackratos@users.noreply.github.com>
|
||||||
|
Corey Lin <514971757@qq.com>
|
||||||
|
cpusoft <cpusoft@live.com>
|
||||||
|
Crispin Flowerday <crispin@bitso.com>
|
||||||
|
croath <croathliu@gmail.com>
|
||||||
|
cui <523516579@qq.com>
|
||||||
|
Dan Kinsley <dan@joincivil.com>
|
||||||
Daniel A. Nagy <nagy.da@gmail.com>
|
Daniel A. Nagy <nagy.da@gmail.com>
|
||||||
Daniel Sloof <goapsychadelic@gmail.com>
|
Daniel Sloof <goapsychadelic@gmail.com>
|
||||||
Darrel Herbst <dherbst@gmail.com>
|
Darrel Herbst <dherbst@gmail.com>
|
||||||
Dave Appleton <calistralabs@gmail.com>
|
Dave Appleton <calistralabs@gmail.com>
|
||||||
|
Dave McGregor <dave.s.mcgregor@gmail.com>
|
||||||
|
David Huie <dahuie@gmail.com>
|
||||||
|
Derek Gottfrid <derek@codecubed.com>
|
||||||
Diego Siqueira <DiSiqueira@users.noreply.github.com>
|
Diego Siqueira <DiSiqueira@users.noreply.github.com>
|
||||||
|
Diep Pham <mrfavadi@gmail.com>
|
||||||
|
dipingxian2 <39109351+dipingxian2@users.noreply.github.com>
|
||||||
|
dm4 <sunrisedm4@gmail.com>
|
||||||
|
Dmitrij Koniajev <dimchansky@gmail.com>
|
||||||
Dmitry Shulyak <yashulyak@gmail.com>
|
Dmitry Shulyak <yashulyak@gmail.com>
|
||||||
|
Domino Valdano <dominoplural@gmail.com>
|
||||||
|
Domino Valdano <jeff@okcupid.com>
|
||||||
|
Dragan Milic <dragan@netice9.com>
|
||||||
|
dragonvslinux <35779158+dragononcrypto@users.noreply.github.com>
|
||||||
Egon Elbre <egonelbre@gmail.com>
|
Egon Elbre <egonelbre@gmail.com>
|
||||||
|
Elad <theman@elad.im>
|
||||||
|
Eli <elihanover@yahoo.com>
|
||||||
Elias Naur <elias.naur@gmail.com>
|
Elias Naur <elias.naur@gmail.com>
|
||||||
Elliot Shepherd <elliot@identitii.com>
|
Elliot Shepherd <elliot@identitii.com>
|
||||||
|
Emil <mursalimovemeel@gmail.com>
|
||||||
|
emile <emile@users.noreply.github.com>
|
||||||
Enrique Fynn <enriquefynn@gmail.com>
|
Enrique Fynn <enriquefynn@gmail.com>
|
||||||
|
Enrique Fynn <me@enriquefynn.com>
|
||||||
|
EOS Classic <info@eos-classic.io>
|
||||||
|
Erichin <erichinbato@gmail.com>
|
||||||
Ernesto del Toro <ernesto.deltoro@gmail.com>
|
Ernesto del Toro <ernesto.deltoro@gmail.com>
|
||||||
Ethan Buchman <ethan@coinculture.info>
|
Ethan Buchman <ethan@coinculture.info>
|
||||||
|
ethersphere <thesw@rm.eth>
|
||||||
Eugene Valeyev <evgen.povt@gmail.com>
|
Eugene Valeyev <evgen.povt@gmail.com>
|
||||||
Evangelos Pappas <epappas@evalonlabs.com>
|
Evangelos Pappas <epappas@evalonlabs.com>
|
||||||
|
Evgeny <awesome.observer@yandex.com>
|
||||||
Evgeny Danilenko <6655321@bk.ru>
|
Evgeny Danilenko <6655321@bk.ru>
|
||||||
|
evgk <evgeniy.kamyshev@gmail.com>
|
||||||
Fabian Vogelsteller <fabian@frozeman.de>
|
Fabian Vogelsteller <fabian@frozeman.de>
|
||||||
Fabio Barone <fabio.barone.co@gmail.com>
|
Fabio Barone <fabio.barone.co@gmail.com>
|
||||||
Fabio Berger <fabioberger1991@gmail.com>
|
Fabio Berger <fabioberger1991@gmail.com>
|
||||||
FaceHo <facehoshi@gmail.com>
|
FaceHo <facehoshi@gmail.com>
|
||||||
Felix Lange <fjl@twurst.com>
|
Felix Lange <fjl@twurst.com>
|
||||||
|
Ferenc Szabo <frncmx@gmail.com>
|
||||||
|
ferhat elmas <elmas.ferhat@gmail.com>
|
||||||
Fiisio <liangcszzu@163.com>
|
Fiisio <liangcszzu@163.com>
|
||||||
|
Frank Szendzielarz <33515470+FrankSzendzielarz@users.noreply.github.com>
|
||||||
Frank Wang <eternnoir@gmail.com>
|
Frank Wang <eternnoir@gmail.com>
|
||||||
|
Franklin <mr_franklin@126.com>
|
||||||
Furkan KAMACI <furkankamaci@gmail.com>
|
Furkan KAMACI <furkankamaci@gmail.com>
|
||||||
|
GagziW <leon.stanko@rwth-aachen.de>
|
||||||
Gary Rong <garyrong0905@gmail.com>
|
Gary Rong <garyrong0905@gmail.com>
|
||||||
George Ornbo <george@shapeshed.com>
|
George Ornbo <george@shapeshed.com>
|
||||||
Gregg Dourgarian <greggd@tempworks.com>
|
Gregg Dourgarian <greggd@tempworks.com>
|
||||||
|
Guilherme Salgado <gsalgado@gmail.com>
|
||||||
Guillaume Ballet <gballet@gmail.com>
|
Guillaume Ballet <gballet@gmail.com>
|
||||||
Guillaume Nicolas <guin56@gmail.com>
|
Guillaume Nicolas <guin56@gmail.com>
|
||||||
|
GuiltyMorishita <morilliantblue@gmail.com>
|
||||||
|
Gus <yo@soygus.com>
|
||||||
Gustav Simonsson <gustav.simonsson@gmail.com>
|
Gustav Simonsson <gustav.simonsson@gmail.com>
|
||||||
|
Gísli Kristjánsson <gislik@hamstur.is>
|
||||||
|
Ha ĐANG <dvietha@gmail.com>
|
||||||
|
HackyMiner <hackyminer@gmail.com>
|
||||||
|
hadv <dvietha@gmail.com>
|
||||||
Hao Bryan Cheng <haobcheng@gmail.com>
|
Hao Bryan Cheng <haobcheng@gmail.com>
|
||||||
|
HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
|
||||||
Henning Diedrich <hd@eonblast.com>
|
Henning Diedrich <hd@eonblast.com>
|
||||||
|
holisticode <holistic.computing@gmail.com>
|
||||||
|
Hongbin Mao <hello2mao@gmail.com>
|
||||||
|
Hsien-Tang Kao <htkao@pm.me>
|
||||||
|
Husam Ibrahim <39692071+HusamIbrahim@users.noreply.github.com>
|
||||||
|
hydai <z54981220@gmail.com>
|
||||||
|
Hyung-Kyu Hqueue Choi <hyungkyu.choi@gmail.com>
|
||||||
|
Ian Macalinao <me@ian.pw>
|
||||||
|
Ian Norden <iannordenn@gmail.com>
|
||||||
Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
|
Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
|
||||||
|
Iskander (Alex) Sharipov <quasilyte@gmail.com>
|
||||||
Ivan Daniluk <ivan.daniluk@gmail.com>
|
Ivan Daniluk <ivan.daniluk@gmail.com>
|
||||||
|
Ivo Georgiev <ivo@strem.io>
|
||||||
Jae Kwon <jkwon.work@gmail.com>
|
Jae Kwon <jkwon.work@gmail.com>
|
||||||
Jamie Pitts <james.pitts@gmail.com>
|
Jamie Pitts <james.pitts@gmail.com>
|
||||||
|
Janos Guljas <janos@resenje.org>
|
||||||
Janoš Guljaš <janos@users.noreply.github.com>
|
Janoš Guljaš <janos@users.noreply.github.com>
|
||||||
Jason Carver <jacarver@linkedin.com>
|
Jason Carver <jacarver@linkedin.com>
|
||||||
|
Javier Peletier <jm@epiclabs.io>
|
||||||
|
Javier Peletier <jpeletier@users.noreply.github.com>
|
||||||
|
Javier Sagredo <jasataco@gmail.com>
|
||||||
|
Jay <codeholic.arena@gmail.com>
|
||||||
Jay Guo <guojiannan1101@gmail.com>
|
Jay Guo <guojiannan1101@gmail.com>
|
||||||
|
Jaynti Kanani <jdkanani@gmail.com>
|
||||||
|
Jeff Prestes <jeffprestes@gmail.com>
|
||||||
Jeff R. Allen <jra@nella.org>
|
Jeff R. Allen <jra@nella.org>
|
||||||
|
Jeffery Robert Walsh <rlxrlps@gmail.com>
|
||||||
Jeffrey Wilcke <jeffrey@ethereum.org>
|
Jeffrey Wilcke <jeffrey@ethereum.org>
|
||||||
Jens Agerberg <github@agerberg.me>
|
Jens Agerberg <github@agerberg.me>
|
||||||
|
Jeremy McNevin <jeremy.mcnevin@optum.com>
|
||||||
|
Jeremy Schlatter <jeremy.schlatter@gmail.com>
|
||||||
|
Jerzy Lasyk <jerzylasyk@gmail.com>
|
||||||
Jia Chenhui <jiachenhui1989@gmail.com>
|
Jia Chenhui <jiachenhui1989@gmail.com>
|
||||||
Jim McDonald <Jim@mcdee.net>
|
Jim McDonald <Jim@mcdee.net>
|
||||||
|
jkcomment <jkcomment@gmail.com>
|
||||||
Joel Burget <joelburget@gmail.com>
|
Joel Burget <joelburget@gmail.com>
|
||||||
|
John C. Vernaleo <john@netpurgatory.com>
|
||||||
|
Johns Beharry <johns@peakshift.com>
|
||||||
|
Jonas <felberj@users.noreply.github.com>
|
||||||
Jonathan Brown <jbrown@bluedroplet.com>
|
Jonathan Brown <jbrown@bluedroplet.com>
|
||||||
|
JoranHonig <JoranHonig@users.noreply.github.com>
|
||||||
|
Jordan Krage <jmank88@gmail.com>
|
||||||
Joseph Chow <ethereum@outlook.com>
|
Joseph Chow <ethereum@outlook.com>
|
||||||
|
jtakalai <juuso.takalainen@streamr.com>
|
||||||
|
JU HYEONG PARK <dkdkajej@gmail.com>
|
||||||
Justin Clark-Casey <justincc@justincc.org>
|
Justin Clark-Casey <justincc@justincc.org>
|
||||||
Justin Drake <drakefjustin@gmail.com>
|
Justin Drake <drakefjustin@gmail.com>
|
||||||
|
jwasinger <j-wasinger@hotmail.com>
|
||||||
|
ken10100147 <sunhongping@kanjian.com>
|
||||||
Kenji Siu <kenji@isuntv.com>
|
Kenji Siu <kenji@isuntv.com>
|
||||||
|
Kenso Trabing <kenso.trabing@bloomwebsite.com>
|
||||||
|
Kenso Trabing <ktrabing@acm.org>
|
||||||
|
Kevin <denk.kevin@web.de>
|
||||||
|
kevin.xu <cming.xu@gmail.com>
|
||||||
|
kiel barry <kiel.j.barry@gmail.com>
|
||||||
|
kimmylin <30611210+kimmylin@users.noreply.github.com>
|
||||||
|
Kitten King <53072918+kittenking@users.noreply.github.com>
|
||||||
|
knarfeh <hejun1874@gmail.com>
|
||||||
Kobi Gurkan <kobigurk@gmail.com>
|
Kobi Gurkan <kobigurk@gmail.com>
|
||||||
Konrad Feldmeier <konrad@brainbot.com>
|
Konrad Feldmeier <konrad@brainbot.com>
|
||||||
|
Kris Shinn <raggamuffin.music@gmail.com>
|
||||||
Kurkó Mihály <kurkomisi@users.noreply.github.com>
|
Kurkó Mihály <kurkomisi@users.noreply.github.com>
|
||||||
|
Kushagra Sharma <ksharm01@gmail.com>
|
||||||
|
Kwuaint <34888408+kwuaint@users.noreply.github.com>
|
||||||
Kyuntae Ethan Kim <ethan.kyuntae.kim@gmail.com>
|
Kyuntae Ethan Kim <ethan.kyuntae.kim@gmail.com>
|
||||||
|
ledgerwatch <akhounov@gmail.com>
|
||||||
Lefteris Karapetsas <lefteris@refu.co>
|
Lefteris Karapetsas <lefteris@refu.co>
|
||||||
Leif Jurvetson <leijurv@gmail.com>
|
Leif Jurvetson <leijurv@gmail.com>
|
||||||
Leo Shklovskii <leo@thermopylae.net>
|
Leo Shklovskii <leo@thermopylae.net>
|
||||||
|
LeoLiao <leofantast@gmail.com>
|
||||||
Lewis Marshall <lewis@lmars.net>
|
Lewis Marshall <lewis@lmars.net>
|
||||||
|
lhendre <lhendre2@gmail.com>
|
||||||
|
Liang Ma <liangma.ul@gmail.com>
|
||||||
|
Liang Ma <liangma@liangbit.com>
|
||||||
|
Liang ZOU <liang.d.zou@gmail.com>
|
||||||
|
libotony <liboliqi@gmail.com>
|
||||||
|
ligi <ligi@ligi.de>
|
||||||
Lio李欧 <lionello@users.noreply.github.com>
|
Lio李欧 <lionello@users.noreply.github.com>
|
||||||
|
Lorenzo Manacorda <lorenzo@kinvolk.io>
|
||||||
Louis Holbrook <dev@holbrook.no>
|
Louis Holbrook <dev@holbrook.no>
|
||||||
Luca Zeug <luclu@users.noreply.github.com>
|
Luca Zeug <luclu@users.noreply.github.com>
|
||||||
Magicking <s@6120.eu>
|
Magicking <s@6120.eu>
|
||||||
|
manlio <manlio.poltronieri@gmail.com>
|
||||||
Maran Hidskes <maran.hidskes@gmail.com>
|
Maran Hidskes <maran.hidskes@gmail.com>
|
||||||
Marek Kotewicz <marek.kotewicz@gmail.com>
|
Marek Kotewicz <marek.kotewicz@gmail.com>
|
||||||
|
Marius van der Wijden <m.vanderwijden@live.de>
|
||||||
Mark <markya0616@gmail.com>
|
Mark <markya0616@gmail.com>
|
||||||
|
Mark Rushakoff <mark.rushakoff@gmail.com>
|
||||||
|
mark.lin <mark@maicoin.com>
|
||||||
|
Martin Alex Philip Dawson <u1356770@gmail.com>
|
||||||
Martin Holst Swende <martin@swende.se>
|
Martin Holst Swende <martin@swende.se>
|
||||||
|
Martin Klepsch <martinklepsch@googlemail.com>
|
||||||
|
Mats Julian Olsen <mats@plysjbyen.net>
|
||||||
|
Matt K <1036969+mkrump@users.noreply.github.com>
|
||||||
Matthew Di Ferrante <mattdf@users.noreply.github.com>
|
Matthew Di Ferrante <mattdf@users.noreply.github.com>
|
||||||
|
Matthew Halpern <matthalp@gmail.com>
|
||||||
|
Matthew Halpern <matthalp@google.com>
|
||||||
Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
|
Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
|
||||||
|
Max Sistemich <mafrasi2@googlemail.com>
|
||||||
Maximilian Meister <mmeister@suse.de>
|
Maximilian Meister <mmeister@suse.de>
|
||||||
Micah Zoltu <micah@zoltu.net>
|
Micah Zoltu <micah@zoltu.net>
|
||||||
Michael Ruminer <michael.ruminer+github@gmail.com>
|
Michael Ruminer <michael.ruminer+github@gmail.com>
|
||||||
Miguel Mota <miguelmota2@gmail.com>
|
Miguel Mota <miguelmota2@gmail.com>
|
||||||
Miya Chen <miyatlchen@gmail.com>
|
Miya Chen <miyatlchen@gmail.com>
|
||||||
|
Mohanson <mohanson@outlook.com>
|
||||||
|
mr_franklin <mr_franklin@126.com>
|
||||||
|
Mymskmkt <1847234666@qq.com>
|
||||||
|
Nalin Bhardwaj <nalinbhardwaj@nibnalin.me>
|
||||||
Nchinda Nchinda <nchinda2@gmail.com>
|
Nchinda Nchinda <nchinda2@gmail.com>
|
||||||
|
necaremus <necaremus@gmail.com>
|
||||||
|
needkane <604476380@qq.com>
|
||||||
|
Nguyen Kien Trung <trung.n.k@gmail.com>
|
||||||
|
Nguyen Sy Thanh Son <thanhson1085@gmail.com>
|
||||||
Nick Dodson <silentcicero@outlook.com>
|
Nick Dodson <silentcicero@outlook.com>
|
||||||
Nick Johnson <arachnid@notdot.net>
|
Nick Johnson <arachnid@notdot.net>
|
||||||
Nicolas Guillaume <gunicolas@sqli.com>
|
Nicolas Guillaume <gunicolas@sqli.com>
|
||||||
|
Nilesh Trivedi <nilesh@hypertrack.io>
|
||||||
|
Nimrod Gutman <nimrod.gutman@gmail.com>
|
||||||
|
njupt-moon <1015041018@njupt.edu.cn>
|
||||||
|
nkbai <nkbai@163.com>
|
||||||
|
nobody <ddean2009@163.com>
|
||||||
Noman <noman@noman.land>
|
Noman <noman@noman.land>
|
||||||
|
Oleg Kovalov <iamolegkovalov@gmail.com>
|
||||||
Oli Bye <olibye@users.noreply.github.com>
|
Oli Bye <olibye@users.noreply.github.com>
|
||||||
|
Osuke <arget-fee.free.dgm@hotmail.co.jp>
|
||||||
|
Paul Berg <hello@paulrberg.com>
|
||||||
Paul Litvak <litvakpol@012.net.il>
|
Paul Litvak <litvakpol@012.net.il>
|
||||||
Paulo L F Casaretto <pcasaretto@gmail.com>
|
Paulo L F Casaretto <pcasaretto@gmail.com>
|
||||||
Paweł Bylica <chfast@gmail.com>
|
Paweł Bylica <chfast@gmail.com>
|
||||||
|
Pedro Pombeiro <PombeirP@users.noreply.github.com>
|
||||||
|
Peter Broadhurst <peter@themumbles.net>
|
||||||
Peter Pratscher <pratscher@gmail.com>
|
Peter Pratscher <pratscher@gmail.com>
|
||||||
Petr Mikusek <petr@mikusek.info>
|
Petr Mikusek <petr@mikusek.info>
|
||||||
|
Philip Schlump <pschlump@gmail.com>
|
||||||
|
Pierre Neter <pierreneter@gmail.com>
|
||||||
|
PilkyuJung <anothel1@naver.com>
|
||||||
|
protolambda <proto@protolambda.com>
|
||||||
Péter Szilágyi <peterke@gmail.com>
|
Péter Szilágyi <peterke@gmail.com>
|
||||||
RJ Catalano <catalanor0220@gmail.com>
|
qd-ethan <31876119+qdgogogo@users.noreply.github.com>
|
||||||
|
Raghav Sood <raghavsood@gmail.com>
|
||||||
|
Ralph Caraveo <deckarep@gmail.com>
|
||||||
|
Ralph Caraveo III <deckarep@gmail.com>
|
||||||
Ramesh Nair <ram@hiddentao.com>
|
Ramesh Nair <ram@hiddentao.com>
|
||||||
|
reinerRubin <tolstov.georgij@gmail.com>
|
||||||
|
rhaps107 <dod-source@yandex.ru>
|
||||||
Ricardo Catalinas Jiménez <r@untroubled.be>
|
Ricardo Catalinas Jiménez <r@untroubled.be>
|
||||||
Ricardo Domingos <ricardohsd@gmail.com>
|
Ricardo Domingos <ricardohsd@gmail.com>
|
||||||
Richard Hart <richardhart92@gmail.com>
|
Richard Hart <richardhart92@gmail.com>
|
||||||
|
RJ Catalano <catalanor0220@gmail.com>
|
||||||
Rob <robert@rojotek.com>
|
Rob <robert@rojotek.com>
|
||||||
|
Rob Mulholand <rmulholand@8thlight.com>
|
||||||
Robert Zaremba <robert.zaremba@scale-it.pl>
|
Robert Zaremba <robert.zaremba@scale-it.pl>
|
||||||
|
Roc Yu <rociiu0112@gmail.com>
|
||||||
|
Runchao Han <elvisage941102@gmail.com>
|
||||||
Russ Cox <rsc@golang.org>
|
Russ Cox <rsc@golang.org>
|
||||||
|
Ryan Schneider <ryanleeschneider@gmail.com>
|
||||||
Rémy Roy <remyroy@remyroy.com>
|
Rémy Roy <remyroy@remyroy.com>
|
||||||
S. Matthew English <s-matthew-english@users.noreply.github.com>
|
S. Matthew English <s-matthew-english@users.noreply.github.com>
|
||||||
|
salanfe <salanfe@users.noreply.github.com>
|
||||||
|
Samuel Marks <samuelmarks@gmail.com>
|
||||||
|
Sarlor <kinsleer@outlook.com>
|
||||||
|
Sasuke1964 <neilperry1964@gmail.com>
|
||||||
|
Saulius Grigaitis <saulius@necolt.com>
|
||||||
|
Sean <darcys22@gmail.com>
|
||||||
|
Sheldon <11510383@mail.sustc.edu.cn>
|
||||||
|
Sheldon <374662347@qq.com>
|
||||||
Shintaro Kaneko <kaneshin0120@gmail.com>
|
Shintaro Kaneko <kaneshin0120@gmail.com>
|
||||||
|
Shuai Qi <qishuai231@gmail.com>
|
||||||
|
Shunsuke Watanabe <ww.shunsuke@gmail.com>
|
||||||
|
silence <wangsai.silence@qq.com>
|
||||||
|
Simon Jentzsch <simon@slock.it>
|
||||||
|
slumber1122 <slumber1122@gmail.com>
|
||||||
|
Smilenator <yurivanenko@yandex.ru>
|
||||||
Sorin Neacsu <sorin.neacsu@gmail.com>
|
Sorin Neacsu <sorin.neacsu@gmail.com>
|
||||||
Stein Dekker <dekker.stein@gmail.com>
|
Stein Dekker <dekker.stein@gmail.com>
|
||||||
|
Steve Gattuso <steve@stevegattuso.me>
|
||||||
|
Steve Ruckdashel <steve.ruckdashel@gmail.com>
|
||||||
Steve Waldman <swaldman@mchange.com>
|
Steve Waldman <swaldman@mchange.com>
|
||||||
Steven Roose <stevenroose@gmail.com>
|
Steven Roose <stevenroose@gmail.com>
|
||||||
|
stompesi <stompesi@gmail.com>
|
||||||
|
stormpang <jialinpeng@vip.qq.com>
|
||||||
|
sunxiaojun2014 <sunxiaojun-xy@360.cn>
|
||||||
|
tamirms <tamir@trello.com>
|
||||||
Taylor Gerring <taylor.gerring@gmail.com>
|
Taylor Gerring <taylor.gerring@gmail.com>
|
||||||
|
TColl <38299499+TColl@users.noreply.github.com>
|
||||||
|
terasum <terasum@163.com>
|
||||||
Thomas Bocek <tom@tomp2p.net>
|
Thomas Bocek <tom@tomp2p.net>
|
||||||
|
thomasmodeneis <thomas.modeneis@gmail.com>
|
||||||
|
thumb8432 <thumb8432@gmail.com>
|
||||||
Ti Zhou <tizhou1986@gmail.com>
|
Ti Zhou <tizhou1986@gmail.com>
|
||||||
Tosh Camille <tochecamille@gmail.com>
|
Tosh Camille <tochecamille@gmail.com>
|
||||||
|
tsarpaul <Litvakpol@012.net.il>
|
||||||
|
tzapu <alex@tzapu.com>
|
||||||
|
ult-bobonovski <alex@ultiledger.io>
|
||||||
Valentin Wüstholz <wuestholz@gmail.com>
|
Valentin Wüstholz <wuestholz@gmail.com>
|
||||||
|
Vedhavyas Singareddi <vedhavyas.singareddi@gmail.com>
|
||||||
Victor Farazdagi <simple.square@gmail.com>
|
Victor Farazdagi <simple.square@gmail.com>
|
||||||
Victor Tran <vu.tran54@gmail.com>
|
Victor Tran <vu.tran54@gmail.com>
|
||||||
|
Vie <yangchenzhong@gmail.com>
|
||||||
Viktor Trón <viktor.tron@gmail.com>
|
Viktor Trón <viktor.tron@gmail.com>
|
||||||
Ville Sundell <github@solarius.fi>
|
Ville Sundell <github@solarius.fi>
|
||||||
|
vim88 <vim88vim88@gmail.com>
|
||||||
Vincent G <caktux@gmail.com>
|
Vincent G <caktux@gmail.com>
|
||||||
|
Vincent Serpoul <vincent@serpoul.com>
|
||||||
Vitalik Buterin <v@buterin.com>
|
Vitalik Buterin <v@buterin.com>
|
||||||
|
Vitaly Bogdanov <vsbogd@gmail.com>
|
||||||
Vitaly V <vvelikodny@gmail.com>
|
Vitaly V <vvelikodny@gmail.com>
|
||||||
Vivek Anand <vivekanand1101@users.noreply.github.com>
|
Vivek Anand <vivekanand1101@users.noreply.github.com>
|
||||||
|
Vlad <gluk256@gmail.com>
|
||||||
|
Vlad Bokov <razum2um@mail.ru>
|
||||||
Vlad Gluhovsky <gluk256@users.noreply.github.com>
|
Vlad Gluhovsky <gluk256@users.noreply.github.com>
|
||||||
|
weimumu <934657014@qq.com>
|
||||||
|
Wenbiao Zheng <delweng@gmail.com>
|
||||||
|
William Setzer <bootstrapsetzer@gmail.com>
|
||||||
|
williambannas <wrschwartz@wpi.edu>
|
||||||
|
Wuxiang <wuxiangzhou2010@gmail.com>
|
||||||
|
xiekeyang <xiekeyang@users.noreply.github.com>
|
||||||
|
xincaosu <xincaosu@126.com>
|
||||||
|
yahtoo <yahtoo.ma@gmail.com>
|
||||||
|
YaoZengzeng <yaozengzeng@zju.edu.cn>
|
||||||
|
YH-Zhou <yanhong.zhou05@gmail.com>
|
||||||
Yohann Léon <sybiload@gmail.com>
|
Yohann Léon <sybiload@gmail.com>
|
||||||
Yoichi Hirai <i@yoichihirai.com>
|
Yoichi Hirai <i@yoichihirai.com>
|
||||||
Yondon Fu <yondon.fu@gmail.com>
|
Yondon Fu <yondon.fu@gmail.com>
|
||||||
|
YOSHIDA Masanori <masanori.yoshida@gmail.com>
|
||||||
|
yoza <yoza.is12s@gmail.com>
|
||||||
|
Yusup <awklsgrep@gmail.com>
|
||||||
Zach <zach.ramsay@gmail.com>
|
Zach <zach.ramsay@gmail.com>
|
||||||
|
zah <zahary@gmail.com>
|
||||||
Zahoor Mohamed <zahoor@zahoor.in>
|
Zahoor Mohamed <zahoor@zahoor.in>
|
||||||
|
Zak Cole <zak@beattiecole.com>
|
||||||
|
zer0to0ne <36526113+zer0to0ne@users.noreply.github.com>
|
||||||
|
Zhenguo Niu <Niu.ZGlinux@gmail.com>
|
||||||
Zoe Nolan <github@zoenolan.org>
|
Zoe Nolan <github@zoenolan.org>
|
||||||
Zsolt Felföldi <zsfelfoldi@gmail.com>
|
Zsolt Felföldi <zsfelfoldi@gmail.com>
|
||||||
am2rican5 <am2rican5@gmail.com>
|
Łukasz Kurowski <crackcomm@users.noreply.github.com>
|
||||||
ayeowch <ayeowch@gmail.com>
|
|
||||||
b00ris <b00ris@mail.ru>
|
|
||||||
bailantaotao <Edwin@maicoin.com>
|
|
||||||
baizhenxuan <nkbai@163.com>
|
|
||||||
bloonfield <bloonfield@163.com>
|
|
||||||
changhong <changhong.yu@shanbay.com>
|
|
||||||
evgk <evgeniy.kamyshev@gmail.com>
|
|
||||||
ferhat elmas <elmas.ferhat@gmail.com>
|
|
||||||
holisticode <holistic.computing@gmail.com>
|
|
||||||
jtakalai <juuso.takalainen@streamr.com>
|
|
||||||
ken10100147 <sunhongping@kanjian.com>
|
|
||||||
ligi <ligi@ligi.de>
|
|
||||||
mark.lin <mark@maicoin.com>
|
|
||||||
necaremus <necaremus@gmail.com>
|
|
||||||
njupt-moon <1015041018@njupt.edu.cn>
|
|
||||||
nkbai <nkbai@163.com>
|
|
||||||
rhaps107 <dod-source@yandex.ru>
|
|
||||||
slumber1122 <slumber1122@gmail.com>
|
|
||||||
sunxiaojun2014 <sunxiaojun-xy@360.cn>
|
|
||||||
terasum <terasum@163.com>
|
|
||||||
tsarpaul <Litvakpol@012.net.il>
|
|
||||||
xiekeyang <xiekeyang@users.noreply.github.com>
|
|
||||||
yoza <yoza.is12s@gmail.com>
|
|
||||||
ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
|
ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
|
||||||
Максим Чусовлянов <mchusovlianov@gmail.com>
|
Максим Чусовлянов <mchusovlianov@gmail.com>
|
||||||
Ralph Caraveo <deckarep@gmail.com>
|
大彬 <hz_stb@163.com>
|
||||||
|
贺鹏飞 <hpf@hackerful.cn>
|
||||||
|
유용환 <33824408+eric-yoo@users.noreply.github.com>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Build Geth in a stock Go builder container
|
# Build Geth in a stock Go builder container
|
||||||
FROM golang:1.11-alpine as builder
|
FROM golang:1.13-alpine as builder
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc musl-dev linux-headers
|
RUN apk add --no-cache make gcc musl-dev linux-headers git
|
||||||
|
|
||||||
ADD . /go-ethereum
|
ADD . /go-ethereum
|
||||||
RUN cd /go-ethereum && make geth
|
RUN cd /go-ethereum && make geth
|
||||||
@@ -12,5 +12,5 @@ FROM alpine:latest
|
|||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
||||||
|
|
||||||
EXPOSE 8545 8546 30303 30303/udp
|
EXPOSE 8545 8546 8547 30303 30303/udp
|
||||||
ENTRYPOINT ["geth"]
|
ENTRYPOINT ["geth"]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Build Geth in a stock Go builder container
|
# Build Geth in a stock Go builder container
|
||||||
FROM golang:1.11-alpine as builder
|
FROM golang:1.13-alpine as builder
|
||||||
|
|
||||||
RUN apk add --no-cache make gcc musl-dev linux-headers
|
RUN apk add --no-cache make gcc musl-dev linux-headers git
|
||||||
|
|
||||||
ADD . /go-ethereum
|
ADD . /go-ethereum
|
||||||
RUN cd /go-ethereum && make all
|
RUN cd /go-ethereum && make all
|
||||||
@@ -12,4 +12,4 @@ FROM alpine:latest
|
|||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
|
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
|
||||||
|
|
||||||
EXPOSE 8545 8546 30303 30303/udp
|
EXPOSE 8545 8546 8547 30303 30303/udp
|
||||||
|
|||||||
12
Makefile
12
Makefile
@@ -2,13 +2,13 @@
|
|||||||
# with Go source code. If you know what GOPATH is then you probably
|
# with Go source code. If you know what GOPATH is then you probably
|
||||||
# don't need to bother with make.
|
# don't need to bother with make.
|
||||||
|
|
||||||
.PHONY: geth android ios geth-cross swarm evm all test clean
|
.PHONY: geth android ios geth-cross evm all test clean
|
||||||
.PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
|
.PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
|
||||||
.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
|
.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
|
||||||
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
|
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
|
||||||
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
|
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
|
||||||
|
|
||||||
GOBIN = $(shell pwd)/build/bin
|
GOBIN = ./build/bin
|
||||||
GO ?= latest
|
GO ?= latest
|
||||||
|
|
||||||
geth:
|
geth:
|
||||||
@@ -16,11 +16,6 @@ geth:
|
|||||||
@echo "Done building."
|
@echo "Done building."
|
||||||
@echo "Run \"$(GOBIN)/geth\" to launch geth."
|
@echo "Run \"$(GOBIN)/geth\" to launch geth."
|
||||||
|
|
||||||
swarm:
|
|
||||||
build/env.sh go run build/ci.go install ./cmd/swarm
|
|
||||||
@echo "Done building."
|
|
||||||
@echo "Run \"$(GOBIN)/swarm\" to launch swarm."
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
build/env.sh go run build/ci.go install
|
build/env.sh go run build/ci.go install
|
||||||
|
|
||||||
@@ -57,9 +52,6 @@ devtools:
|
|||||||
@type "solc" 2> /dev/null || echo 'Please install solc'
|
@type "solc" 2> /dev/null || echo 'Please install solc'
|
||||||
@type "protoc" 2> /dev/null || echo 'Please install protoc'
|
@type "protoc" 2> /dev/null || echo 'Please install protoc'
|
||||||
|
|
||||||
swarm-devtools:
|
|
||||||
env GOBIN= go install ./cmd/swarm/mimegen
|
|
||||||
|
|
||||||
# Cross Compilation Targets (xgo)
|
# Cross Compilation Targets (xgo)
|
||||||
|
|
||||||
geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
|
geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
|
||||||
|
|||||||
361
README.md
361
README.md
@@ -1,6 +1,6 @@
|
|||||||
## Go Ethereum
|
## Go Ethereum
|
||||||
|
|
||||||
Official golang implementation of the Ethereum protocol.
|
Official Golang implementation of the Ethereum protocol.
|
||||||
|
|
||||||
[](https://travis-ci.org/ethereum/go-ethereum)
|
[](https://travis-ci.org/ethereum/go-ethereum)
|
||||||
[](https://discord.gg/nthXNEv)
|
[](https://discord.gg/nthXNEv)
|
||||||
|
|
||||||
Automated builds are available for stable releases and the unstable master branch.
|
Automated builds are available for stable releases and the unstable master branch. Binary
|
||||||
Binary archives are published at https://geth.ethereum.org/downloads/.
|
archives are published at https://geth.ethereum.org/downloads/.
|
||||||
|
|
||||||
## Building the source
|
## Building the source
|
||||||
|
|
||||||
For prerequisites and detailed build instructions please read the
|
For prerequisites and detailed build instructions please read the [Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum) on the wiki.
|
||||||
[Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)
|
|
||||||
on the wiki.
|
|
||||||
|
|
||||||
Building geth requires both a Go (version 1.9 or later) and a C compiler.
|
Building `geth` requires both a Go (version 1.10 or later) and a C compiler. You can install
|
||||||
You can install them using your favourite package manager.
|
them using your favourite package manager. Once the dependencies are installed, run
|
||||||
Once the dependencies are installed, run
|
|
||||||
|
|
||||||
make geth
|
```shell
|
||||||
|
make geth
|
||||||
|
```
|
||||||
|
|
||||||
or, to build the full suite of utilities:
|
or, to build the full suite of utilities:
|
||||||
|
|
||||||
make all
|
```shell
|
||||||
|
make all
|
||||||
|
```
|
||||||
|
|
||||||
## Executables
|
## Executables
|
||||||
|
|
||||||
The go-ethereum project comes with several wrappers/executables found in the `cmd` directory.
|
The go-ethereum project comes with several wrappers/executables found in the `cmd`
|
||||||
|
directory.
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
|:----------:|-------------|
|
| :-----------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) for command line options. |
|
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) for command line options. |
|
||||||
| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) with expanded functionality if the contract bytecode is also available. However it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. |
|
| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. |
|
||||||
| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
|
| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
|
||||||
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`). |
|
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`). |
|
||||||
| `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. |
|
| `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. |
|
||||||
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
|
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
|
||||||
| `swarm` | Swarm daemon and tools. This is the entrypoint for the Swarm network. `swarm --help` for command line options and subcommands. See [Swarm README](https://github.com/ethereum/go-ethereum/tree/master/swarm) for more information. |
|
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
|
||||||
| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
|
|
||||||
|
|
||||||
## Running geth
|
## Running `geth`
|
||||||
|
|
||||||
Going through all the possible command line flags is out of scope here (please consult our
|
Going through all the possible command line flags is out of scope here (please consult our
|
||||||
[CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)), but we've
|
[CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)),
|
||||||
enumerated a few common parameter combos to get you up to speed quickly on how you can run your
|
but we've enumerated a few common parameter combos to get you up to speed quickly
|
||||||
own Geth instance.
|
on how you can run your own `geth` instance.
|
||||||
|
|
||||||
### Full node on the main Ethereum network
|
### Full node on the main Ethereum network
|
||||||
|
|
||||||
By far the most common scenario is people wanting to simply interact with the Ethereum network:
|
By far the most common scenario is people wanting to simply interact with the Ethereum
|
||||||
create accounts; transfer funds; deploy and interact with contracts. For this particular use-case
|
network: create accounts; transfer funds; deploy and interact with contracts. For this
|
||||||
the user doesn't care about years-old historical data, so we can fast-sync quickly to the current
|
particular use-case the user doesn't care about years-old historical data, so we can
|
||||||
state of the network. To do so:
|
fast-sync quickly to the current state of the network. To do so:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth console
|
$ geth console
|
||||||
```
|
```
|
||||||
|
|
||||||
This command will:
|
This command will:
|
||||||
|
* Start `geth` in fast sync mode (default, can be changed with the `--syncmode` flag),
|
||||||
* Start geth in fast sync mode (default, can be changed with the `--syncmode` flag), causing it to
|
causing it to download more data in exchange for avoiding processing the entire history
|
||||||
download more data in exchange for avoiding processing the entire history of the Ethereum network,
|
of the Ethereum network, which is very CPU intensive.
|
||||||
which is very CPU intensive.
|
* Start up `geth`'s built-in interactive [JavaScript console](https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console),
|
||||||
* Start up Geth's built-in interactive [JavaScript console](https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console),
|
|
||||||
(via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API)
|
(via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API)
|
||||||
as well as Geth's own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs).
|
as well as `geth`'s own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs).
|
||||||
This tool is optional and if you leave it out you can always attach to an already running Geth instance
|
This tool is optional and if you leave it out you can always attach to an already running
|
||||||
with `geth attach`.
|
`geth` instance with `geth attach`.
|
||||||
|
|
||||||
### Full node on the Ethereum test network
|
### A Full node on the Ethereum test network
|
||||||
|
|
||||||
Transitioning towards developers, if you'd like to play around with creating Ethereum contracts, you
|
Transitioning towards developers, if you'd like to play around with creating Ethereum
|
||||||
almost certainly would like to do that without any real money involved until you get the hang of the
|
contracts, you almost certainly would like to do that without any real money involved until
|
||||||
entire system. In other words, instead of attaching to the main network, you want to join the **test**
|
you get the hang of the entire system. In other words, instead of attaching to the main
|
||||||
network with your node, which is fully equivalent to the main network, but with play-Ether only.
|
network, you want to join the **test** network with your node, which is fully equivalent to
|
||||||
|
the main network, but with play-Ether only.
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth --testnet console
|
$ geth --testnet console
|
||||||
```
|
```
|
||||||
|
|
||||||
The `console` subcommand have the exact same meaning as above and they are equally useful on the
|
The `console` subcommand has the exact same meaning as above and they are equally
|
||||||
testnet too. Please see above for their explanations if you've skipped to here.
|
useful on the testnet too. Please see above for their explanations if you've skipped here.
|
||||||
|
|
||||||
Specifying the `--testnet` flag however will reconfigure your Geth instance a bit:
|
Specifying the `--testnet` flag, however, will reconfigure your `geth` instance a bit:
|
||||||
|
|
||||||
* Instead of using the default data directory (`~/.ethereum` on Linux for example), Geth will nest
|
* Instead of using the default data directory (`~/.ethereum` on Linux for example), `geth`
|
||||||
itself one level deeper into a `testnet` subfolder (`~/.ethereum/testnet` on Linux). Note, on OSX
|
will nest itself one level deeper into a `testnet` subfolder (`~/.ethereum/testnet` on
|
||||||
and Linux this also means that attaching to a running testnet node requires the use of a custom
|
Linux). Note, on OSX and Linux this also means that attaching to a running testnet node
|
||||||
endpoint since `geth attach` will try to attach to a production node endpoint by default. E.g.
|
requires the use of a custom endpoint since `geth attach` will try to attach to a
|
||||||
`geth attach <datadir>/testnet/geth.ipc`. Windows users are not affected by this.
|
production node endpoint by default. E.g.
|
||||||
* Instead of connecting the main Ethereum network, the client will connect to the test network,
|
`geth attach <datadir>/testnet/geth.ipc`. Windows users are not affected by
|
||||||
which uses different P2P bootnodes, different network IDs and genesis states.
|
this.
|
||||||
|
* Instead of connecting the main Ethereum network, the client will connect to the test
|
||||||
*Note: Although there are some internal protective measures to prevent transactions from crossing
|
network, which uses different P2P bootnodes, different network IDs and genesis states.
|
||||||
over between the main network and test network, you should make sure to always use separate accounts
|
|
||||||
for play-money and real-money. Unless you manually move accounts, Geth will by default correctly
|
*Note: Although there are some internal protective measures to prevent transactions from
|
||||||
separate the two networks and will not make any accounts available between them.*
|
crossing over between the main network and test network, you should make sure to always
|
||||||
|
use separate accounts for play-money and real-money. Unless you manually move
|
||||||
|
accounts, `geth` will by default correctly separate the two networks and will not make any
|
||||||
|
accounts available between them.*
|
||||||
|
|
||||||
### Full node on the Rinkeby test network
|
### Full node on the Rinkeby test network
|
||||||
|
|
||||||
The above test network is a cross client one based on the ethash proof-of-work consensus algorithm. As such, it has certain extra overhead and is more susceptible to reorganization attacks due to the network's low difficulty / security. Go Ethereum also supports connecting to a proof-of-authority based test network called [*Rinkeby*](https://www.rinkeby.io) (operated by members of the community). This network is lighter, more secure, but is only supported by go-ethereum.
|
The above test network is a cross-client one based on the ethash proof-of-work consensus
|
||||||
|
algorithm. As such, it has certain extra overhead and is more susceptible to reorganization
|
||||||
|
attacks due to the network's low difficulty/security. Go Ethereum also supports connecting
|
||||||
|
to a proof-of-authority based test network called [*Rinkeby*](https://www.rinkeby.io)
|
||||||
|
(operated by members of the community). This network is lighter, more secure, but is only
|
||||||
|
supported by go-ethereum.
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth --rinkeby console
|
$ geth --rinkeby console
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
As an alternative to passing the numerous flags to the `geth` binary, you can also pass a configuration file via:
|
As an alternative to passing the numerous flags to the `geth` binary, you can also pass a
|
||||||
|
configuration file via:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth --config /path/to/your_config.toml
|
$ geth --config /path/to/your_config.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
To get an idea how the file should look like you can use the `dumpconfig` subcommand to export your existing configuration:
|
To get an idea how the file should look like you can use the `dumpconfig` subcommand to
|
||||||
|
export your existing configuration:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth --your-favourite-flags dumpconfig
|
$ geth --your-favourite-flags dumpconfig
|
||||||
```
|
```
|
||||||
|
|
||||||
*Note: This works only with geth v1.6.0 and above.*
|
*Note: This works only with `geth` v1.6.0 and above.*
|
||||||
|
|
||||||
#### Docker quick start
|
#### Docker quick start
|
||||||
|
|
||||||
One of the quickest ways to get Ethereum up and running on your machine is by using Docker:
|
One of the quickest ways to get Ethereum up and running on your machine is by using
|
||||||
|
Docker:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \
|
docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \
|
||||||
-p 8545:8545 -p 30303:30303 \
|
-p 8545:8545 -p 30303:30303 \
|
||||||
ethereum/client-go
|
ethereum/client-go
|
||||||
```
|
```
|
||||||
|
|
||||||
This will start geth in fast-sync mode with a DB memory allowance of 1GB just as the above command does. It will also create a persistent volume in your home directory for saving your blockchain as well as map the default ports. There is also an `alpine` tag available for a slim version of the image.
|
This will start `geth` in fast-sync mode with a DB memory allowance of 1GB just as the
|
||||||
|
above command does. It will also create a persistent volume in your home directory for
|
||||||
|
saving your blockchain as well as map the default ports. There is also an `alpine` tag
|
||||||
|
available for a slim version of the image.
|
||||||
|
|
||||||
Do not forget `--rpcaddr 0.0.0.0`, if you want to access RPC from other containers and/or hosts. By default, `geth` binds to the local interface and RPC endpoints is not accessible from the outside.
|
Do not forget `--rpcaddr 0.0.0.0`, if you want to access RPC from other containers
|
||||||
|
and/or hosts. By default, `geth` binds to the local interface and RPC endpoints is not
|
||||||
|
accessible from the outside.
|
||||||
|
|
||||||
### Programatically interfacing Geth nodes
|
### Programmatically interfacing `geth` nodes
|
||||||
|
|
||||||
As a developer, sooner rather than later you'll want to start interacting with Geth and the Ethereum
|
As a developer, sooner rather than later you'll want to start interacting with `geth` and the
|
||||||
network via your own programs and not manually through the console. To aid this, Geth has built-in
|
Ethereum network via your own programs and not manually through the console. To aid
|
||||||
support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC) and
|
this, `geth` has built-in support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC)
|
||||||
[Geth specific APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)). These can be
|
and [`geth` specific APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)).
|
||||||
exposed via HTTP, WebSockets and IPC (unix sockets on unix based platforms, and named pipes on Windows).
|
These can be exposed via HTTP, WebSockets and IPC (UNIX sockets on UNIX based
|
||||||
|
platforms, and named pipes on Windows).
|
||||||
|
|
||||||
The IPC interface is enabled by default and exposes all the APIs supported by Geth, whereas the HTTP
|
The IPC interface is enabled by default and exposes all the APIs supported by `geth`,
|
||||||
and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons.
|
whereas the HTTP and WS interfaces need to manually be enabled and only expose a
|
||||||
These can be turned on/off and configured as you'd expect.
|
subset of APIs due to security reasons. These can be turned on/off and configured as
|
||||||
|
you'd expect.
|
||||||
|
|
||||||
HTTP based JSON-RPC API options:
|
HTTP based JSON-RPC API options:
|
||||||
|
|
||||||
* `--rpc` Enable the HTTP-RPC server
|
* `--rpc` Enable the HTTP-RPC server
|
||||||
* `--rpcaddr` HTTP-RPC server listening interface (default: "localhost")
|
* `--rpcaddr` HTTP-RPC server listening interface (default: `localhost`)
|
||||||
* `--rpcport` HTTP-RPC server listening port (default: 8545)
|
* `--rpcport` HTTP-RPC server listening port (default: `8545`)
|
||||||
* `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3")
|
* `--rpcapi` API's offered over the HTTP-RPC interface (default: `eth,net,web3`)
|
||||||
* `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
|
* `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
|
||||||
* `--ws` Enable the WS-RPC server
|
* `--ws` Enable the WS-RPC server
|
||||||
* `--wsaddr` WS-RPC server listening interface (default: "localhost")
|
* `--wsaddr` WS-RPC server listening interface (default: `localhost`)
|
||||||
* `--wsport` WS-RPC server listening port (default: 8546)
|
* `--wsport` WS-RPC server listening port (default: `8546`)
|
||||||
* `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3")
|
* `--wsapi` API's offered over the WS-RPC interface (default: `eth,net,web3`)
|
||||||
* `--wsorigins` Origins from which to accept websockets requests
|
* `--wsorigins` Origins from which to accept websockets requests
|
||||||
* `--ipcdisable` Disable the IPC-RPC server
|
* `--ipcdisable` Disable the IPC-RPC server
|
||||||
* `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3")
|
* `--ipcapi` API's offered over the IPC-RPC interface (default: `admin,debug,eth,miner,net,personal,shh,txpool,web3`)
|
||||||
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
||||||
|
|
||||||
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect
|
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to
|
||||||
via HTTP, WS or IPC to a Geth node configured with the above flags and you'll need to speak [JSON-RPC](https://www.jsonrpc.org/specification)
|
connect via HTTP, WS or IPC to a `geth` node configured with the above flags and you'll
|
||||||
on all transports. You can reuse the same connection for multiple requests!
|
need to speak [JSON-RPC](https://www.jsonrpc.org/specification) on all transports. You
|
||||||
|
can reuse the same connection for multiple requests!
|
||||||
|
|
||||||
**Note: Please understand the security implications of opening up an HTTP/WS based transport before
|
**Note: Please understand the security implications of opening up an HTTP/WS based
|
||||||
doing so! Hackers on the internet are actively trying to subvert Ethereum nodes with exposed APIs!
|
transport before doing so! Hackers on the internet are actively trying to subvert
|
||||||
Further, all browser tabs can access locally running webservers, so malicious webpages could try to
|
Ethereum nodes with exposed APIs! Further, all browser tabs can access locally
|
||||||
subvert locally available APIs!**
|
running web servers, so malicious web pages could try to subvert locally available
|
||||||
|
APIs!**
|
||||||
|
|
||||||
### Operating a private network
|
### Operating a private network
|
||||||
|
|
||||||
Maintaining your own private network is more involved as a lot of configurations taken for granted in
|
Maintaining your own private network is more involved as a lot of configurations taken for
|
||||||
the official networks need to be manually set up.
|
granted in the official networks need to be manually set up.
|
||||||
|
|
||||||
#### Defining the private genesis state
|
#### Defining the private genesis state
|
||||||
|
|
||||||
First, you'll need to create the genesis state of your networks, which all nodes need to be aware of
|
First, you'll need to create the genesis state of your networks, which all nodes need to be
|
||||||
and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`):
|
aware of and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`):
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"chainId": 0,
|
"chainId": <arbitrary positive integer>,
|
||||||
"homesteadBlock": 0,
|
"homesteadBlock": 0,
|
||||||
"eip155Block": 0,
|
"eip150Block": 0,
|
||||||
"eip158Block": 0
|
"eip155Block": 0,
|
||||||
},
|
"eip158Block": 0,
|
||||||
"alloc" : {},
|
"byzantiumBlock": 0,
|
||||||
"coinbase" : "0x0000000000000000000000000000000000000000",
|
"constantinopleBlock": 0,
|
||||||
"difficulty" : "0x20000",
|
"petersburgBlock": 0
|
||||||
"extraData" : "",
|
},
|
||||||
"gasLimit" : "0x2fefd8",
|
"alloc": {},
|
||||||
"nonce" : "0x0000000000000042",
|
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||||
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"difficulty": "0x20000",
|
||||||
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
|
"extraData": "",
|
||||||
"timestamp" : "0x00"
|
"gasLimit": "0x2fefd8",
|
||||||
|
"nonce": "0x0000000000000042",
|
||||||
|
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
|
"timestamp": "0x00"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The above fields should be fine for most purposes, although we'd recommend changing the `nonce` to
|
The above fields should be fine for most purposes, although we'd recommend changing
|
||||||
some random value so you prevent unknown remote nodes from being able to connect to you. If you'd
|
the `nonce` to some random value so you prevent unknown remote nodes from being able
|
||||||
like to pre-fund some accounts for easier testing, you can populate the `alloc` field with account
|
to connect to you. If you'd like to pre-fund some accounts for easier testing, create
|
||||||
configs:
|
the accounts and populate the `alloc` field with their addresses.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"alloc": {
|
"alloc": {
|
||||||
"0x0000000000000000000000000000000000000001": {"balance": "111111111"},
|
"0x0000000000000000000000000000000000000001": {
|
||||||
"0x0000000000000000000000000000000000000002": {"balance": "222222222"}
|
"balance": "111111111"
|
||||||
|
},
|
||||||
|
"0x0000000000000000000000000000000000000002": {
|
||||||
|
"balance": "222222222"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
With the genesis state defined in the above JSON file, you'll need to initialize **every** Geth node
|
With the genesis state defined in the above JSON file, you'll need to initialize **every**
|
||||||
with it prior to starting it up to ensure all blockchain parameters are correctly set:
|
`geth` node with it prior to starting it up to ensure all blockchain parameters are correctly
|
||||||
|
set:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth init path/to/genesis.json
|
$ geth init path/to/genesis.json
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Creating the rendezvous point
|
#### Creating the rendezvous point
|
||||||
|
|
||||||
With all nodes that you want to run initialized to the desired genesis state, you'll need to start a
|
With all nodes that you want to run initialized to the desired genesis state, you'll need to
|
||||||
bootstrap node that others can use to find each other in your network and/or over the internet. The
|
start a bootstrap node that others can use to find each other in your network and/or over
|
||||||
clean way is to configure and run a dedicated bootnode:
|
the internet. The clean way is to configure and run a dedicated bootnode:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ bootnode --genkey=boot.key
|
$ bootnode --genkey=boot.key
|
||||||
$ bootnode --nodekey=boot.key
|
$ bootnode --nodekey=boot.key
|
||||||
```
|
```
|
||||||
|
|
||||||
With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format)
|
With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format)
|
||||||
that other nodes can use to connect to it and exchange peer information. Make sure to replace the
|
that other nodes can use to connect to it and exchange peer information. Make sure to
|
||||||
displayed IP address information (most probably `[::]`) with your externally accessible IP to get the
|
replace the displayed IP address information (most probably `[::]`) with your externally
|
||||||
actual `enode` URL.
|
accessible IP to get the actual `enode` URL.
|
||||||
|
|
||||||
*Note: You could also use a full fledged Geth node as a bootnode, but it's the less recommended way.*
|
*Note: You could also use a full-fledged `geth` node as a bootnode, but it's the less
|
||||||
|
recommended way.*
|
||||||
|
|
||||||
#### Starting up your member nodes
|
#### Starting up your member nodes
|
||||||
|
|
||||||
With the bootnode operational and externally reachable (you can try `telnet <ip> <port>` to ensure
|
With the bootnode operational and externally reachable (you can try
|
||||||
it's indeed reachable), start every subsequent Geth node pointed to the bootnode for peer discovery
|
`telnet <ip> <port>` to ensure it's indeed reachable), start every subsequent `geth`
|
||||||
via the `--bootnodes` flag. It will probably also be desirable to keep the data directory of your
|
node pointed to the bootnode for peer discovery via the `--bootnodes` flag. It will
|
||||||
private network separated, so do also specify a custom `--datadir` flag.
|
probably also be desirable to keep the data directory of your private network separated, so
|
||||||
|
do also specify a custom `--datadir` flag.
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above>
|
$ geth --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above>
|
||||||
```
|
```
|
||||||
|
|
||||||
*Note: Since your network will be completely cut off from the main and test networks, you'll also
|
*Note: Since your network will be completely cut off from the main and test networks, you'll
|
||||||
need to configure a miner to process transactions and create new blocks for you.*
|
also need to configure a miner to process transactions and create new blocks for you.*
|
||||||
|
|
||||||
#### Running a private miner
|
#### Running a private miner
|
||||||
|
|
||||||
Mining on the public Ethereum network is a complex task as it's only feasible using GPUs, requiring
|
Mining on the public Ethereum network is a complex task as it's only feasible using GPUs,
|
||||||
an OpenCL or CUDA enabled `ethminer` instance. For information on such a setup, please consult the
|
requiring an OpenCL or CUDA enabled `ethminer` instance. For information on such a
|
||||||
[EtherMining subreddit](https://www.reddit.com/r/EtherMining/) and the [Genoil miner](https://github.com/Genoil/cpp-ethereum)
|
setup, please consult the [EtherMining subreddit](https://www.reddit.com/r/EtherMining/)
|
||||||
repository.
|
and the [Genoil miner](https://github.com/Genoil/cpp-ethereum) repository.
|
||||||
|
|
||||||
In a private network setting however, a single CPU miner instance is more than enough for practical
|
In a private network setting, however a single CPU miner instance is more than enough for
|
||||||
purposes as it can produce a stable stream of blocks at the correct intervals without needing heavy
|
practical purposes as it can produce a stable stream of blocks at the correct intervals
|
||||||
resources (consider running on a single thread, no need for multiple ones either). To start a Geth
|
without needing heavy resources (consider running on a single thread, no need for multiple
|
||||||
instance for mining, run it with all your usual flags, extended by:
|
ones either). To start a `geth` instance for mining, run it with all your usual flags, extended
|
||||||
|
by:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ geth <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
|
$ geth <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
|
||||||
```
|
```
|
||||||
|
|
||||||
Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to
|
Which will start mining blocks and transactions on a single CPU thread, crediting all
|
||||||
the account specified by `--etherbase`. You can further tune the mining by changing the default gas
|
proceedings to the account specified by `--etherbase`. You can further tune the mining
|
||||||
limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).
|
by changing the default gas limit blocks converge to (`--targetgaslimit`) and the price
|
||||||
|
transactions are accepted at (`--gasprice`).
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
Thank you for considering to help out with the source code! We welcome contributions from
|
Thank you for considering to help out with the source code! We welcome contributions
|
||||||
anyone on the internet, and are grateful for even the smallest of fixes!
|
from anyone on the internet, and are grateful for even the smallest of fixes!
|
||||||
|
|
||||||
If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request
|
If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request
|
||||||
for the maintainers to review and merge into the main code base. If you wish to submit more
|
for the maintainers to review and merge into the main code base. If you wish to submit
|
||||||
complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/ethereum/go-ethereum)
|
more complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/ethereum/go-ethereum)
|
||||||
to ensure those changes are in line with the general philosophy of the project and/or get some
|
to ensure those changes are in line with the general philosophy of the project and/or get
|
||||||
early feedback which can make both your efforts much lighter as well as our review and merge
|
some early feedback which can make both your efforts much lighter as well as our review
|
||||||
procedures quick and simple.
|
and merge procedures quick and simple.
|
||||||
|
|
||||||
Please make sure your contributions adhere to our coding guidelines:
|
Please make sure your contributions adhere to our coding guidelines:
|
||||||
|
|
||||||
* Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
|
* Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting)
|
||||||
* Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
|
guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
|
||||||
|
* Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary)
|
||||||
|
guidelines.
|
||||||
* Pull requests need to be based on and opened against the `master` branch.
|
* Pull requests need to be based on and opened against the `master` branch.
|
||||||
* Commit messages should be prefixed with the package(s) they modify.
|
* Commit messages should be prefixed with the package(s) they modify.
|
||||||
* E.g. "eth, rpc: make trace configs optional"
|
* E.g. "eth, rpc: make trace configs optional"
|
||||||
|
|
||||||
Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
|
Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
|
||||||
for more details on configuring your environment, managing project dependencies and testing procedures.
|
for more details on configuring your environment, managing project dependencies, and
|
||||||
|
testing procedures.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the
|
The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the
|
||||||
[GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also
|
[GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html),
|
||||||
included in our repository in the `COPYING.LESSER` file.
|
also included in our repository in the `COPYING.LESSER` file.
|
||||||
|
|
||||||
The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the
|
The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the
|
||||||
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included
|
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also
|
||||||
in our repository in the `COPYING` file.
|
included in our repository in the `COPYING` file.
|
||||||
|
|||||||
120
SECURITY.md
Normal file
120
SECURITY.md
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Please see Releases. We recommend to use the most recent released version.
|
||||||
|
|
||||||
|
## Audit reports
|
||||||
|
|
||||||
|
Audit reports are published in the `docs` folder: https://github.com/ethereum/go-ethereum/tree/master/docs/audits
|
||||||
|
|
||||||
|
|
||||||
|
| Scope | Date | Report Link |
|
||||||
|
| ------- | ------- | ----------- |
|
||||||
|
| `geth` | 20170425 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2017-04-25_Geth-audit_Truesec.pdf) |
|
||||||
|
| `clef` | 20180914 | [pdf](https://github.com/ethereum/go-ethereum/blob/master/docs/audits/2018-09-14_Clef-audit_NCC.pdf) |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
**Please do not file a public ticket** mentioning the vulnerability.
|
||||||
|
|
||||||
|
To find out how to disclose a vulnerability in Ethereum visit [https://bounty.ethereum.org](https://bounty.ethereum.org) or email bounty@ethereum.org.
|
||||||
|
|
||||||
|
The following key may be used to communicate sensitive information to developers.
|
||||||
|
|
||||||
|
Fingerprint: `AE96 ED96 9E47 9B00 84F3 E17F E88D 3334 FA5F 6A0A`
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1
|
||||||
|
|
||||||
|
mQINBFgl3tgBEAC8A1tUBkD9YV+eLrOmtgy+/JS/H9RoZvkg3K1WZ8IYfj6iIRaY
|
||||||
|
neAk3Bp182GUPVz/zhKr2g0tMXIScDR3EnaDsY+Qg+JqQl8NOG+Cikr1nnkG2on9
|
||||||
|
L8c8yiqry1ZTCmYMqCa2acTFqnyuXJ482aZNtB4QG2BpzfhW4k8YThpegk/EoRUi
|
||||||
|
m+y7buJDtoNf7YILlhDQXN8qlHB02DWOVUihph9tUIFsPK6BvTr9SIr/eG6j6k0b
|
||||||
|
fUo9pexOn7LS4SojoJmsm/5dp6AoKlac48cZU5zwR9AYcq/nvkrfmf2WkObg/xRd
|
||||||
|
EvKZzn05jRopmAIwmoC3CiLmqCHPmT5a29vEob/yPFE335k+ujjZCPOu7OwjzDk7
|
||||||
|
M0zMSfnNfDq8bXh16nn+ueBxJ0NzgD1oC6c2PhM+XRQCXChoyI8vbfp4dGvCvYqv
|
||||||
|
QAE1bWjqnumZ/7vUPgZN6gDfiAzG2mUxC2SeFBhacgzDvtQls+uuvm+FnQOUgg2H
|
||||||
|
h8x2zgoZ7kqV29wjaUPFREuew7e+Th5BxielnzOfVycVXeSuvvIn6cd3g/s8mX1c
|
||||||
|
2kLSXJR7+KdWDrIrR5Az0kwAqFZt6B6QTlDrPswu3mxsm5TzMbny0PsbL/HBM+GZ
|
||||||
|
EZCjMXxB8bqV2eSaktjnSlUNX1VXxyOxXA+ZG2jwpr51egi57riVRXokrQARAQAB
|
||||||
|
tDlFdGhlcmV1bSBGb3VuZGF0aW9uIFNlY3VyaXR5IFRlYW0gPHNlY3VyaXR5QGV0
|
||||||
|
aGVyZXVtLm9yZz6JAj4EEwECACgCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheA
|
||||||
|
BQJaCWH6BQkFo2BYAAoJEOiNMzT6X2oK+DEP/3H6dxkm0hvHZKoHLVuuxcu3EHYo
|
||||||
|
k5sd3MMWPrZSN8qzZnY7ayEDMxnarWOizc+2jfOxfJlzX/g8lR1/fsHdWPFPhPoV
|
||||||
|
Qk8ygrHn1H8U8+rpw/U03BqmqHpYCDzJ+CIis9UWROniqXw1nuqu/FtWOsdWxNKh
|
||||||
|
jUo6k/0EsaXsxRPzgJv7fEUcVcQ7as/C3x9sy3muc2gvgA4/BKoGPb1/U0GuA8lV
|
||||||
|
fDIDshAggmnSUAg+TuYSAAdoFQ1sKwFMPigcLJF2eyKuK3iUyixJrec/c4LSf3wA
|
||||||
|
cGghbeuqI8INP0Y2zvXDQN2cByxsFAuoZG+m0cyKGaDH2MVUvOKKYqn/03qvrf15
|
||||||
|
AWAsW0l0yQwOTCo3FbsNzemClm5Bj/xH0E4XuwXwChcMCMOWJrFoxyvCEI+keoQc
|
||||||
|
c08/a8/MtS7vBAABXwOziSmm6CNqmzpWrh/fDrjlJlba9U3MxzvqU3IFlTdMratv
|
||||||
|
6V+SgX+L25lCzW4NxxUavoB8fAlvo8lxpHKo24FP+RcLQ8XqkU3RiUsgRjQRFOqQ
|
||||||
|
TaJcsp8mimmiYyf24mNu6b48pi+a5c/eQR9w59emeEUZqsJU+nqv8BWIIp7o4Agh
|
||||||
|
NYnKjkhPlY5e1fLVfAHIADZFynWwRPkPMJSrBiP5EtcOFxQGHGjRxU/KjXkvE0hV
|
||||||
|
xYb1PB8pWMTu/beeiQI+BBMBAgAoBQJYJd7YAhsDBQkB4TOABgsJCAcDAgYVCAIJ
|
||||||
|
CgsEFgIDAQIeAQIXgAAKCRDojTM0+l9qCplDD/9IZ2i+m1cnqQKtiyHbyFGx32oL
|
||||||
|
fzqPylX2bOG5DPsSTorSUdJMGVfT04oVxXc4S/2DVnNvi7RAbSiLapCWSplgtBOj
|
||||||
|
j1xlblOoXxT3m7s1XHGCX5tENxI9fVSSPVKJn+fQaWpPB2MhBA+1lUI6GJ+11T7K
|
||||||
|
J8LrP/fiw1/nOb7rW61HW44Gtyox23sA/d1+DsFVaF8hxJlNj5coPKr8xWzQ8pQl
|
||||||
|
juzdjHDukjevuw4rRmRq9vozvj9keEU9XJ5dldyEVXFmdDk7KT0p0Rla9nxYhzf/
|
||||||
|
r/Bv8Bzy0HCWRb2D31BjXXGG05oVnYmNGxGFxYja4MwgrMmne3ilEVjfUJsapsqi
|
||||||
|
w41BAyQgIdfREulYN7ahsF5PrjVAqBd9IGtE8ULelF2SQxEBQBngEkP0ahP6tRAL
|
||||||
|
i7/CBjPKOyKijtqVny7qrGOnU2ygcA88/WDibexDhrjz0Gx8WmErU7rIWZiZ5u4Y
|
||||||
|
vJYVRo0+6rBCXRPeSJfiP5h1p17Anr2l42boAYslfcrzquB8MHtrNcyn650OLtHG
|
||||||
|
nbxgIdniKrpuzGN6Opw+O2id2JhD1/1p4SOemwAmthplr1MIyOHNP3q93rEj2J7h
|
||||||
|
5zPS/AJuKkMDFUpslPNLQjCOwPXtdzL7/kUZGBSyez1T3TaW1uY6l9XaJJRaSn+v
|
||||||
|
1zPgfp4GJ3lPs4AlAbQ0RXRoZXJldW0gRm91bmRhdGlvbiBCdWcgQm91bnR5IDxi
|
||||||
|
b3VudHlAZXRoZXJldW0ub3JnPokCPgQTAQIAKAIbAwYLCQgHAwIGFQgCCQoLBBYC
|
||||||
|
AwECHgECF4AFAloJYfoFCQWjYFgACgkQ6I0zNPpfagoENg/+LnSaVeMxiGVtcjWl
|
||||||
|
b7Xd73yrEy4uxiESS1AalW9mMf7oZzfI05f7QIQlaLAkNac74vZDJbPKjtb7tpMO
|
||||||
|
RFhRZMCveq6CPKU6pd1SI8IUVUKwpEe6AJP3lHdVP57dquieFE2HlYKm6uHbCGWU
|
||||||
|
0cjyTA+uu2KbgCHGmofsPY/xOcZLGEHTHqa5w60JJAQm+BSDKnw8wTyrxGvA3EK/
|
||||||
|
ePSvOZMYa+iw6vYuZeBIMbdiXR/A2keBi3GuvqB8tDMj7P22TrH5mVDm3zNqGYD6
|
||||||
|
amDPeiWp4cztY3aZyLcgYotqXPpDceZzDn+HopBPzAb/llCdE7bVswKRhphVMw4b
|
||||||
|
bhL0R/TQY7Sf6TK2LKSBrjv0DWOSijikE71SJcBnJvHU7EpKrQQ0lMGclm3ynyji
|
||||||
|
Nf0YTPXQt4I+fwTmOew2GFeK3UytNWbWI7oXX7Nm4bj9bhf3IJ0kmZb/Gs73+xII
|
||||||
|
e7Rz52Mby436tWyQIQiF9ITYNGvNf53TwBBZMn0pKPiTyr3Ur7FHEotkEOFNh1//
|
||||||
|
4zQY10XxuBdLrYGyZ4V8xHJM+oKre8Eg2R9qHXVbjvErHE+7CvgnV7YUip0criPr
|
||||||
|
BlKRvuoJaSliH2JFhSjWVrkPmFGrWN0BAx10yIqMnEplfKeHf4P9Elek3oInS8WP
|
||||||
|
G1zJG6s/t5+hQK0X37+TB+6rd3GJAj4EEwECACgFAlgl4TsCGwMFCQHhM4AGCwkI
|
||||||
|
BwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOiNMzT6X2oKzf8P/iIKd77WHTbp4pMN
|
||||||
|
8h52HyZJtDJmjA1DPZrbGl1TesW/Z9uTd12txlgqZnbG2GfN9+LSP6EOPzR6v2xC
|
||||||
|
OVhR+RdWhZDJJuQCVS7lJIqQrZgmeTZG0TyQPZdLjVFBOrrhVwYX+HXbu429IzHr
|
||||||
|
URf5InyR1QgqOXyElDYS6e28HFqvaoA0DWTWDDqOLPVl+U5fuceIE2XXdv3AGLeP
|
||||||
|
Yf8J5MPobjPiZtBqI6S6iENY2Yn35qLX+axeC/iYSCHVtFuCCIdb/QYR1ZZV8Ps/
|
||||||
|
aI9DwC7LU+YfPw7iqCIoqxSeA3o1PORkdSigEg3jtfRv5UqVo9a0oBb9jdoADsat
|
||||||
|
F/gW0E7mto3XGOiaR0eB9SSdsM3x7Bz4A0HIGNaxpZo1RWqlO91leP4c13Px7ISv
|
||||||
|
5OGXfLg+M8qb+qxbGd1HpitGi9s1y1aVfEj1kOtZ0tN8eu+Upg5WKwPNBDX3ar7J
|
||||||
|
9NCULgVSL+E79FG+zXw62gxiQrLfKzm4wU/9L5wVkwQnm29hLJ0tokrSBZFnc/1l
|
||||||
|
7OC+GM63tYicKkY4rqmoWUeYx7IwFH9mtDtvR1RxO85RbQhZizwpZpdpRkH0DqZu
|
||||||
|
ZJRmRa5r7rPqmfa7d+VIFhz2Xs8pJMLVqxTsLKcLglmjw7aOrYG0SWeH7YraXWGD
|
||||||
|
N3SlvSBiVwcK7QUKzLLvpadLwxfsuQINBFgl3tgBEACbgq6HTN5gEBi0lkD/MafI
|
||||||
|
nmNi+59U5gRGYqk46WlfRjhHudXjDpgD0lolGb4hYontkMaKRlCg2Rvgjvk3Zve0
|
||||||
|
PKWjKw7gr8YBa9fMFY8BhAXI32OdyI9rFhxEZFfWAfwKVmT19BdeAQRFvcfd+8w8
|
||||||
|
f1XVc+zddULMJFBTr+xKDlIRWwTkdLPQeWbjo0eHl/g4tuLiLrTxVbnj26bf+2+1
|
||||||
|
DbM/w5VavzPrkviHqvKe/QP/gay4QDViWvFgLb90idfAHIdsPgflp0VDS5rVHFL6
|
||||||
|
D73rSRdIRo3I8c8mYoNjSR4XDuvgOkAKW9LR3pvouFHHjp6Fr0GesRbrbb2EG66i
|
||||||
|
PsR99MQ7FqIL9VMHPm2mtR+XvbnKkH2rYyEqaMbSdk29jGapkAWle4sIhSKk749A
|
||||||
|
4tGkHl08KZ2N9o6GrfUehP/V2eJLaph2DioFL1HxRryrKy80QQKLMJRekxigq8gr
|
||||||
|
eW8xB4zuf9Mkuou+RHNmo8PebHjFstLigiD6/zP2e+4tUmrT0/JTGOShoGMl8Rt0
|
||||||
|
VRxdPImKun+4LOXbfOxArOSkY6i35+gsgkkSy1gTJE0BY3S9auT6+YrglY/TWPQ9
|
||||||
|
IJxWVOKlT+3WIp5wJu2bBKQ420VLqDYzkoWytel/bM1ACUtipMiIVeUs2uFiRjpz
|
||||||
|
A1Wy0QHKPTdSuGlJPRrfcQARAQABiQIlBBgBAgAPAhsMBQJaCWIIBQkFo2BYAAoJ
|
||||||
|
EOiNMzT6X2oKgSwQAKKs7BGF8TyZeIEO2EUK7R2bdQDCdSGZY06tqLFg3IHMGxDM
|
||||||
|
b/7FVoa2AEsFgv6xpoebxBB5zkhUk7lslgxvKiSLYjxfNjTBltfiFJ+eQnf+OTs8
|
||||||
|
KeR51lLa66rvIH2qUzkNDCCTF45H4wIDpV05AXhBjKYkrDCrtey1rQyFp5fxI+0I
|
||||||
|
Q1UKKXvzZK4GdxhxDbOUSd38MYy93nqcmclGSGK/gF8XiyuVjeifDCM6+T1NQTX0
|
||||||
|
K9lneidcqtBDvlggJTLJtQPO33o5EHzXSiud+dKth1uUhZOFEaYRZoye1YE3yB0T
|
||||||
|
NOOE8fXlvu8iuIAMBSDL9ep6sEIaXYwoD60I2gHdWD0lkP0DOjGQpi4ouXM3Edsd
|
||||||
|
5MTi0MDRNTij431kn8T/D0LCgmoUmYYMBgbwFhXr67axPZlKjrqR0z3F/Elv0ZPP
|
||||||
|
cVg1tNznsALYQ9Ovl6b5M3cJ5GapbbvNWC7yEE1qScl9HiMxjt/H6aPastH63/7w
|
||||||
|
cN0TslW+zRBy05VNJvpWGStQXcngsSUeJtI1Gd992YNjUJq4/Lih6Z1TlwcFVap+
|
||||||
|
cTcDptoUvXYGg/9mRNNPZwErSfIJ0Ibnx9wPVuRN6NiCLOt2mtKp2F1pM6AOQPpZ
|
||||||
|
85vEh6I8i6OaO0w/Z0UHBwvpY6jDUliaROsWUQsqz78Z34CVj4cy6vPW2EF4
|
||||||
|
=r6KK
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
|
```
|
||||||
@@ -21,6 +21,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The ABI holds information about a contract's context and available
|
// The ABI holds information about a contract's context and available
|
||||||
@@ -68,23 +70,43 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Pack up the method ID too if not a constructor and return
|
// Pack up the method ID too if not a constructor and return
|
||||||
return append(method.Id(), arguments...), nil
|
return append(method.ID(), arguments...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unpack output in v according to the abi specification
|
// Unpack output in v according to the abi specification
|
||||||
func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
|
func (abi ABI) Unpack(v interface{}, name string, data []byte) (err error) {
|
||||||
if len(output) == 0 {
|
if len(data) == 0 {
|
||||||
return fmt.Errorf("abi: unmarshalling empty output")
|
return fmt.Errorf("abi: unmarshalling empty output")
|
||||||
}
|
}
|
||||||
// since there can't be naming collisions with contracts and events,
|
// since there can't be naming collisions with contracts and events,
|
||||||
// we need to decide whether we're calling a method or an event
|
// we need to decide whether we're calling a method or an event
|
||||||
if method, ok := abi.Methods[name]; ok {
|
if method, ok := abi.Methods[name]; ok {
|
||||||
if len(output)%32 != 0 {
|
if len(data)%32 != 0 {
|
||||||
return fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(output), output)
|
return fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(data), data)
|
||||||
}
|
}
|
||||||
return method.Outputs.Unpack(v, output)
|
return method.Outputs.Unpack(v, data)
|
||||||
} else if event, ok := abi.Events[name]; ok {
|
}
|
||||||
return event.Inputs.Unpack(v, output)
|
if event, ok := abi.Events[name]; ok {
|
||||||
|
return event.Inputs.Unpack(v, data)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("abi: could not locate named method or event")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnpackIntoMap unpacks a log into the provided map[string]interface{}
|
||||||
|
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
|
||||||
|
if len(data) == 0 {
|
||||||
|
return fmt.Errorf("abi: unmarshalling empty output")
|
||||||
|
}
|
||||||
|
// since there can't be naming collisions with contracts and events,
|
||||||
|
// we need to decide whether we're calling a method or an event
|
||||||
|
if method, ok := abi.Methods[name]; ok {
|
||||||
|
if len(data)%32 != 0 {
|
||||||
|
return fmt.Errorf("abi: improperly formatted output")
|
||||||
|
}
|
||||||
|
return method.Outputs.UnpackIntoMap(v, data)
|
||||||
|
}
|
||||||
|
if event, ok := abi.Events[name]; ok {
|
||||||
|
return event.Inputs.UnpackIntoMap(v, data)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("abi: could not locate named method or event")
|
return fmt.Errorf("abi: could not locate named method or event")
|
||||||
}
|
}
|
||||||
@@ -99,11 +121,9 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
Inputs []Argument
|
Inputs []Argument
|
||||||
Outputs []Argument
|
Outputs []Argument
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(data, &fields); err != nil {
|
if err := json.Unmarshal(data, &fields); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
abi.Methods = make(map[string]Method)
|
abi.Methods = make(map[string]Method)
|
||||||
abi.Events = make(map[string]Event)
|
abi.Events = make(map[string]Event)
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
@@ -114,15 +134,29 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
// empty defaults to function according to the abi spec
|
// empty defaults to function according to the abi spec
|
||||||
case "function", "":
|
case "function", "":
|
||||||
abi.Methods[field.Name] = Method{
|
name := field.Name
|
||||||
Name: field.Name,
|
_, ok := abi.Methods[name]
|
||||||
|
for idx := 0; ok; idx++ {
|
||||||
|
name = fmt.Sprintf("%s%d", field.Name, idx)
|
||||||
|
_, ok = abi.Methods[name]
|
||||||
|
}
|
||||||
|
abi.Methods[name] = Method{
|
||||||
|
Name: name,
|
||||||
|
RawName: field.Name,
|
||||||
Const: field.Constant,
|
Const: field.Constant,
|
||||||
Inputs: field.Inputs,
|
Inputs: field.Inputs,
|
||||||
Outputs: field.Outputs,
|
Outputs: field.Outputs,
|
||||||
}
|
}
|
||||||
case "event":
|
case "event":
|
||||||
abi.Events[field.Name] = Event{
|
name := field.Name
|
||||||
Name: field.Name,
|
_, ok := abi.Events[name]
|
||||||
|
for idx := 0; ok; idx++ {
|
||||||
|
name = fmt.Sprintf("%s%d", field.Name, idx)
|
||||||
|
_, ok = abi.Events[name]
|
||||||
|
}
|
||||||
|
abi.Events[name] = Event{
|
||||||
|
Name: name,
|
||||||
|
RawName: field.Name,
|
||||||
Anonymous: field.Anonymous,
|
Anonymous: field.Anonymous,
|
||||||
Inputs: field.Inputs,
|
Inputs: field.Inputs,
|
||||||
}
|
}
|
||||||
@@ -136,12 +170,23 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||||||
// returns nil if none found
|
// returns nil if none found
|
||||||
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
|
||||||
if len(sigdata) < 4 {
|
if len(sigdata) < 4 {
|
||||||
return nil, fmt.Errorf("data too short (% bytes) for abi method lookup", len(sigdata))
|
return nil, fmt.Errorf("data too short (%d bytes) for abi method lookup", len(sigdata))
|
||||||
}
|
}
|
||||||
for _, method := range abi.Methods {
|
for _, method := range abi.Methods {
|
||||||
if bytes.Equal(method.Id(), sigdata[:4]) {
|
if bytes.Equal(method.ID(), sigdata[:4]) {
|
||||||
return &method, nil
|
return &method, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no method with id: %#x", sigdata[:4])
|
return nil, fmt.Errorf("no method with id: %#x", sigdata[:4])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventByID looks an event up by its topic hash in the
|
||||||
|
// ABI and returns nil if none found.
|
||||||
|
func (abi *ABI) EventByID(topic common.Hash) (*Event, error) {
|
||||||
|
for _, event := range abi.Events {
|
||||||
|
if bytes.Equal(event.ID().Bytes(), topic.Bytes()) {
|
||||||
|
return &event, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("no event with id: %#x", topic.Hex())
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -62,10 +61,10 @@ func TestReader(t *testing.T) {
|
|||||||
exp := ABI{
|
exp := ABI{
|
||||||
Methods: map[string]Method{
|
Methods: map[string]Method{
|
||||||
"balance": {
|
"balance": {
|
||||||
"balance", true, nil, nil,
|
"balance", "balance", true, nil, nil,
|
||||||
},
|
},
|
||||||
"send": {
|
"send": {
|
||||||
"send", false, []Argument{
|
"send", "send", false, []Argument{
|
||||||
{"amount", Uint256, false},
|
{"amount", Uint256, false},
|
||||||
}, nil,
|
}, nil,
|
||||||
},
|
},
|
||||||
@@ -102,8 +101,7 @@ func TestReader(t *testing.T) {
|
|||||||
func TestTestNumbers(t *testing.T) {
|
func TestTestNumbers(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(jsondata2))
|
abi, err := JSON(strings.NewReader(jsondata2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := abi.Pack("balance"); err != nil {
|
if _, err := abi.Pack("balance"); err != nil {
|
||||||
@@ -140,8 +138,7 @@ func TestTestNumbers(t *testing.T) {
|
|||||||
func TestTestString(t *testing.T) {
|
func TestTestString(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(jsondata2))
|
abi, err := JSON(strings.NewReader(jsondata2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := abi.Pack("string", "hello world"); err != nil {
|
if _, err := abi.Pack("string", "hello world"); err != nil {
|
||||||
@@ -152,8 +149,7 @@ func TestTestString(t *testing.T) {
|
|||||||
func TestTestBool(t *testing.T) {
|
func TestTestBool(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(jsondata2))
|
abi, err := JSON(strings.NewReader(jsondata2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := abi.Pack("bool", true); err != nil {
|
if _, err := abi.Pack("bool", true); err != nil {
|
||||||
@@ -164,15 +160,12 @@ func TestTestBool(t *testing.T) {
|
|||||||
func TestTestSlice(t *testing.T) {
|
func TestTestSlice(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(jsondata2))
|
abi, err := JSON(strings.NewReader(jsondata2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slice := make([]uint64, 2)
|
slice := make([]uint64, 2)
|
||||||
if _, err := abi.Pack("uint64[2]", slice); err != nil {
|
if _, err := abi.Pack("uint64[2]", slice); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := abi.Pack("uint64[]", slice); err != nil {
|
if _, err := abi.Pack("uint64[]", slice); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
@@ -180,19 +173,19 @@ func TestTestSlice(t *testing.T) {
|
|||||||
|
|
||||||
func TestMethodSignature(t *testing.T) {
|
func TestMethodSignature(t *testing.T) {
|
||||||
String, _ := NewType("string", nil)
|
String, _ := NewType("string", nil)
|
||||||
m := Method{"foo", false, []Argument{{"bar", String, false}, {"baz", String, false}}, nil}
|
m := Method{"foo", "foo", false, []Argument{{"bar", String, false}, {"baz", String, false}}, nil}
|
||||||
exp := "foo(string,string)"
|
exp := "foo(string,string)"
|
||||||
if m.Sig() != exp {
|
if m.Sig() != exp {
|
||||||
t.Error("signature mismatch", exp, "!=", m.Sig())
|
t.Error("signature mismatch", exp, "!=", m.Sig())
|
||||||
}
|
}
|
||||||
|
|
||||||
idexp := crypto.Keccak256([]byte(exp))[:4]
|
idexp := crypto.Keccak256([]byte(exp))[:4]
|
||||||
if !bytes.Equal(m.Id(), idexp) {
|
if !bytes.Equal(m.ID(), idexp) {
|
||||||
t.Errorf("expected ids to match %x != %x", m.Id(), idexp)
|
t.Errorf("expected ids to match %x != %x", m.ID(), idexp)
|
||||||
}
|
}
|
||||||
|
|
||||||
uintt, _ := NewType("uint256", nil)
|
uintt, _ := NewType("uint256", nil)
|
||||||
m = Method{"foo", false, []Argument{{"bar", uintt, false}}, nil}
|
m = Method{"foo", "foo", false, []Argument{{"bar", uintt, false}}, nil}
|
||||||
exp = "foo(uint256)"
|
exp = "foo(uint256)"
|
||||||
if m.Sig() != exp {
|
if m.Sig() != exp {
|
||||||
t.Error("signature mismatch", exp, "!=", m.Sig())
|
t.Error("signature mismatch", exp, "!=", m.Sig())
|
||||||
@@ -211,18 +204,40 @@ func TestMethodSignature(t *testing.T) {
|
|||||||
{Name: "y", Type: "int256"},
|
{Name: "y", Type: "int256"},
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
m = Method{"foo", false, []Argument{{"s", s, false}, {"bar", String, false}}, nil}
|
m = Method{"foo", "foo", false, []Argument{{"s", s, false}, {"bar", String, false}}, nil}
|
||||||
exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)"
|
exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)"
|
||||||
if m.Sig() != exp {
|
if m.Sig() != exp {
|
||||||
t.Error("signature mismatch", exp, "!=", m.Sig())
|
t.Error("signature mismatch", exp, "!=", m.Sig())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOverloadedMethodSignature(t *testing.T) {
|
||||||
|
json := `[{"constant":true,"inputs":[{"name":"i","type":"uint256"},{"name":"j","type":"uint256"}],"name":"foo","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"i","type":"uint256"}],"name":"foo","outputs":[],"payable":false,"stateMutability":"pure","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"i","type":"uint256"}],"name":"bar","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"i","type":"uint256"},{"indexed":false,"name":"j","type":"uint256"}],"name":"bar","type":"event"}]`
|
||||||
|
abi, err := JSON(strings.NewReader(json))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
check := func(name string, expect string, method bool) {
|
||||||
|
if method {
|
||||||
|
if abi.Methods[name].Sig() != expect {
|
||||||
|
t.Fatalf("The signature of overloaded method mismatch, want %s, have %s", expect, abi.Methods[name].Sig())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if abi.Events[name].Sig() != expect {
|
||||||
|
t.Fatalf("The signature of overloaded event mismatch, want %s, have %s", expect, abi.Events[name].Sig())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check("foo", "foo(uint256,uint256)", true)
|
||||||
|
check("foo0", "foo(uint256)", true)
|
||||||
|
check("bar", "bar(uint256)", false)
|
||||||
|
check("bar0", "bar(uint256,uint256)", false)
|
||||||
|
}
|
||||||
|
|
||||||
func TestMultiPack(t *testing.T) {
|
func TestMultiPack(t *testing.T) {
|
||||||
abi, err := JSON(strings.NewReader(jsondata2))
|
abi, err := JSON(strings.NewReader(jsondata2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sig := crypto.Keccak256([]byte("bar(uint32,uint16)"))[:4]
|
sig := crypto.Keccak256([]byte("bar(uint32,uint16)"))[:4]
|
||||||
@@ -232,10 +247,8 @@ func TestMultiPack(t *testing.T) {
|
|||||||
|
|
||||||
packed, err := abi.Pack("bar", uint32(10), uint16(11))
|
packed, err := abi.Pack("bar", uint32(10), uint16(11))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
t.FailNow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(packed, sig) {
|
if !bytes.Equal(packed, sig) {
|
||||||
t.Errorf("expected %x got %x", sig, packed)
|
t.Errorf("expected %x got %x", sig, packed)
|
||||||
}
|
}
|
||||||
@@ -246,11 +259,11 @@ func ExampleJSON() {
|
|||||||
|
|
||||||
abi, err := JSON(strings.NewReader(definition))
|
abi, err := JSON(strings.NewReader(definition))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
out, err := abi.Pack("isBar", common.HexToAddress("01"))
|
out, err := abi.Pack("isBar", common.HexToAddress("01"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%x\n", out)
|
fmt.Printf("%x\n", out)
|
||||||
@@ -694,6 +707,189 @@ func TestUnpackEvent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUnpackEventIntoMap(t *testing.T) {
|
||||||
|
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
|
||||||
|
abi, err := JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
const hexdata = `000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158`
|
||||||
|
data, err := hex.DecodeString(hexdata)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(data)%32 == 0 {
|
||||||
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
receivedMap := map[string]interface{}{}
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err := abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if len(receivedMap) != 3 {
|
||||||
|
t.Error("unpacked `received` map expected to have length 3")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
|
}
|
||||||
|
|
||||||
|
receivedAddrMap := map[string]interface{}{}
|
||||||
|
if err = abi.UnpackIntoMap(receivedAddrMap, "receivedAddr", data); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if len(receivedAddrMap) != 1 {
|
||||||
|
t.Error("unpacked `receivedAddr` map expected to have length 1")
|
||||||
|
}
|
||||||
|
if receivedAddrMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked `receivedAddr` map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnpackMethodIntoMap(t *testing.T) {
|
||||||
|
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"send","outputs":[{"name":"amount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"get","outputs":[{"name":"hash","type":"bytes"}],"payable":true,"stateMutability":"payable","type":"function"}]`
|
||||||
|
abi, err := JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
const hexdata = `00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000015800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000158000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001580000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000015800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000158`
|
||||||
|
data, err := hex.DecodeString(hexdata)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(data)%32 != 0 {
|
||||||
|
t.Errorf("len(data) is %d, want a multiple of 32", len(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests a method with no outputs
|
||||||
|
receiveMap := map[string]interface{}{}
|
||||||
|
if err = abi.UnpackIntoMap(receiveMap, "receive", data); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if len(receiveMap) > 0 {
|
||||||
|
t.Error("unpacked `receive` map expected to have length 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests a method with only outputs
|
||||||
|
sendMap := map[string]interface{}{}
|
||||||
|
if err = abi.UnpackIntoMap(sendMap, "send", data); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if len(sendMap) != 1 {
|
||||||
|
t.Error("unpacked `send` map expected to have length 1")
|
||||||
|
}
|
||||||
|
if sendMap["amount"].(*big.Int).Cmp(big.NewInt(1)) != 0 {
|
||||||
|
t.Error("unpacked `send` map expected `amount` value of 1")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests a method with outputs and inputs
|
||||||
|
getMap := map[string]interface{}{}
|
||||||
|
if err = abi.UnpackIntoMap(getMap, "get", data); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if len(getMap) != 1 {
|
||||||
|
t.Error("unpacked `get` map expected to have length 1")
|
||||||
|
}
|
||||||
|
expectedBytes := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 88, 0}
|
||||||
|
if !bytes.Equal(getMap["hash"].([]byte), expectedBytes) {
|
||||||
|
t.Errorf("unpacked `get` map expected `hash` value of %v", expectedBytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnpackIntoMapNamingConflict(t *testing.T) {
|
||||||
|
// Two methods have the same name
|
||||||
|
var abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"get","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"send","outputs":[{"name":"amount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"get","outputs":[{"name":"hash","type":"bytes"}],"payable":true,"stateMutability":"payable","type":"function"}]`
|
||||||
|
abi, err := JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var hexdata = `00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158`
|
||||||
|
data, err := hex.DecodeString(hexdata)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(data)%32 == 0 {
|
||||||
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
|
}
|
||||||
|
getMap := map[string]interface{}{}
|
||||||
|
if err = abi.UnpackIntoMap(getMap, "get", data); err == nil {
|
||||||
|
t.Error("naming conflict between two methods; error expected")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Two events have the same name
|
||||||
|
abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"received","type":"event"}]`
|
||||||
|
abi, err = JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
hexdata = `000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158`
|
||||||
|
data, err = hex.DecodeString(hexdata)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(data)%32 == 0 {
|
||||||
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
|
}
|
||||||
|
receivedMap := map[string]interface{}{}
|
||||||
|
if err = abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
|
||||||
|
t.Error("naming conflict between two events; no error expected")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method and event have the same name
|
||||||
|
abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"received","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
|
||||||
|
abi, err = JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(data)%32 == 0 {
|
||||||
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
|
}
|
||||||
|
if err = abi.UnpackIntoMap(receivedMap, "received", data); err == nil {
|
||||||
|
t.Error("naming conflict between an event and a method; error expected")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conflict is case sensitive
|
||||||
|
abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"received","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
|
||||||
|
abi, err = JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(data)%32 == 0 {
|
||||||
|
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
|
||||||
|
}
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err = abi.UnpackIntoMap(receivedMap, "Received", data); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
if len(receivedMap) != 3 {
|
||||||
|
t.Error("unpacked `received` map expected to have length 3")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked `received` map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestABI_MethodById(t *testing.T) {
|
func TestABI_MethodById(t *testing.T) {
|
||||||
const abiJSON = `[
|
const abiJSON = `[
|
||||||
{"type":"function","name":"receive","constant":false,"inputs":[{"name":"memo","type":"bytes"}],"outputs":[],"payable":true,"stateMutability":"payable"},
|
{"type":"function","name":"receive","constant":false,"inputs":[{"name":"memo","type":"bytes"}],"outputs":[],"payable":true,"stateMutability":"payable"},
|
||||||
@@ -725,13 +921,13 @@ func TestABI_MethodById(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for name, m := range abi.Methods {
|
for name, m := range abi.Methods {
|
||||||
a := fmt.Sprintf("%v", m)
|
a := fmt.Sprintf("%v", m)
|
||||||
m2, err := abi.MethodById(m.Id())
|
m2, err := abi.MethodById(m.ID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to look up ABI method: %v", err)
|
t.Fatalf("Failed to look up ABI method: %v", err)
|
||||||
}
|
}
|
||||||
b := fmt.Sprintf("%v", m2)
|
b := fmt.Sprintf("%v", m2)
|
||||||
if a != b {
|
if a != b {
|
||||||
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.Id()))
|
t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.ID()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Also test empty
|
// Also test empty
|
||||||
@@ -745,3 +941,113 @@ func TestABI_MethodById(t *testing.T) {
|
|||||||
t.Errorf("Expected error, nil is short to decode data")
|
t.Errorf("Expected error, nil is short to decode data")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestABI_EventById(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
json string
|
||||||
|
event string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "",
|
||||||
|
json: `[
|
||||||
|
{"type":"event","name":"received","anonymous":false,"inputs":[
|
||||||
|
{"indexed":false,"name":"sender","type":"address"},
|
||||||
|
{"indexed":false,"name":"amount","type":"uint256"},
|
||||||
|
{"indexed":false,"name":"memo","type":"bytes"}
|
||||||
|
]
|
||||||
|
}]`,
|
||||||
|
event: "received(address,uint256,bytes)",
|
||||||
|
}, {
|
||||||
|
name: "",
|
||||||
|
json: `[
|
||||||
|
{ "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" },
|
||||||
|
{ "constant": false, "inputs": [ { "name": "_spender", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "approve", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" },
|
||||||
|
{ "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" },
|
||||||
|
{ "constant": false, "inputs": [ { "name": "_from", "type": "address" }, { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" },
|
||||||
|
{ "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" },
|
||||||
|
{ "constant": true, "inputs": [ { "name": "_owner", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "balance", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" },
|
||||||
|
{ "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" },
|
||||||
|
{ "constant": false, "inputs": [ { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transfer", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" },
|
||||||
|
{ "constant": true, "inputs": [ { "name": "_owner", "type": "address" }, { "name": "_spender", "type": "address" } ], "name": "allowance", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" },
|
||||||
|
{ "payable": true, "stateMutability": "payable", "type": "fallback" },
|
||||||
|
{ "anonymous": false, "inputs": [ { "indexed": true, "name": "owner", "type": "address" }, { "indexed": true, "name": "spender", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Approval", "type": "event" },
|
||||||
|
{ "anonymous": false, "inputs": [ { "indexed": true, "name": "from", "type": "address" }, { "indexed": true, "name": "to", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }
|
||||||
|
]`,
|
||||||
|
event: "Transfer(address,address,uint256)",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for testnum, test := range tests {
|
||||||
|
abi, err := JSON(strings.NewReader(test.json))
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
topic := test.event
|
||||||
|
topicID := crypto.Keccak256Hash([]byte(topic))
|
||||||
|
|
||||||
|
event, err := abi.EventByID(topicID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to look up ABI method: %v, test #%d", err, testnum)
|
||||||
|
}
|
||||||
|
if event == nil {
|
||||||
|
t.Errorf("We should find a event for topic %s, test #%d", topicID.Hex(), testnum)
|
||||||
|
}
|
||||||
|
|
||||||
|
if event.ID() != topicID {
|
||||||
|
t.Errorf("Event id %s does not match topic %s, test #%d", event.ID().Hex(), topicID.Hex(), testnum)
|
||||||
|
}
|
||||||
|
|
||||||
|
unknowntopicID := crypto.Keccak256Hash([]byte("unknownEvent"))
|
||||||
|
unknownEvent, err := abi.EventByID(unknowntopicID)
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("EventByID should return an error if a topic is not found, test #%d", testnum)
|
||||||
|
}
|
||||||
|
if unknownEvent != nil {
|
||||||
|
t.Errorf("We should not find any event for topic %s, test #%d", unknowntopicID.Hex(), testnum)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDuplicateMethodNames(t *testing.T) {
|
||||||
|
abiJSON := `[{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"},{"name":"customFallback","type":"string"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]`
|
||||||
|
contractAbi, err := JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer"]; !ok {
|
||||||
|
t.Fatalf("Could not find original method")
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer0"]; !ok {
|
||||||
|
t.Fatalf("Could not find duplicate method")
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer1"]; !ok {
|
||||||
|
t.Fatalf("Could not find duplicate method")
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer2"]; ok {
|
||||||
|
t.Fatalf("Should not have found extra method")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestDoubleDuplicateMethodNames checks that if transfer0 already exists, there won't be a name
|
||||||
|
// conflict and that the second transfer method will be renamed transfer1.
|
||||||
|
func TestDoubleDuplicateMethodNames(t *testing.T) {
|
||||||
|
abiJSON := `[{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"transfer0","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"},{"name":"customFallback","type":"string"}],"name":"transfer","outputs":[{"name":"ok","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]`
|
||||||
|
contractAbi, err := JSON(strings.NewReader(abiJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer"]; !ok {
|
||||||
|
t.Fatalf("Could not find original method")
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer0"]; !ok {
|
||||||
|
t.Fatalf("Could not find duplicate method")
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer1"]; !ok {
|
||||||
|
t.Fatalf("Could not find duplicate method")
|
||||||
|
}
|
||||||
|
if _, ok := contractAbi.Methods["transfer2"]; ok {
|
||||||
|
t.Fatalf("Should not have found extra method")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -102,6 +102,16 @@ func (arguments Arguments) Unpack(v interface{}, data []byte) error {
|
|||||||
return arguments.unpackAtomic(v, marshalledValues[0])
|
return arguments.unpackAtomic(v, marshalledValues[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value
|
||||||
|
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
|
||||||
|
marshalledValues, err := arguments.UnpackValues(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return arguments.unpackIntoMap(v, marshalledValues)
|
||||||
|
}
|
||||||
|
|
||||||
// unpack sets the unmarshalled value to go format.
|
// unpack sets the unmarshalled value to go format.
|
||||||
// Note the dst here must be settable.
|
// Note the dst here must be settable.
|
||||||
func unpack(t *Type, dst interface{}, src interface{}) error {
|
func unpack(t *Type, dst interface{}, src interface{}) error {
|
||||||
@@ -109,11 +119,22 @@ func unpack(t *Type, dst interface{}, src interface{}) error {
|
|||||||
dstVal = reflect.ValueOf(dst).Elem()
|
dstVal = reflect.ValueOf(dst).Elem()
|
||||||
srcVal = reflect.ValueOf(src)
|
srcVal = reflect.ValueOf(src)
|
||||||
)
|
)
|
||||||
|
tuple, typ := false, t
|
||||||
if t.T != TupleTy && !((t.T == SliceTy || t.T == ArrayTy) && t.Elem.T == TupleTy) {
|
for {
|
||||||
|
if typ.T == SliceTy || typ.T == ArrayTy {
|
||||||
|
typ = typ.Elem
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tuple = typ.T == TupleTy
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !tuple {
|
||||||
return set(dstVal, srcVal)
|
return set(dstVal, srcVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dereferences interface or pointer wrapper
|
||||||
|
dstVal = indirectInterfaceOrPtr(dstVal)
|
||||||
|
|
||||||
switch t.T {
|
switch t.T {
|
||||||
case TupleTy:
|
case TupleTy:
|
||||||
if dstVal.Kind() != reflect.Struct {
|
if dstVal.Kind() != reflect.Struct {
|
||||||
@@ -160,6 +181,19 @@ func unpack(t *Type, dst interface{}, src interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unpackIntoMap unpacks marshalledValues into the provided map[string]interface{}
|
||||||
|
func (arguments Arguments) unpackIntoMap(v map[string]interface{}, marshalledValues []interface{}) error {
|
||||||
|
// Make sure map is not nil
|
||||||
|
if v == nil {
|
||||||
|
return fmt.Errorf("abi: cannot unpack into a nil map")
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, arg := range arguments.NonIndexed() {
|
||||||
|
v[arg.Name] = marshalledValues[i]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// unpackAtomic unpacks ( hexdata -> go ) a single value
|
// unpackAtomic unpacks ( hexdata -> go ) a single value
|
||||||
func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interface{}) error {
|
func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interface{}) error {
|
||||||
if arguments.LengthNonIndexed() == 0 {
|
if arguments.LengthNonIndexed() == 0 {
|
||||||
@@ -168,7 +202,7 @@ func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interfac
|
|||||||
argument := arguments.NonIndexed()[0]
|
argument := arguments.NonIndexed()[0]
|
||||||
elem := reflect.ValueOf(v).Elem()
|
elem := reflect.ValueOf(v).Elem()
|
||||||
|
|
||||||
if elem.Kind() == reflect.Struct {
|
if elem.Kind() == reflect.Struct && argument.Type.T != TupleTy {
|
||||||
fieldmap, err := mapArgNamesToStructFields([]string{argument.Name}, elem)
|
fieldmap, err := mapArgNamesToStructFields([]string{argument.Name}, elem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/external"
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@@ -42,6 +44,24 @@ func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
|
|||||||
return NewKeyedTransactor(key.PrivateKey), nil
|
return NewKeyedTransactor(key.PrivateKey), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewKeyStoreTransactor is a utility method to easily create a transaction signer from
|
||||||
|
// an decrypted key from a keystore
|
||||||
|
func NewKeyStoreTransactor(keystore *keystore.KeyStore, account accounts.Account) (*TransactOpts, error) {
|
||||||
|
return &TransactOpts{
|
||||||
|
From: account.Address,
|
||||||
|
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
|
||||||
|
if address != account.Address {
|
||||||
|
return nil, errors.New("not authorized to sign this account")
|
||||||
|
}
|
||||||
|
signature, err := keystore.SignHash(account, signer.Hash(tx).Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tx.WithSignature(signer, signature)
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewKeyedTransactor is a utility method to easily create a transaction signer
|
// NewKeyedTransactor is a utility method to easily create a transaction signer
|
||||||
// from a single private key.
|
// from a single private key.
|
||||||
func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
|
func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
|
||||||
@@ -60,3 +80,17 @@ func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewClefTransactor is a utility method to easily create a transaction signer
|
||||||
|
// with a clef backend.
|
||||||
|
func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account) *TransactOpts {
|
||||||
|
return &TransactOpts{
|
||||||
|
From: account.Address,
|
||||||
|
Signer: func(signer types.Signer, address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
|
||||||
|
if address != account.Address {
|
||||||
|
return nil, errors.New("not authorized to sign this account")
|
||||||
|
}
|
||||||
|
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,8 +45,10 @@ import (
|
|||||||
// This nil assignment ensures compile time that SimulatedBackend implements bind.ContractBackend.
|
// This nil assignment ensures compile time that SimulatedBackend implements bind.ContractBackend.
|
||||||
var _ bind.ContractBackend = (*SimulatedBackend)(nil)
|
var _ bind.ContractBackend = (*SimulatedBackend)(nil)
|
||||||
|
|
||||||
var errBlockNumberUnsupported = errors.New("SimulatedBackend cannot access blocks other than the latest block")
|
var (
|
||||||
var errGasEstimationFailed = errors.New("gas required exceeds allowance or always failing transaction")
|
errBlockNumberUnsupported = errors.New("simulatedBackend cannot access blocks other than the latest block")
|
||||||
|
errGasEstimationFailed = errors.New("gas required exceeds allowance or always failing transaction")
|
||||||
|
)
|
||||||
|
|
||||||
// SimulatedBackend implements bind.ContractBackend, simulating a blockchain in
|
// SimulatedBackend implements bind.ContractBackend, simulating a blockchain in
|
||||||
// the background. Its main purpose is to allow easily testing contract bindings.
|
// the background. Its main purpose is to allow easily testing contract bindings.
|
||||||
@@ -63,10 +65,9 @@ type SimulatedBackend struct {
|
|||||||
config *params.ChainConfig
|
config *params.ChainConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSimulatedBackend creates a new binding backend using a simulated blockchain
|
// NewSimulatedBackendWithDatabase creates a new binding backend based on the given database
|
||||||
// for testing purposes.
|
// and uses a simulated blockchain for testing purposes.
|
||||||
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
||||||
database := ethdb.NewMemDatabase()
|
|
||||||
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
|
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
|
||||||
genesis.MustCommit(database)
|
genesis.MustCommit(database)
|
||||||
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil)
|
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil)
|
||||||
@@ -81,6 +82,18 @@ func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBac
|
|||||||
return backend
|
return backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSimulatedBackend creates a new binding backend using a simulated blockchain
|
||||||
|
// for testing purposes.
|
||||||
|
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
|
||||||
|
return NewSimulatedBackendWithDatabase(rawdb.NewMemoryDatabase(), alloc, gasLimit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close terminates the underlying blockchain's update loop.
|
||||||
|
func (b *SimulatedBackend) Close() error {
|
||||||
|
b.blockchain.Stop()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Commit imports all the pending transactions as a single block and starts a
|
// Commit imports all the pending transactions as a single block and starts a
|
||||||
// fresh new state.
|
// fresh new state.
|
||||||
func (b *SimulatedBackend) Commit() {
|
func (b *SimulatedBackend) Commit() {
|
||||||
@@ -160,10 +173,29 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
|
|||||||
|
|
||||||
// TransactionReceipt returns the receipt of a transaction.
|
// TransactionReceipt returns the receipt of a transaction.
|
||||||
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
|
||||||
receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash)
|
receipt, _, _, _ := rawdb.ReadReceipt(b.database, txHash, b.config)
|
||||||
return receipt, nil
|
return receipt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransactionByHash checks the pool of pending transactions in addition to the
|
||||||
|
// blockchain. The isPending return value indicates whether the transaction has been
|
||||||
|
// mined yet. Note that the transaction may not be part of the canonical chain even if
|
||||||
|
// it's not pending.
|
||||||
|
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
tx := b.pendingBlock.Transaction(txHash)
|
||||||
|
if tx != nil {
|
||||||
|
return tx, true, nil
|
||||||
|
}
|
||||||
|
tx, _, _, _ = rawdb.ReadTransaction(b.database, txHash)
|
||||||
|
if tx != nil {
|
||||||
|
return tx, false, nil
|
||||||
|
}
|
||||||
|
return nil, false, ethereum.NotFound
|
||||||
|
}
|
||||||
|
|
||||||
// PendingCodeAt returns the code associated with an account in the pending state.
|
// PendingCodeAt returns the code associated with an account in the pending state.
|
||||||
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
|
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
@@ -297,7 +329,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
|
|||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
sender, err := types.Sender(types.HomesteadSigner{}, tx)
|
sender, err := types.Sender(types.NewEIP155Signer(b.config.ChainID), tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("invalid transaction: %v", err))
|
panic(fmt.Errorf("invalid transaction: %v", err))
|
||||||
}
|
}
|
||||||
@@ -405,6 +437,11 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Blockchain returns the underlying blockchain.
|
||||||
|
func (b *SimulatedBackend) Blockchain() *core.BlockChain {
|
||||||
|
return b.blockchain
|
||||||
|
}
|
||||||
|
|
||||||
// callmsg implements core.Message to allow passing it as a transaction simulator.
|
// callmsg implements core.Message to allow passing it as a transaction simulator.
|
||||||
type callmsg struct {
|
type callmsg struct {
|
||||||
ethereum.CallMsg
|
ethereum.CallMsg
|
||||||
@@ -445,7 +482,7 @@ func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (typ
|
|||||||
if number == nil {
|
if number == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return rawdb.ReadReceipts(fb.db, hash, *number), nil
|
return rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
|
func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) {
|
||||||
@@ -453,7 +490,7 @@ func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash) ([][]*ty
|
|||||||
if number == nil {
|
if number == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
receipts := rawdb.ReadReceipts(fb.db, hash, *number)
|
receipts := rawdb.ReadReceipts(fb.db, hash, *number, fb.bc.Config())
|
||||||
if receipts == nil {
|
if receipts == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
83
accounts/abi/bind/backends/simulated_test.go
Normal file
83
accounts/abi/bind/backends/simulated_test.go
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package backends_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"math/big"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimulatedBackend(t *testing.T) {
|
||||||
|
var gasLimit uint64 = 8000029
|
||||||
|
key, _ := crypto.GenerateKey() // nolint: gosec
|
||||||
|
auth := bind.NewKeyedTransactor(key)
|
||||||
|
genAlloc := make(core.GenesisAlloc)
|
||||||
|
genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)}
|
||||||
|
|
||||||
|
sim := backends.NewSimulatedBackend(genAlloc, gasLimit)
|
||||||
|
defer sim.Close()
|
||||||
|
|
||||||
|
// should return an error if the tx is not found
|
||||||
|
txHash := common.HexToHash("2")
|
||||||
|
_, isPending, err := sim.TransactionByHash(context.Background(), txHash)
|
||||||
|
|
||||||
|
if isPending {
|
||||||
|
t.Fatal("transaction should not be pending")
|
||||||
|
}
|
||||||
|
if err != ethereum.NotFound {
|
||||||
|
t.Fatalf("err should be `ethereum.NotFound` but received %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate a transaction and confirm you can retrieve it
|
||||||
|
code := `6060604052600a8060106000396000f360606040526008565b00`
|
||||||
|
var gas uint64 = 3000000
|
||||||
|
tx := types.NewContractCreation(0, big.NewInt(0), gas, big.NewInt(1), common.FromHex(code))
|
||||||
|
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, key)
|
||||||
|
|
||||||
|
err = sim.SendTransaction(context.Background(), tx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("error sending transaction")
|
||||||
|
}
|
||||||
|
|
||||||
|
txHash = tx.Hash()
|
||||||
|
_, isPending, err = sim.TransactionByHash(context.Background(), txHash)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error getting transaction with hash: %v", txHash.String())
|
||||||
|
}
|
||||||
|
if !isPending {
|
||||||
|
t.Fatal("transaction should have pending status")
|
||||||
|
}
|
||||||
|
|
||||||
|
sim.Commit()
|
||||||
|
tx, isPending, err = sim.TransactionByHash(context.Background(), txHash)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("error getting transaction with hash: %v", txHash.String())
|
||||||
|
}
|
||||||
|
if isPending {
|
||||||
|
t.Fatal("transaction should not have pending status")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -252,7 +252,7 @@ func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]int
|
|||||||
opts = new(FilterOpts)
|
opts = new(FilterOpts)
|
||||||
}
|
}
|
||||||
// Append the event selector to the query parameters and construct the topic set
|
// Append the event selector to the query parameters and construct the topic set
|
||||||
query = append([][]interface{}{{c.abi.Events[name].Id()}}, query...)
|
query = append([][]interface{}{{c.abi.Events[name].ID()}}, query...)
|
||||||
|
|
||||||
topics, err := makeTopics(query...)
|
topics, err := makeTopics(query...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -301,7 +301,7 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter
|
|||||||
opts = new(WatchOpts)
|
opts = new(WatchOpts)
|
||||||
}
|
}
|
||||||
// Append the event selector to the query parameters and construct the topic set
|
// Append the event selector to the query parameters and construct the topic set
|
||||||
query = append([][]interface{}{{c.abi.Events[name].Id()}}, query...)
|
query = append([][]interface{}{{c.abi.Events[name].ID()}}, query...)
|
||||||
|
|
||||||
topics, err := makeTopics(query...)
|
topics, err := makeTopics(query...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -340,6 +340,22 @@ func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log)
|
|||||||
return parseTopics(out, indexed, log.Topics[1:])
|
return parseTopics(out, indexed, log.Topics[1:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnpackLogIntoMap unpacks a retrieved log into the provided map.
|
||||||
|
func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event string, log types.Log) error {
|
||||||
|
if len(log.Data) > 0 {
|
||||||
|
if err := c.abi.UnpackIntoMap(out, event, log.Data); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var indexed abi.Arguments
|
||||||
|
for _, arg := range c.abi.Events[event].Inputs {
|
||||||
|
if arg.Indexed {
|
||||||
|
indexed = append(indexed, arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parseTopicsIntoMap(out, indexed, log.Topics[1:])
|
||||||
|
}
|
||||||
|
|
||||||
// ensureContext is a helper method to ensure a context is not nil, even if the
|
// ensureContext is a helper method to ensure a context is not nil, even if the
|
||||||
// user specified it as such.
|
// user specified it as such.
|
||||||
func ensureContext(ctx context.Context) context.Context {
|
func ensureContext(ctx context.Context) context.Context {
|
||||||
|
|||||||
@@ -1,14 +1,36 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package bind_test
|
package bind_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockCaller struct {
|
type mockCaller struct {
|
||||||
@@ -25,7 +47,6 @@ func (mc *mockCaller) CallContract(ctx context.Context, call ethereum.CallMsg, b
|
|||||||
mc.callContractBlockNumber = blockNumber
|
mc.callContractBlockNumber = blockNumber
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPassingBlockNumber(t *testing.T) {
|
func TestPassingBlockNumber(t *testing.T) {
|
||||||
|
|
||||||
mc := &mockCaller{}
|
mc := &mockCaller{}
|
||||||
@@ -62,3 +83,265 @@ func TestPassingBlockNumber(t *testing.T) {
|
|||||||
t.Fatalf("CodeAt() was passed a block number when it should not have been")
|
t.Fatalf("CodeAt() was passed a block number when it should not have been")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hexData = "0x000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158"
|
||||||
|
|
||||||
|
func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
|
||||||
|
hash := crypto.Keccak256Hash([]byte("testName"))
|
||||||
|
mockLog := types.Log{
|
||||||
|
Address: common.HexToAddress("0x0"),
|
||||||
|
Topics: []common.Hash{
|
||||||
|
common.HexToHash("0x0"),
|
||||||
|
hash,
|
||||||
|
},
|
||||||
|
Data: hexutil.MustDecode(hexData),
|
||||||
|
BlockNumber: uint64(26),
|
||||||
|
TxHash: common.HexToHash("0x0"),
|
||||||
|
TxIndex: 111,
|
||||||
|
BlockHash: common.BytesToHash([]byte{1, 2, 3, 4, 5}),
|
||||||
|
Index: 7,
|
||||||
|
Removed: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
abiString := `[{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"string"},{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"}]`
|
||||||
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
|
receivedMap := make(map[string]interface{})
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"name": hash,
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err := bc.UnpackLogIntoMap(receivedMap, "received", mockLog); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(receivedMap) != 4 {
|
||||||
|
t.Fatal("unpacked map expected to have length 4")
|
||||||
|
}
|
||||||
|
if receivedMap["name"] != expectedReceivedMap["name"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
|
||||||
|
sliceBytes, err := rlp.EncodeToBytes([]string{"name1", "name2", "name3", "name4"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
hash := crypto.Keccak256Hash(sliceBytes)
|
||||||
|
mockLog := types.Log{
|
||||||
|
Address: common.HexToAddress("0x0"),
|
||||||
|
Topics: []common.Hash{
|
||||||
|
common.HexToHash("0x0"),
|
||||||
|
hash,
|
||||||
|
},
|
||||||
|
Data: hexutil.MustDecode(hexData),
|
||||||
|
BlockNumber: uint64(26),
|
||||||
|
TxHash: common.HexToHash("0x0"),
|
||||||
|
TxIndex: 111,
|
||||||
|
BlockHash: common.BytesToHash([]byte{1, 2, 3, 4, 5}),
|
||||||
|
Index: 7,
|
||||||
|
Removed: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
abiString := `[{"anonymous":false,"inputs":[{"indexed":true,"name":"names","type":"string[]"},{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"}]`
|
||||||
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
|
receivedMap := make(map[string]interface{})
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"names": hash,
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err := bc.UnpackLogIntoMap(receivedMap, "received", mockLog); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(receivedMap) != 4 {
|
||||||
|
t.Fatal("unpacked map expected to have length 4")
|
||||||
|
}
|
||||||
|
if receivedMap["names"] != expectedReceivedMap["names"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
|
||||||
|
arrBytes, err := rlp.EncodeToBytes([2]common.Address{common.HexToAddress("0x0"), common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2")})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
hash := crypto.Keccak256Hash(arrBytes)
|
||||||
|
mockLog := types.Log{
|
||||||
|
Address: common.HexToAddress("0x0"),
|
||||||
|
Topics: []common.Hash{
|
||||||
|
common.HexToHash("0x0"),
|
||||||
|
hash,
|
||||||
|
},
|
||||||
|
Data: hexutil.MustDecode(hexData),
|
||||||
|
BlockNumber: uint64(26),
|
||||||
|
TxHash: common.HexToHash("0x0"),
|
||||||
|
TxIndex: 111,
|
||||||
|
BlockHash: common.BytesToHash([]byte{1, 2, 3, 4, 5}),
|
||||||
|
Index: 7,
|
||||||
|
Removed: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
abiString := `[{"anonymous":false,"inputs":[{"indexed":true,"name":"addresses","type":"address[2]"},{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"}]`
|
||||||
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
|
receivedMap := make(map[string]interface{})
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"addresses": hash,
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err := bc.UnpackLogIntoMap(receivedMap, "received", mockLog); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(receivedMap) != 4 {
|
||||||
|
t.Fatal("unpacked map expected to have length 4")
|
||||||
|
}
|
||||||
|
if receivedMap["addresses"] != expectedReceivedMap["addresses"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
|
||||||
|
mockAddress := common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2")
|
||||||
|
addrBytes := mockAddress.Bytes()
|
||||||
|
hash := crypto.Keccak256Hash([]byte("mockFunction(address,uint)"))
|
||||||
|
functionSelector := hash[:4]
|
||||||
|
functionTyBytes := append(addrBytes, functionSelector...)
|
||||||
|
var functionTy [24]byte
|
||||||
|
copy(functionTy[:], functionTyBytes[0:24])
|
||||||
|
mockLog := types.Log{
|
||||||
|
Address: common.HexToAddress("0x0"),
|
||||||
|
Topics: []common.Hash{
|
||||||
|
common.HexToHash("0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"),
|
||||||
|
common.BytesToHash(functionTyBytes),
|
||||||
|
},
|
||||||
|
Data: hexutil.MustDecode(hexData),
|
||||||
|
BlockNumber: uint64(26),
|
||||||
|
TxHash: common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"),
|
||||||
|
TxIndex: 111,
|
||||||
|
BlockHash: common.BytesToHash([]byte{1, 2, 3, 4, 5}),
|
||||||
|
Index: 7,
|
||||||
|
Removed: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
abiString := `[{"anonymous":false,"inputs":[{"indexed":true,"name":"function","type":"function"},{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"}]`
|
||||||
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
|
receivedMap := make(map[string]interface{})
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"function": functionTy,
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err := bc.UnpackLogIntoMap(receivedMap, "received", mockLog); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(receivedMap) != 4 {
|
||||||
|
t.Fatal("unpacked map expected to have length 4")
|
||||||
|
}
|
||||||
|
if receivedMap["function"] != expectedReceivedMap["function"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
|
||||||
|
byts := []byte{1, 2, 3, 4, 5}
|
||||||
|
hash := crypto.Keccak256Hash(byts)
|
||||||
|
mockLog := types.Log{
|
||||||
|
Address: common.HexToAddress("0x0"),
|
||||||
|
Topics: []common.Hash{
|
||||||
|
common.HexToHash("0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"),
|
||||||
|
hash,
|
||||||
|
},
|
||||||
|
Data: hexutil.MustDecode(hexData),
|
||||||
|
BlockNumber: uint64(26),
|
||||||
|
TxHash: common.HexToHash("0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"),
|
||||||
|
TxIndex: 111,
|
||||||
|
BlockHash: common.BytesToHash([]byte{1, 2, 3, 4, 5}),
|
||||||
|
Index: 7,
|
||||||
|
Removed: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
abiString := `[{"anonymous":false,"inputs":[{"indexed":true,"name":"content","type":"bytes"},{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"}]`
|
||||||
|
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
|
||||||
|
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)
|
||||||
|
|
||||||
|
receivedMap := make(map[string]interface{})
|
||||||
|
expectedReceivedMap := map[string]interface{}{
|
||||||
|
"content": hash,
|
||||||
|
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||||
|
"amount": big.NewInt(1),
|
||||||
|
"memo": []byte{88},
|
||||||
|
}
|
||||||
|
if err := bc.UnpackLogIntoMap(receivedMap, "received", mockLog); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(receivedMap) != 4 {
|
||||||
|
t.Fatal("unpacked map expected to have length 4")
|
||||||
|
}
|
||||||
|
if receivedMap["content"] != expectedReceivedMap["content"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["sender"] != expectedReceivedMap["sender"] {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if receivedMap["amount"].(*big.Int).Cmp(expectedReceivedMap["amount"].(*big.Int)) != 0 {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(receivedMap["memo"].([]byte), expectedReceivedMap["memo"].([]byte)) {
|
||||||
|
t.Error("unpacked map does not match expected map")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ package bind
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -30,6 +31,7 @@ import (
|
|||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lang is a target programming language selector to generate bindings for.
|
// Lang is a target programming language selector to generate bindings for.
|
||||||
@@ -45,10 +47,13 @@ const (
|
|||||||
// to be used as is in client code, but rather as an intermediate struct which
|
// to be used as is in client code, but rather as an intermediate struct which
|
||||||
// enforces compile time type safety and naming convention opposed to having to
|
// enforces compile time type safety and naming convention opposed to having to
|
||||||
// manually maintain hard coded strings that break on runtime.
|
// manually maintain hard coded strings that break on runtime.
|
||||||
func Bind(types []string, abis []string, bytecodes []string, pkg string, lang Lang) (string, error) {
|
func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]string, pkg string, lang Lang, libs map[string]string) (string, error) {
|
||||||
// Process each individual contract requested binding
|
// Process each individual contract requested binding
|
||||||
contracts := make(map[string]*tmplContract)
|
contracts := make(map[string]*tmplContract)
|
||||||
|
|
||||||
|
// Map used to flag each encountered library as such
|
||||||
|
isLib := make(map[string]struct{})
|
||||||
|
|
||||||
for i := 0; i < len(types); i++ {
|
for i := 0; i < len(types); i++ {
|
||||||
// Parse the actual ABI to generate the binding for
|
// Parse the actual ABI to generate the binding for
|
||||||
evmABI, err := abi.JSON(strings.NewReader(abis[i]))
|
evmABI, err := abi.JSON(strings.NewReader(abis[i]))
|
||||||
@@ -63,11 +68,12 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
return r
|
return r
|
||||||
}, abis[i])
|
}, abis[i])
|
||||||
|
|
||||||
// Extract the call and transact methods; events; and sort them alphabetically
|
// Extract the call and transact methods; events, struct definitions; and sort them alphabetically
|
||||||
var (
|
var (
|
||||||
calls = make(map[string]*tmplMethod)
|
calls = make(map[string]*tmplMethod)
|
||||||
transacts = make(map[string]*tmplMethod)
|
transacts = make(map[string]*tmplMethod)
|
||||||
events = make(map[string]*tmplEvent)
|
events = make(map[string]*tmplEvent)
|
||||||
|
structs = make(map[string]*tmplStruct)
|
||||||
)
|
)
|
||||||
for _, original := range evmABI.Methods {
|
for _, original := range evmABI.Methods {
|
||||||
// Normalize the method for capital cases and non-anonymous inputs/outputs
|
// Normalize the method for capital cases and non-anonymous inputs/outputs
|
||||||
@@ -80,6 +86,9 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
if input.Name == "" {
|
if input.Name == "" {
|
||||||
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
|
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
|
||||||
}
|
}
|
||||||
|
if _, exist := structs[input.Type.String()]; input.Type.T == abi.TupleTy && !exist {
|
||||||
|
bindStructType[lang](input.Type, structs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
normalized.Outputs = make([]abi.Argument, len(original.Outputs))
|
normalized.Outputs = make([]abi.Argument, len(original.Outputs))
|
||||||
copy(normalized.Outputs, original.Outputs)
|
copy(normalized.Outputs, original.Outputs)
|
||||||
@@ -87,6 +96,9 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
if output.Name != "" {
|
if output.Name != "" {
|
||||||
normalized.Outputs[j].Name = capitalise(output.Name)
|
normalized.Outputs[j].Name = capitalise(output.Name)
|
||||||
}
|
}
|
||||||
|
if _, exist := structs[output.Type.String()]; output.Type.T == abi.TupleTy && !exist {
|
||||||
|
bindStructType[lang](output.Type, structs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Append the methods to the call or transact lists
|
// Append the methods to the call or transact lists
|
||||||
if original.Const {
|
if original.Const {
|
||||||
@@ -112,25 +124,61 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
if input.Name == "" {
|
if input.Name == "" {
|
||||||
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
|
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
|
||||||
}
|
}
|
||||||
|
if _, exist := structs[input.Type.String()]; input.Type.T == abi.TupleTy && !exist {
|
||||||
|
bindStructType[lang](input.Type, structs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Append the event to the accumulator list
|
// Append the event to the accumulator list
|
||||||
events[original.Name] = &tmplEvent{Original: original, Normalized: normalized}
|
events[original.Name] = &tmplEvent{Original: original, Normalized: normalized}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There is no easy way to pass arbitrary java objects to the Go side.
|
||||||
|
if len(structs) > 0 && lang == LangJava {
|
||||||
|
return "", errors.New("java binding for tuple arguments is not supported yet")
|
||||||
|
}
|
||||||
|
|
||||||
contracts[types[i]] = &tmplContract{
|
contracts[types[i]] = &tmplContract{
|
||||||
Type: capitalise(types[i]),
|
Type: capitalise(types[i]),
|
||||||
InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1),
|
InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1),
|
||||||
InputBin: strings.TrimSpace(bytecodes[i]),
|
InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"),
|
||||||
Constructor: evmABI.Constructor,
|
Constructor: evmABI.Constructor,
|
||||||
Calls: calls,
|
Calls: calls,
|
||||||
Transacts: transacts,
|
Transacts: transacts,
|
||||||
Events: events,
|
Events: events,
|
||||||
|
Libraries: make(map[string]string),
|
||||||
|
Structs: structs,
|
||||||
}
|
}
|
||||||
|
// Function 4-byte signatures are stored in the same sequence
|
||||||
|
// as types, if available.
|
||||||
|
if len(fsigs) > i {
|
||||||
|
contracts[types[i]].FuncSigs = fsigs[i]
|
||||||
|
}
|
||||||
|
// Parse library references.
|
||||||
|
for pattern, name := range libs {
|
||||||
|
matched, err := regexp.Match("__\\$"+pattern+"\\$__", []byte(contracts[types[i]].InputBin))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Could not search for pattern", "pattern", pattern, "contract", contracts[types[i]], "err", err)
|
||||||
|
}
|
||||||
|
if matched {
|
||||||
|
contracts[types[i]].Libraries[pattern] = name
|
||||||
|
// keep track that this type is a library
|
||||||
|
if _, ok := isLib[name]; !ok {
|
||||||
|
isLib[name] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check if that type has already been identified as a library
|
||||||
|
for i := 0; i < len(types); i++ {
|
||||||
|
_, ok := isLib[types[i]]
|
||||||
|
contracts[types[i]].Library = ok
|
||||||
}
|
}
|
||||||
// Generate the contract template data content and render it
|
// Generate the contract template data content and render it
|
||||||
data := &tmplData{
|
data := &tmplData{
|
||||||
Package: pkg,
|
Package: pkg,
|
||||||
Contracts: contracts,
|
Contracts: contracts,
|
||||||
|
Libraries: libs,
|
||||||
}
|
}
|
||||||
buffer := new(bytes.Buffer)
|
buffer := new(bytes.Buffer)
|
||||||
|
|
||||||
@@ -138,6 +186,8 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
"bindtype": bindType[lang],
|
"bindtype": bindType[lang],
|
||||||
"bindtopictype": bindTopicType[lang],
|
"bindtopictype": bindTopicType[lang],
|
||||||
"namedtype": namedType[lang],
|
"namedtype": namedType[lang],
|
||||||
|
"formatmethod": formatMethod,
|
||||||
|
"formatevent": formatEvent,
|
||||||
"capitalise": capitalise,
|
"capitalise": capitalise,
|
||||||
"decapitalise": decapitalise,
|
"decapitalise": decapitalise,
|
||||||
}
|
}
|
||||||
@@ -159,129 +209,67 @@ func Bind(types []string, abis []string, bytecodes []string, pkg string, lang La
|
|||||||
|
|
||||||
// bindType is a set of type binders that convert Solidity types to some supported
|
// bindType is a set of type binders that convert Solidity types to some supported
|
||||||
// programming language types.
|
// programming language types.
|
||||||
var bindType = map[Lang]func(kind abi.Type) string{
|
var bindType = map[Lang]func(kind abi.Type, structs map[string]*tmplStruct) string{
|
||||||
LangGo: bindTypeGo,
|
LangGo: bindTypeGo,
|
||||||
LangJava: bindTypeJava,
|
LangJava: bindTypeJava,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for the binding generators.
|
// bindBasicTypeGo converts basic solidity types(except array, slice and tuple) to Go one.
|
||||||
// It reads the unmatched characters after the inner type-match,
|
func bindBasicTypeGo(kind abi.Type) string {
|
||||||
// (since the inner type is a prefix of the total type declaration),
|
switch kind.T {
|
||||||
// looks for valid arrays (possibly a dynamic one) wrapping the inner type,
|
case abi.AddressTy:
|
||||||
// and returns the sizes of these arrays.
|
return "common.Address"
|
||||||
//
|
case abi.IntTy, abi.UintTy:
|
||||||
// Returned array sizes are in the same order as solidity signatures; inner array size first.
|
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
|
||||||
// Array sizes may also be "", indicating a dynamic array.
|
|
||||||
func wrapArray(stringKind string, innerLen int, innerMapping string) (string, []string) {
|
|
||||||
remainder := stringKind[innerLen:]
|
|
||||||
//find all the sizes
|
|
||||||
matches := regexp.MustCompile(`\[(\d*)\]`).FindAllStringSubmatch(remainder, -1)
|
|
||||||
parts := make([]string, 0, len(matches))
|
|
||||||
for _, match := range matches {
|
|
||||||
//get group 1 from the regex match
|
|
||||||
parts = append(parts, match[1])
|
|
||||||
}
|
|
||||||
return innerMapping, parts
|
|
||||||
}
|
|
||||||
|
|
||||||
// Translates the array sizes to a Go-lang declaration of a (nested) array of the inner type.
|
|
||||||
// Simply returns the inner type if arraySizes is empty.
|
|
||||||
func arrayBindingGo(inner string, arraySizes []string) string {
|
|
||||||
out := ""
|
|
||||||
//prepend all array sizes, from outer (end arraySizes) to inner (start arraySizes)
|
|
||||||
for i := len(arraySizes) - 1; i >= 0; i-- {
|
|
||||||
out += "[" + arraySizes[i] + "]"
|
|
||||||
}
|
|
||||||
out += inner
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// bindTypeGo converts a Solidity type to a Go one. Since there is no clear mapping
|
|
||||||
// from all Solidity types to Go ones (e.g. uint17), those that cannot be exactly
|
|
||||||
// mapped will use an upscaled type (e.g. *big.Int).
|
|
||||||
func bindTypeGo(kind abi.Type) string {
|
|
||||||
stringKind := kind.String()
|
|
||||||
innerLen, innerMapping := bindUnnestedTypeGo(stringKind)
|
|
||||||
return arrayBindingGo(wrapArray(stringKind, innerLen, innerMapping))
|
|
||||||
}
|
|
||||||
|
|
||||||
// The inner function of bindTypeGo, this finds the inner type of stringKind.
|
|
||||||
// (Or just the type itself if it is not an array or slice)
|
|
||||||
// The length of the matched part is returned, with the translated type.
|
|
||||||
func bindUnnestedTypeGo(stringKind string) (int, string) {
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case strings.HasPrefix(stringKind, "address"):
|
|
||||||
return len("address"), "common.Address"
|
|
||||||
|
|
||||||
case strings.HasPrefix(stringKind, "bytes"):
|
|
||||||
parts := regexp.MustCompile(`bytes([0-9]*)`).FindStringSubmatch(stringKind)
|
|
||||||
return len(parts[0]), fmt.Sprintf("[%s]byte", parts[1])
|
|
||||||
|
|
||||||
case strings.HasPrefix(stringKind, "int") || strings.HasPrefix(stringKind, "uint"):
|
|
||||||
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(stringKind)
|
|
||||||
switch parts[2] {
|
switch parts[2] {
|
||||||
case "8", "16", "32", "64":
|
case "8", "16", "32", "64":
|
||||||
return len(parts[0]), fmt.Sprintf("%sint%s", parts[1], parts[2])
|
return fmt.Sprintf("%sint%s", parts[1], parts[2])
|
||||||
}
|
}
|
||||||
return len(parts[0]), "*big.Int"
|
return "*big.Int"
|
||||||
|
case abi.FixedBytesTy:
|
||||||
case strings.HasPrefix(stringKind, "bool"):
|
return fmt.Sprintf("[%d]byte", kind.Size)
|
||||||
return len("bool"), "bool"
|
case abi.BytesTy:
|
||||||
|
return "[]byte"
|
||||||
case strings.HasPrefix(stringKind, "string"):
|
case abi.FunctionTy:
|
||||||
return len("string"), "string"
|
return "[24]byte"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return len(stringKind), stringKind
|
// string, bool types
|
||||||
|
return kind.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates the array sizes to a Java declaration of a (nested) array of the inner type.
|
// bindTypeGo converts solidity types to Go ones. Since there is no clear mapping
|
||||||
// Simply returns the inner type if arraySizes is empty.
|
// from all Solidity types to Go ones (e.g. uint17), those that cannot be exactly
|
||||||
func arrayBindingJava(inner string, arraySizes []string) string {
|
|
||||||
// Java array type declarations do not include the length.
|
|
||||||
return inner + strings.Repeat("[]", len(arraySizes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// bindTypeJava converts a Solidity type to a Java one. Since there is no clear mapping
|
|
||||||
// from all Solidity types to Java ones (e.g. uint17), those that cannot be exactly
|
|
||||||
// mapped will use an upscaled type (e.g. BigDecimal).
|
// mapped will use an upscaled type (e.g. BigDecimal).
|
||||||
func bindTypeJava(kind abi.Type) string {
|
func bindTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
stringKind := kind.String()
|
switch kind.T {
|
||||||
innerLen, innerMapping := bindUnnestedTypeJava(stringKind)
|
case abi.TupleTy:
|
||||||
return arrayBindingJava(wrapArray(stringKind, innerLen, innerMapping))
|
return structs[kind.String()].Name
|
||||||
|
case abi.ArrayTy:
|
||||||
|
return fmt.Sprintf("[%d]", kind.Size) + bindTypeGo(*kind.Elem, structs)
|
||||||
|
case abi.SliceTy:
|
||||||
|
return "[]" + bindTypeGo(*kind.Elem, structs)
|
||||||
|
default:
|
||||||
|
return bindBasicTypeGo(kind)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The inner function of bindTypeJava, this finds the inner type of stringKind.
|
// bindBasicTypeJava converts basic solidity types(except array, slice and tuple) to Java one.
|
||||||
// (Or just the type itself if it is not an array or slice)
|
func bindBasicTypeJava(kind abi.Type) string {
|
||||||
// The length of the matched part is returned, with the translated type.
|
switch kind.T {
|
||||||
func bindUnnestedTypeJava(stringKind string) (int, string) {
|
case abi.AddressTy:
|
||||||
|
return "Address"
|
||||||
switch {
|
case abi.IntTy, abi.UintTy:
|
||||||
case strings.HasPrefix(stringKind, "address"):
|
// Note that uint and int (without digits) are also matched,
|
||||||
parts := regexp.MustCompile(`address(\[[0-9]*\])?`).FindStringSubmatch(stringKind)
|
|
||||||
if len(parts) != 2 {
|
|
||||||
return len(stringKind), stringKind
|
|
||||||
}
|
|
||||||
if parts[1] == "" {
|
|
||||||
return len("address"), "Address"
|
|
||||||
}
|
|
||||||
return len(parts[0]), "Addresses"
|
|
||||||
|
|
||||||
case strings.HasPrefix(stringKind, "bytes"):
|
|
||||||
parts := regexp.MustCompile(`bytes([0-9]*)`).FindStringSubmatch(stringKind)
|
|
||||||
if len(parts) != 2 {
|
|
||||||
return len(stringKind), stringKind
|
|
||||||
}
|
|
||||||
return len(parts[0]), "byte[]"
|
|
||||||
|
|
||||||
case strings.HasPrefix(stringKind, "int") || strings.HasPrefix(stringKind, "uint"):
|
|
||||||
//Note that uint and int (without digits) are also matched,
|
|
||||||
// these are size 256, and will translate to BigInt (the default).
|
// these are size 256, and will translate to BigInt (the default).
|
||||||
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(stringKind)
|
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return len(stringKind), stringKind
|
return kind.String()
|
||||||
|
}
|
||||||
|
// All unsigned integers should be translated to BigInt since gomobile doesn't
|
||||||
|
// support them.
|
||||||
|
if parts[1] == "u" {
|
||||||
|
return "BigInt"
|
||||||
}
|
}
|
||||||
|
|
||||||
namedSize := map[string]string{
|
namedSize := map[string]string{
|
||||||
@@ -291,50 +279,146 @@ func bindUnnestedTypeJava(stringKind string) (int, string) {
|
|||||||
"64": "long",
|
"64": "long",
|
||||||
}[parts[2]]
|
}[parts[2]]
|
||||||
|
|
||||||
//default to BigInt
|
// default to BigInt
|
||||||
if namedSize == "" {
|
if namedSize == "" {
|
||||||
namedSize = "BigInt"
|
namedSize = "BigInt"
|
||||||
}
|
}
|
||||||
return len(parts[0]), namedSize
|
return namedSize
|
||||||
|
case abi.FixedBytesTy, abi.BytesTy:
|
||||||
case strings.HasPrefix(stringKind, "bool"):
|
return "byte[]"
|
||||||
return len("bool"), "boolean"
|
case abi.BoolTy:
|
||||||
|
return "boolean"
|
||||||
case strings.HasPrefix(stringKind, "string"):
|
case abi.StringTy:
|
||||||
return len("string"), "String"
|
return "String"
|
||||||
|
case abi.FunctionTy:
|
||||||
|
return "byte[24]"
|
||||||
default:
|
default:
|
||||||
return len(stringKind), stringKind
|
return kind.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pluralizeJavaType explicitly converts multidimensional types to predefined
|
||||||
|
// type in go side.
|
||||||
|
func pluralizeJavaType(typ string) string {
|
||||||
|
switch typ {
|
||||||
|
case "boolean":
|
||||||
|
return "Bools"
|
||||||
|
case "String":
|
||||||
|
return "Strings"
|
||||||
|
case "Address":
|
||||||
|
return "Addresses"
|
||||||
|
case "byte[]":
|
||||||
|
return "Binaries"
|
||||||
|
case "BigInt":
|
||||||
|
return "BigInts"
|
||||||
|
}
|
||||||
|
return typ + "[]"
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindTypeJava converts a Solidity type to a Java one. Since there is no clear mapping
|
||||||
|
// from all Solidity types to Java ones (e.g. uint17), those that cannot be exactly
|
||||||
|
// mapped will use an upscaled type (e.g. BigDecimal).
|
||||||
|
func bindTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
|
switch kind.T {
|
||||||
|
case abi.TupleTy:
|
||||||
|
return structs[kind.String()].Name
|
||||||
|
case abi.ArrayTy, abi.SliceTy:
|
||||||
|
return pluralizeJavaType(bindTypeJava(*kind.Elem, structs))
|
||||||
|
default:
|
||||||
|
return bindBasicTypeJava(kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bindTopicType is a set of type binders that convert Solidity types to some
|
// bindTopicType is a set of type binders that convert Solidity types to some
|
||||||
// supported programming language topic types.
|
// supported programming language topic types.
|
||||||
var bindTopicType = map[Lang]func(kind abi.Type) string{
|
var bindTopicType = map[Lang]func(kind abi.Type, structs map[string]*tmplStruct) string{
|
||||||
LangGo: bindTopicTypeGo,
|
LangGo: bindTopicTypeGo,
|
||||||
LangJava: bindTopicTypeJava,
|
LangJava: bindTopicTypeJava,
|
||||||
}
|
}
|
||||||
|
|
||||||
// bindTypeGo converts a Solidity topic type to a Go one. It is almost the same
|
// bindTopicTypeGo converts a Solidity topic type to a Go one. It is almost the same
|
||||||
// funcionality as for simple types, but dynamic types get converted to hashes.
|
// funcionality as for simple types, but dynamic types get converted to hashes.
|
||||||
func bindTopicTypeGo(kind abi.Type) string {
|
func bindTopicTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
bound := bindTypeGo(kind)
|
bound := bindTypeGo(kind, structs)
|
||||||
if bound == "string" || bound == "[]byte" {
|
if bound == "string" || bound == "[]byte" {
|
||||||
bound = "common.Hash"
|
bound = "common.Hash"
|
||||||
}
|
}
|
||||||
return bound
|
return bound
|
||||||
}
|
}
|
||||||
|
|
||||||
// bindTypeGo converts a Solidity topic type to a Java one. It is almost the same
|
// bindTopicTypeJava converts a Solidity topic type to a Java one. It is almost the same
|
||||||
// funcionality as for simple types, but dynamic types get converted to hashes.
|
// funcionality as for simple types, but dynamic types get converted to hashes.
|
||||||
func bindTopicTypeJava(kind abi.Type) string {
|
func bindTopicTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
bound := bindTypeJava(kind)
|
bound := bindTypeJava(kind, structs)
|
||||||
if bound == "String" || bound == "Bytes" {
|
if bound == "String" || bound == "byte[]" {
|
||||||
bound = "Hash"
|
bound = "Hash"
|
||||||
}
|
}
|
||||||
return bound
|
return bound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bindStructType is a set of type binders that convert Solidity tuple types to some supported
|
||||||
|
// programming language struct definition.
|
||||||
|
var bindStructType = map[Lang]func(kind abi.Type, structs map[string]*tmplStruct) string{
|
||||||
|
LangGo: bindStructTypeGo,
|
||||||
|
LangJava: bindStructTypeJava,
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindStructTypeGo converts a Solidity tuple type to a Go one and records the mapping
|
||||||
|
// in the given map.
|
||||||
|
// Notably, this function will resolve and record nested struct recursively.
|
||||||
|
func bindStructTypeGo(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
|
switch kind.T {
|
||||||
|
case abi.TupleTy:
|
||||||
|
if s, exist := structs[kind.String()]; exist {
|
||||||
|
return s.Name
|
||||||
|
}
|
||||||
|
var fields []*tmplField
|
||||||
|
for i, elem := range kind.TupleElems {
|
||||||
|
field := bindStructTypeGo(*elem, structs)
|
||||||
|
fields = append(fields, &tmplField{Type: field, Name: capitalise(kind.TupleRawNames[i]), SolKind: *elem})
|
||||||
|
}
|
||||||
|
name := fmt.Sprintf("Struct%d", len(structs))
|
||||||
|
structs[kind.String()] = &tmplStruct{
|
||||||
|
Name: name,
|
||||||
|
Fields: fields,
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
case abi.ArrayTy:
|
||||||
|
return fmt.Sprintf("[%d]", kind.Size) + bindStructTypeGo(*kind.Elem, structs)
|
||||||
|
case abi.SliceTy:
|
||||||
|
return "[]" + bindStructTypeGo(*kind.Elem, structs)
|
||||||
|
default:
|
||||||
|
return bindBasicTypeGo(kind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindStructTypeJava converts a Solidity tuple type to a Java one and records the mapping
|
||||||
|
// in the given map.
|
||||||
|
// Notably, this function will resolve and record nested struct recursively.
|
||||||
|
func bindStructTypeJava(kind abi.Type, structs map[string]*tmplStruct) string {
|
||||||
|
switch kind.T {
|
||||||
|
case abi.TupleTy:
|
||||||
|
if s, exist := structs[kind.String()]; exist {
|
||||||
|
return s.Name
|
||||||
|
}
|
||||||
|
var fields []*tmplField
|
||||||
|
for i, elem := range kind.TupleElems {
|
||||||
|
field := bindStructTypeJava(*elem, structs)
|
||||||
|
fields = append(fields, &tmplField{Type: field, Name: decapitalise(kind.TupleRawNames[i]), SolKind: *elem})
|
||||||
|
}
|
||||||
|
name := fmt.Sprintf("Class%d", len(structs))
|
||||||
|
structs[kind.String()] = &tmplStruct{
|
||||||
|
Name: name,
|
||||||
|
Fields: fields,
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
case abi.ArrayTy, abi.SliceTy:
|
||||||
|
return pluralizeJavaType(bindStructTypeJava(*kind.Elem, structs))
|
||||||
|
default:
|
||||||
|
return bindBasicTypeJava(kind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// namedType is a set of functions that transform language specific types to
|
// namedType is a set of functions that transform language specific types to
|
||||||
// named versions that my be used inside method names.
|
// named versions that my be used inside method names.
|
||||||
var namedType = map[Lang]func(string, abi.Type) string{
|
var namedType = map[Lang]func(string, abi.Type) string{
|
||||||
@@ -348,18 +432,8 @@ func namedTypeJava(javaKind string, solKind abi.Type) string {
|
|||||||
switch javaKind {
|
switch javaKind {
|
||||||
case "byte[]":
|
case "byte[]":
|
||||||
return "Binary"
|
return "Binary"
|
||||||
case "byte[][]":
|
|
||||||
return "Binaries"
|
|
||||||
case "string":
|
|
||||||
return "String"
|
|
||||||
case "string[]":
|
|
||||||
return "Strings"
|
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return "Bool"
|
return "Bool"
|
||||||
case "boolean[]":
|
|
||||||
return "Bools"
|
|
||||||
case "BigInt[]":
|
|
||||||
return "BigInts"
|
|
||||||
default:
|
default:
|
||||||
parts := regexp.MustCompile(`(u)?int([0-9]*)(\[[0-9]*\])?`).FindStringSubmatch(solKind.String())
|
parts := regexp.MustCompile(`(u)?int([0-9]*)(\[[0-9]*\])?`).FindStringSubmatch(solKind.String())
|
||||||
if len(parts) != 4 {
|
if len(parts) != 4 {
|
||||||
@@ -422,3 +496,63 @@ func structured(args abi.Arguments) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolveArgName converts a raw argument representation into a user friendly format.
|
||||||
|
func resolveArgName(arg abi.Argument, structs map[string]*tmplStruct) string {
|
||||||
|
var (
|
||||||
|
prefix string
|
||||||
|
embedded string
|
||||||
|
typ = &arg.Type
|
||||||
|
)
|
||||||
|
loop:
|
||||||
|
for {
|
||||||
|
switch typ.T {
|
||||||
|
case abi.SliceTy:
|
||||||
|
prefix += "[]"
|
||||||
|
case abi.ArrayTy:
|
||||||
|
prefix += fmt.Sprintf("[%d]", typ.Size)
|
||||||
|
default:
|
||||||
|
embedded = typ.String()
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
typ = typ.Elem
|
||||||
|
}
|
||||||
|
if s, exist := structs[embedded]; exist {
|
||||||
|
return prefix + s.Name
|
||||||
|
} else {
|
||||||
|
return arg.Type.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatMethod transforms raw method representation into a user friendly one.
|
||||||
|
func formatMethod(method abi.Method, structs map[string]*tmplStruct) string {
|
||||||
|
inputs := make([]string, len(method.Inputs))
|
||||||
|
for i, input := range method.Inputs {
|
||||||
|
inputs[i] = fmt.Sprintf("%v %v", resolveArgName(input, structs), input.Name)
|
||||||
|
}
|
||||||
|
outputs := make([]string, len(method.Outputs))
|
||||||
|
for i, output := range method.Outputs {
|
||||||
|
outputs[i] = resolveArgName(output, structs)
|
||||||
|
if len(output.Name) > 0 {
|
||||||
|
outputs[i] += fmt.Sprintf(" %v", output.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constant := ""
|
||||||
|
if method.Const {
|
||||||
|
constant = "constant "
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("function %v(%v) %sreturns(%v)", method.RawName, strings.Join(inputs, ", "), constant, strings.Join(outputs, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
// formatEvent transforms raw event representation into a user friendly one.
|
||||||
|
func formatEvent(event abi.Event, structs map[string]*tmplStruct) string {
|
||||||
|
inputs := make([]string, len(event.Inputs))
|
||||||
|
for i, input := range event.Inputs {
|
||||||
|
if input.Indexed {
|
||||||
|
inputs[i] = fmt.Sprintf("%v indexed %v", resolveArgName(input, structs), input.Name)
|
||||||
|
} else {
|
||||||
|
inputs[i] = fmt.Sprintf("%v %v", resolveArgName(input, structs), input.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("event %v(%v)", event.RawName, strings.Join(inputs, ", "))
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -22,6 +22,7 @@ import "github.com/ethereum/go-ethereum/accounts/abi"
|
|||||||
type tmplData struct {
|
type tmplData struct {
|
||||||
Package string // Name of the package to place the generated file in
|
Package string // Name of the package to place the generated file in
|
||||||
Contracts map[string]*tmplContract // List of contracts to generate into this file
|
Contracts map[string]*tmplContract // List of contracts to generate into this file
|
||||||
|
Libraries map[string]string // Map the bytecode's link pattern to the library name
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmplContract contains the data needed to generate an individual contract binding.
|
// tmplContract contains the data needed to generate an individual contract binding.
|
||||||
@@ -29,10 +30,14 @@ type tmplContract struct {
|
|||||||
Type string // Type name of the main contract binding
|
Type string // Type name of the main contract binding
|
||||||
InputABI string // JSON ABI used as the input to generate the binding from
|
InputABI string // JSON ABI used as the input to generate the binding from
|
||||||
InputBin string // Optional EVM bytecode used to denetare deploy code from
|
InputBin string // Optional EVM bytecode used to denetare deploy code from
|
||||||
|
FuncSigs map[string]string // Optional map: string signature -> 4-byte signature
|
||||||
Constructor abi.Method // Contract constructor for deploy parametrization
|
Constructor abi.Method // Contract constructor for deploy parametrization
|
||||||
Calls map[string]*tmplMethod // Contract calls that only read state data
|
Calls map[string]*tmplMethod // Contract calls that only read state data
|
||||||
Transacts map[string]*tmplMethod // Contract calls that write state data
|
Transacts map[string]*tmplMethod // Contract calls that write state data
|
||||||
Events map[string]*tmplEvent // Contract events accessors
|
Events map[string]*tmplEvent // Contract events accessors
|
||||||
|
Libraries map[string]string // Same as tmplData, but filtered to only keep what the contract needs
|
||||||
|
Structs map[string]*tmplStruct // Contract struct type definitions
|
||||||
|
Library bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// tmplMethod is a wrapper around an abi.Method that contains a few preprocessed
|
// tmplMethod is a wrapper around an abi.Method that contains a few preprocessed
|
||||||
@@ -49,6 +54,21 @@ type tmplEvent struct {
|
|||||||
Normalized abi.Event // Normalized version of the parsed fields
|
Normalized abi.Event // Normalized version of the parsed fields
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tmplField is a wrapper around a struct field with binding language
|
||||||
|
// struct type definition and relative filed name.
|
||||||
|
type tmplField struct {
|
||||||
|
Type string // Field type representation depends on target binding language
|
||||||
|
Name string // Field name converted from the raw user-defined field name
|
||||||
|
SolKind abi.Type // Raw abi type information
|
||||||
|
}
|
||||||
|
|
||||||
|
// tmplStruct is a wrapper around an abi.tuple contains a auto-generated
|
||||||
|
// struct name.
|
||||||
|
type tmplStruct struct {
|
||||||
|
Name string // Auto-generated struct name(We can't obtain the raw struct name through abi)
|
||||||
|
Fields []*tmplField // Struct fields definition depends on the binding language.
|
||||||
|
}
|
||||||
|
|
||||||
// tmplSource is language to template mapping containing all the supported
|
// tmplSource is language to template mapping containing all the supported
|
||||||
// programming languages the package can generate to.
|
// programming languages the package can generate to.
|
||||||
var tmplSource = map[Lang]string{
|
var tmplSource = map[Lang]string{
|
||||||
@@ -89,19 +109,32 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
{{range $contract := .Contracts}}
|
{{range $contract := .Contracts}}
|
||||||
|
{{$structs := $contract.Structs}}
|
||||||
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
// {{.Type}}ABI is the input ABI used to generate the binding from.
|
||||||
const {{.Type}}ABI = "{{.InputABI}}"
|
const {{.Type}}ABI = "{{.InputABI}}"
|
||||||
|
|
||||||
|
{{if $contract.FuncSigs}}
|
||||||
|
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
|
||||||
|
var {{.Type}}FuncSigs = map[string]string{
|
||||||
|
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}",
|
||||||
|
{{end}}
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if .InputBin}}
|
{{if .InputBin}}
|
||||||
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
|
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
|
||||||
const {{.Type}}Bin = ` + "`" + `{{.InputBin}}` + "`" + `
|
var {{.Type}}Bin = "0x{{.InputBin}}"
|
||||||
|
|
||||||
// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
||||||
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
|
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
|
||||||
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
|
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, nil, nil, err
|
return common.Address{}, nil, nil, err
|
||||||
}
|
}
|
||||||
|
{{range $pattern, $name := .Libraries}}
|
||||||
|
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
||||||
|
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
|
||||||
|
{{end}}
|
||||||
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
|
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, nil, nil, err
|
return common.Address{}, nil, nil, err
|
||||||
@@ -114,7 +147,7 @@ var (
|
|||||||
type {{.Type}} struct {
|
type {{.Type}} struct {
|
||||||
{{.Type}}Caller // Read-only binding to the contract
|
{{.Type}}Caller // Read-only binding to the contract
|
||||||
{{.Type}}Transactor // Write-only binding to the contract
|
{{.Type}}Transactor // Write-only binding to the contract
|
||||||
{{.Type}}Filterer // Log filterer for contract events
|
{{.Type}}Filterer // Log filterer for contract events
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{.Type}}Caller is an auto generated read-only Go binding around an Ethereum contract.
|
// {{.Type}}Caller is an auto generated read-only Go binding around an Ethereum contract.
|
||||||
@@ -252,16 +285,24 @@ var (
|
|||||||
return _{{$contract.Type}}.Contract.contract.Transact(opts, method, params...)
|
return _{{$contract.Type}}.Contract.contract.Transact(opts, method, params...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{range .Structs}}
|
||||||
|
// {{.Name}} is an auto generated low-level Go binding around an user-defined struct.
|
||||||
|
type {{.Name}} struct {
|
||||||
|
{{range $field := .Fields}}
|
||||||
|
{{$field.Name}} {{$field.Type}}{{end}}
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{range .Calls}}
|
{{range .Calls}}
|
||||||
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatmethod .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}},{{end}}{{end}} error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) {
|
||||||
{{if .Structured}}ret := new(struct{
|
{{if .Structured}}ret := new(struct{
|
||||||
{{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}}
|
{{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}}
|
||||||
{{end}}
|
{{end}}
|
||||||
}){{else}}var (
|
}){{else}}var (
|
||||||
{{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type}})
|
{{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type $structs}})
|
||||||
{{end}}
|
{{end}}
|
||||||
){{end}}
|
){{end}}
|
||||||
out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}&[]interface{}{
|
out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}&[]interface{}{
|
||||||
@@ -272,40 +313,40 @@ var (
|
|||||||
return {{if .Structured}}*ret,{{else}}{{range $i, $_ := .Normalized.Outputs}}*ret{{$i}},{{end}}{{end}} err
|
return {{if .Structured}}*ret,{{else}}{{range $i, $_ := .Normalized.Outputs}}*ret{{$i}},{{end}}{{end}} err
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatmethod .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}} {{end}} error) {
|
||||||
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatmethod .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}} {{end}} error) {
|
||||||
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
||||||
}
|
}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{range .Transacts}}
|
{{range .Transacts}}
|
||||||
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatmethod .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Transactor) {{.Normalized.Name}}(opts *bind.TransactOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type}} {{end}}) (*types.Transaction, error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Transactor) {{.Normalized.Name}}(opts *bind.TransactOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) {
|
||||||
return _{{$contract.Type}}.contract.Transact(opts, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
return _{{$contract.Type}}.contract.Transact(opts, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatmethod .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) (*types.Transaction, error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) {
|
||||||
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}})
|
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatmethod .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) (*types.Transaction, error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}TransactorSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type $structs}} {{end}}) (*types.Transaction, error) {
|
||||||
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}})
|
return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.TransactOpts {{range $i, $_ := .Normalized.Inputs}}, {{.Name}}{{end}})
|
||||||
}
|
}
|
||||||
{{end}}
|
{{end}}
|
||||||
@@ -377,14 +418,14 @@ var (
|
|||||||
|
|
||||||
// {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} event raised by the {{$contract.Type}} contract.
|
// {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} event raised by the {{$contract.Type}} contract.
|
||||||
type {{$contract.Type}}{{.Normalized.Name}} struct { {{range .Normalized.Inputs}}
|
type {{$contract.Type}}{{.Normalized.Name}} struct { {{range .Normalized.Inputs}}
|
||||||
{{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type}}{{else}}{{bindtype .Type}}{{end}}; {{end}}
|
{{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}}
|
||||||
Raw types.Log // Blockchain specific contextual infos
|
Raw types.Log // Blockchain specific contextual infos
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter{{.Normalized.Name}} is a free log retrieval operation binding the contract event 0x{{printf "%x" .Original.Id}}.
|
// Filter{{.Normalized.Name}} is a free log retrieval operation binding the contract event 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatevent .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Filter{{.Normalized.Name}}(opts *bind.FilterOpts{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type}}{{end}}{{end}}) (*{{$contract.Type}}{{.Normalized.Name}}Iterator, error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Filter{{.Normalized.Name}}(opts *bind.FilterOpts{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type $structs}}{{end}}{{end}}) (*{{$contract.Type}}{{.Normalized.Name}}Iterator, error) {
|
||||||
{{range .Normalized.Inputs}}
|
{{range .Normalized.Inputs}}
|
||||||
{{if .Indexed}}var {{.Name}}Rule []interface{}
|
{{if .Indexed}}var {{.Name}}Rule []interface{}
|
||||||
for _, {{.Name}}Item := range {{.Name}} {
|
for _, {{.Name}}Item := range {{.Name}} {
|
||||||
@@ -398,10 +439,10 @@ var (
|
|||||||
return &{{$contract.Type}}{{.Normalized.Name}}Iterator{contract: _{{$contract.Type}}.contract, event: "{{.Original.Name}}", logs: logs, sub: sub}, nil
|
return &{{$contract.Type}}{{.Normalized.Name}}Iterator{contract: _{{$contract.Type}}.contract, event: "{{.Original.Name}}", logs: logs, sub: sub}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.Id}}.
|
// Watch{{.Normalized.Name}} is a free log subscription operation binding the contract event 0x{{printf "%x" .Original.ID}}.
|
||||||
//
|
//
|
||||||
// Solidity: {{.Original.String}}
|
// Solidity: {{formatevent .Original $structs}}
|
||||||
func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Watch{{.Normalized.Name}}(opts *bind.WatchOpts, sink chan<- *{{$contract.Type}}{{.Normalized.Name}}{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type}}{{end}}{{end}}) (event.Subscription, error) {
|
func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Watch{{.Normalized.Name}}(opts *bind.WatchOpts, sink chan<- *{{$contract.Type}}{{.Normalized.Name}}{{range .Normalized.Inputs}}{{if .Indexed}}, {{.Name}} []{{bindtype .Type $structs}}{{end}}{{end}}) (event.Subscription, error) {
|
||||||
{{range .Normalized.Inputs}}
|
{{range .Normalized.Inputs}}
|
||||||
{{if .Indexed}}var {{.Name}}Rule []interface{}
|
{{if .Indexed}}var {{.Name}}Rule []interface{}
|
||||||
for _, {{.Name}}Item := range {{.Name}} {
|
for _, {{.Name}}Item := range {{.Name}} {
|
||||||
@@ -439,6 +480,18 @@ var (
|
|||||||
}
|
}
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse{{.Normalized.Name}} is a log parse operation binding the contract event 0x{{printf "%x" .Original.ID}}.
|
||||||
|
//
|
||||||
|
// Solidity: {{.Original.String}}
|
||||||
|
func (_{{$contract.Type}} *{{$contract.Type}}Filterer) Parse{{.Normalized.Name}}(log types.Log) (*{{$contract.Type}}{{.Normalized.Name}}, error) {
|
||||||
|
event := new({{$contract.Type}}{{.Normalized.Name}})
|
||||||
|
if err := _{{$contract.Type}}.contract.UnpackLog(event, "{{.Original.Name}}", log); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return event, nil
|
||||||
|
}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
@@ -452,95 +505,112 @@ const tmplSourceJava = `
|
|||||||
package {{.Package}};
|
package {{.Package}};
|
||||||
|
|
||||||
import org.ethereum.geth.*;
|
import org.ethereum.geth.*;
|
||||||
import org.ethereum.geth.internal.*;
|
import java.util.*;
|
||||||
|
|
||||||
{{range $contract := .Contracts}}
|
{{range $contract := .Contracts}}
|
||||||
public class {{.Type}} {
|
{{$structs := $contract.Structs}}
|
||||||
// ABI is the input ABI used to generate the binding from.
|
{{if not .Library}}public {{end}}class {{.Type}} {
|
||||||
public final static String ABI = "{{.InputABI}}";
|
// ABI is the input ABI used to generate the binding from.
|
||||||
|
public final static String ABI = "{{.InputABI}}";
|
||||||
{{if .InputBin}}
|
{{if $contract.FuncSigs}}
|
||||||
// BYTECODE is the compiled bytecode used for deploying new contracts.
|
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
|
||||||
public final static byte[] BYTECODE = "{{.InputBin}}".getBytes();
|
public final static Map<String, String> {{.Type}}FuncSigs;
|
||||||
|
static {
|
||||||
// deploy deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
Hashtable<String, String> temp = new Hashtable<String, String>();
|
||||||
public static {{.Type}} deploy(TransactOpts auth, EthereumClient client{{range .Constructor.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
|
{{range $strsig, $binsig := .FuncSigs}}temp.put("{{$binsig}}", "{{$strsig}}");
|
||||||
Interfaces args = Geth.newInterfaces({{(len .Constructor.Inputs)}});
|
|
||||||
{{range $index, $element := .Constructor.Inputs}}
|
|
||||||
args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
|
|
||||||
{{end}}
|
|
||||||
return new {{.Type}}(Geth.deployContract(auth, ABI, BYTECODE, client, args));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal constructor used by contract deployment.
|
|
||||||
private {{.Type}}(BoundContract deployment) {
|
|
||||||
this.Address = deployment.getAddress();
|
|
||||||
this.Deployer = deployment.getDeployer();
|
|
||||||
this.Contract = deployment;
|
|
||||||
}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
// Ethereum address where this contract is located at.
|
|
||||||
public final Address Address;
|
|
||||||
|
|
||||||
// Ethereum transaction in which this contract was deployed (if known!).
|
|
||||||
public final Transaction Deployer;
|
|
||||||
|
|
||||||
// Contract instance bound to a blockchain address.
|
|
||||||
private final BoundContract Contract;
|
|
||||||
|
|
||||||
// Creates a new instance of {{.Type}}, bound to a specific deployed contract.
|
|
||||||
public {{.Type}}(Address address, EthereumClient client) throws Exception {
|
|
||||||
this(Geth.bindContract(address, ABI, client));
|
|
||||||
}
|
|
||||||
|
|
||||||
{{range .Calls}}
|
|
||||||
{{if gt (len .Normalized.Outputs) 1}}
|
|
||||||
// {{capitalise .Normalized.Name}}Results is the output of a call to {{.Normalized.Name}}.
|
|
||||||
public class {{capitalise .Normalized.Name}}Results {
|
|
||||||
{{range $index, $item := .Normalized.Outputs}}public {{bindtype .Type}} {{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}};
|
|
||||||
{{end}}
|
|
||||||
}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{.Type}}FuncSigs = Collections.unmodifiableMap(temp);
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
{{if .InputBin}}
|
||||||
|
// BYTECODE is the compiled bytecode used for deploying new contracts.
|
||||||
|
public final static String BYTECODE = "0x{{.InputBin}}";
|
||||||
|
|
||||||
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}.
|
// deploy deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
|
||||||
//
|
public static {{.Type}} deploy(TransactOpts auth, EthereumClient client{{range .Constructor.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception {
|
||||||
// Solidity: {{.Original.String}}
|
Interfaces args = Geth.newInterfaces({{(len .Constructor.Inputs)}});
|
||||||
public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
|
String bytecode = BYTECODE;
|
||||||
Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
|
{{if .Libraries}}
|
||||||
{{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
Interfaces results = Geth.newInterfaces({{(len .Normalized.Outputs)}});
|
// "link" contract to dependent libraries by deploying them first.
|
||||||
{{range $index, $item := .Normalized.Outputs}}Interface result{{$index}} = Geth.newInterface(); result{{$index}}.setDefault{{namedtype (bindtype .Type) .Type}}(); results.set({{$index}}, result{{$index}});
|
{{range $pattern, $name := .Libraries}}
|
||||||
{{end}}
|
{{capitalise $name}} {{decapitalise $name}}Inst = {{capitalise $name}}.deploy(auth, client);
|
||||||
|
bytecode = bytecode.replace("__${{$pattern}}$__", {{decapitalise $name}}Inst.Address.getHex().substring(2));
|
||||||
if (opts == null) {
|
|
||||||
opts = Geth.newCallOpts();
|
|
||||||
}
|
|
||||||
this.Contract.call(opts, results, "{{.Original.Name}}", args);
|
|
||||||
{{if gt (len .Normalized.Outputs) 1}}
|
|
||||||
{{capitalise .Normalized.Name}}Results result = new {{capitalise .Normalized.Name}}Results();
|
|
||||||
{{range $index, $item := .Normalized.Outputs}}result.{{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}} = results.get({{$index}}).get{{namedtype (bindtype .Type) .Type}}();
|
|
||||||
{{end}}
|
|
||||||
return result;
|
|
||||||
{{else}}{{range .Normalized.Outputs}}return results.get(0).get{{namedtype (bindtype .Type) .Type}}();{{end}}
|
|
||||||
{{end}}
|
|
||||||
}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{range $index, $element := .Constructor.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}});
|
||||||
|
{{end}}
|
||||||
|
return new {{.Type}}(Geth.deployContract(auth, ABI, Geth.decodeFromHex(bytecode), client, args));
|
||||||
|
}
|
||||||
|
|
||||||
{{range .Transacts}}
|
// Internal constructor used by contract deployment.
|
||||||
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.Id}}.
|
private {{.Type}}(BoundContract deployment) {
|
||||||
//
|
this.Address = deployment.getAddress();
|
||||||
// Solidity: {{.Original.String}}
|
this.Deployer = deployment.getDeployer();
|
||||||
public Transaction {{.Normalized.Name}}(TransactOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
|
this.Contract = deployment;
|
||||||
Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
|
}
|
||||||
{{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
|
{{end}}
|
||||||
{{end}}
|
|
||||||
|
|
||||||
return this.Contract.transact(opts, "{{.Original.Name}}" , args);
|
// Ethereum address where this contract is located at.
|
||||||
}
|
public final Address Address;
|
||||||
|
|
||||||
|
// Ethereum transaction in which this contract was deployed (if known!).
|
||||||
|
public final Transaction Deployer;
|
||||||
|
|
||||||
|
// Contract instance bound to a blockchain address.
|
||||||
|
private final BoundContract Contract;
|
||||||
|
|
||||||
|
// Creates a new instance of {{.Type}}, bound to a specific deployed contract.
|
||||||
|
public {{.Type}}(Address address, EthereumClient client) throws Exception {
|
||||||
|
this(Geth.bindContract(address, ABI, client));
|
||||||
|
}
|
||||||
|
|
||||||
|
{{range .Calls}}
|
||||||
|
{{if gt (len .Normalized.Outputs) 1}}
|
||||||
|
// {{capitalise .Normalized.Name}}Results is the output of a call to {{.Normalized.Name}}.
|
||||||
|
public class {{capitalise .Normalized.Name}}Results {
|
||||||
|
{{range $index, $item := .Normalized.Outputs}}public {{bindtype .Type $structs}} {{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}};
|
||||||
{{end}}
|
{{end}}
|
||||||
}
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
|
//
|
||||||
|
// Solidity: {{.Original.String}}
|
||||||
|
public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception {
|
||||||
|
Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
|
||||||
|
{{range $index, $item := .Normalized.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}});
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
Interfaces results = Geth.newInterfaces({{(len .Normalized.Outputs)}});
|
||||||
|
{{range $index, $item := .Normalized.Outputs}}Interface result{{$index}} = Geth.newInterface(); result{{$index}}.setDefault{{namedtype (bindtype .Type $structs) .Type}}(); results.set({{$index}}, result{{$index}});
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
if (opts == null) {
|
||||||
|
opts = Geth.newCallOpts();
|
||||||
|
}
|
||||||
|
this.Contract.call(opts, results, "{{.Original.Name}}", args);
|
||||||
|
{{if gt (len .Normalized.Outputs) 1}}
|
||||||
|
{{capitalise .Normalized.Name}}Results result = new {{capitalise .Normalized.Name}}Results();
|
||||||
|
{{range $index, $item := .Normalized.Outputs}}result.{{if ne .Name ""}}{{.Name}}{{else}}Return{{$index}}{{end}} = results.get({{$index}}).get{{namedtype (bindtype .Type $structs) .Type}}();
|
||||||
|
{{end}}
|
||||||
|
return result;
|
||||||
|
{{else}}{{range .Normalized.Outputs}}return results.get(0).get{{namedtype (bindtype .Type $structs) .Type}}();{{end}}
|
||||||
|
{{end}}
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range .Transacts}}
|
||||||
|
// {{.Normalized.Name}} is a paid mutator transaction binding the contract method 0x{{printf "%x" .Original.ID}}.
|
||||||
|
//
|
||||||
|
// Solidity: {{.Original.String}}
|
||||||
|
public Transaction {{.Normalized.Name}}(TransactOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception {
|
||||||
|
Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
|
||||||
|
{{range $index, $item := .Normalized.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}});
|
||||||
|
{{end}}
|
||||||
|
return this.Contract.transact(opts, "{{.Original.Name}}" , args);
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
}
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package bind
|
package bind
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
@@ -83,8 +84,10 @@ func makeTopics(query ...[]interface{}) ([][]common.Hash, error) {
|
|||||||
val := reflect.ValueOf(rule)
|
val := reflect.ValueOf(rule)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|
||||||
|
// static byte array
|
||||||
case val.Kind() == reflect.Array && reflect.TypeOf(rule).Elem().Kind() == reflect.Uint8:
|
case val.Kind() == reflect.Array && reflect.TypeOf(rule).Elem().Kind() == reflect.Uint8:
|
||||||
reflect.Copy(reflect.ValueOf(topic[common.HashLength-val.Len():]), val)
|
reflect.Copy(reflect.ValueOf(topic[:val.Len()]), val)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported indexed type: %T", rule)
|
return nil, fmt.Errorf("unsupported indexed type: %T", rule)
|
||||||
@@ -175,8 +178,10 @@ func parseTopics(out interface{}, fields abi.Arguments, topics []common.Hash) er
|
|||||||
default:
|
default:
|
||||||
// Ran out of custom types, try the crazies
|
// Ran out of custom types, try the crazies
|
||||||
switch {
|
switch {
|
||||||
|
|
||||||
|
// static byte array
|
||||||
case arg.Type.T == abi.FixedBytesTy:
|
case arg.Type.T == abi.FixedBytesTy:
|
||||||
reflect.Copy(field, reflect.ValueOf(topics[0][common.HashLength-arg.Type.Size:]))
|
reflect.Copy(field, reflect.ValueOf(topics[0][:arg.Type.Size]))
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported indexed type: %v", arg.Type)
|
return fmt.Errorf("unsupported indexed type: %v", arg.Type)
|
||||||
@@ -187,3 +192,50 @@ func parseTopics(out interface{}, fields abi.Arguments, topics []common.Hash) er
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parseTopicsIntoMap converts the indexed topic field-value pairs into map key-value pairs
|
||||||
|
func parseTopicsIntoMap(out map[string]interface{}, fields abi.Arguments, topics []common.Hash) error {
|
||||||
|
// Sanity check that the fields and topics match up
|
||||||
|
if len(fields) != len(topics) {
|
||||||
|
return errors.New("topic/field count mismatch")
|
||||||
|
}
|
||||||
|
// Iterate over all the fields and reconstruct them from topics
|
||||||
|
for _, arg := range fields {
|
||||||
|
if !arg.Indexed {
|
||||||
|
return errors.New("non-indexed field in topic reconstruction")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch arg.Type.T {
|
||||||
|
case abi.BoolTy:
|
||||||
|
out[arg.Name] = topics[0][common.HashLength-1] == 1
|
||||||
|
case abi.IntTy, abi.UintTy:
|
||||||
|
num := new(big.Int).SetBytes(topics[0][:])
|
||||||
|
out[arg.Name] = num
|
||||||
|
case abi.AddressTy:
|
||||||
|
var addr common.Address
|
||||||
|
copy(addr[:], topics[0][common.HashLength-common.AddressLength:])
|
||||||
|
out[arg.Name] = addr
|
||||||
|
case abi.HashTy:
|
||||||
|
out[arg.Name] = topics[0]
|
||||||
|
case abi.FixedBytesTy:
|
||||||
|
out[arg.Name] = topics[0][:]
|
||||||
|
case abi.StringTy, abi.BytesTy, abi.SliceTy, abi.ArrayTy:
|
||||||
|
// Array types (including strings and bytes) have their keccak256 hashes stored in the topic- not a hash
|
||||||
|
// whose bytes can be decoded to the actual value- so the best we can do is retrieve that hash
|
||||||
|
out[arg.Name] = topics[0]
|
||||||
|
case abi.FunctionTy:
|
||||||
|
if garbage := binary.BigEndian.Uint64(topics[0][0:8]); garbage != 0 {
|
||||||
|
return fmt.Errorf("bind: got improperly encoded function type, got %v", topics[0].Bytes())
|
||||||
|
}
|
||||||
|
var tmp [24]byte
|
||||||
|
copy(tmp[:], topics[0][8:32])
|
||||||
|
out[arg.Name] = tmp
|
||||||
|
default: // Not handling tuples
|
||||||
|
return fmt.Errorf("unsupported indexed type: %v", arg.Type)
|
||||||
|
}
|
||||||
|
|
||||||
|
topics = topics[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
103
accounts/abi/bind/topics_test.go
Normal file
103
accounts/abi/bind/topics_test.go
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package bind
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMakeTopics(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
query [][]interface{}
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want [][]common.Hash
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"support fixed byte types, right padded to 32 bytes",
|
||||||
|
args{[][]interface{}{{[5]byte{1, 2, 3, 4, 5}}}},
|
||||||
|
[][]common.Hash{{common.Hash{1, 2, 3, 4, 5}}},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, err := makeTopics(tt.args.query...)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("makeTopics() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
|
t.Errorf("makeTopics() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseTopics(t *testing.T) {
|
||||||
|
type bytesStruct struct {
|
||||||
|
StaticBytes [5]byte
|
||||||
|
}
|
||||||
|
bytesType, _ := abi.NewType("bytes5", nil)
|
||||||
|
type args struct {
|
||||||
|
createObj func() interface{}
|
||||||
|
resultObj func() interface{}
|
||||||
|
fields abi.Arguments
|
||||||
|
topics []common.Hash
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "support fixed byte types, right padded to 32 bytes",
|
||||||
|
args: args{
|
||||||
|
createObj: func() interface{} { return &bytesStruct{} },
|
||||||
|
resultObj: func() interface{} { return &bytesStruct{StaticBytes: [5]byte{1, 2, 3, 4, 5}} },
|
||||||
|
fields: abi.Arguments{abi.Argument{
|
||||||
|
Name: "staticBytes",
|
||||||
|
Type: bytesType,
|
||||||
|
Indexed: true,
|
||||||
|
}},
|
||||||
|
topics: []common.Hash{
|
||||||
|
{1, 2, 3, 4, 5},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
createObj := tt.args.createObj()
|
||||||
|
if err := parseTopics(createObj, tt.args.fields, tt.args.topics); (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("parseTopics() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
}
|
||||||
|
resultObj := tt.args.resultObj()
|
||||||
|
if !reflect.DeepEqual(createObj, resultObj) {
|
||||||
|
t.Errorf("parseTopics() = %v, want %v", createObj, resultObj)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,8 +56,10 @@ func TestWaitDeployed(t *testing.T) {
|
|||||||
backend := backends.NewSimulatedBackend(
|
backend := backends.NewSimulatedBackend(
|
||||||
core.GenesisAlloc{
|
core.GenesisAlloc{
|
||||||
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
|
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
|
||||||
}, 10000000,
|
},
|
||||||
|
10000000,
|
||||||
)
|
)
|
||||||
|
defer backend.Close()
|
||||||
|
|
||||||
// Create the transaction.
|
// Create the transaction.
|
||||||
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
|
tx := types.NewContractCreation(0, big.NewInt(0), test.gas, big.NewInt(1), common.FromHex(test.code))
|
||||||
|
|||||||
@@ -28,7 +28,18 @@ import (
|
|||||||
// holds type information (inputs) about the yielded output. Anonymous events
|
// holds type information (inputs) about the yielded output. Anonymous events
|
||||||
// don't get the signature canonical representation as the first LOG topic.
|
// don't get the signature canonical representation as the first LOG topic.
|
||||||
type Event struct {
|
type Event struct {
|
||||||
Name string
|
// Name is the event name used for internal representation. It's derived from
|
||||||
|
// the raw name and a suffix will be added in the case of a event overload.
|
||||||
|
//
|
||||||
|
// e.g.
|
||||||
|
// There are two events have same name:
|
||||||
|
// * foo(int,int)
|
||||||
|
// * foo(uint,uint)
|
||||||
|
// The event name of the first one wll be resolved as foo while the second one
|
||||||
|
// will be resolved as foo0.
|
||||||
|
Name string
|
||||||
|
// RawName is the raw event name parsed from ABI.
|
||||||
|
RawName string
|
||||||
Anonymous bool
|
Anonymous bool
|
||||||
Inputs Arguments
|
Inputs Arguments
|
||||||
}
|
}
|
||||||
@@ -41,17 +52,26 @@ func (e Event) String() string {
|
|||||||
inputs[i] = fmt.Sprintf("%v indexed %v", input.Type, input.Name)
|
inputs[i] = fmt.Sprintf("%v indexed %v", input.Type, input.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("event %v(%v)", e.Name, strings.Join(inputs, ", "))
|
return fmt.Sprintf("event %v(%v)", e.RawName, strings.Join(inputs, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Id returns the canonical representation of the event's signature used by the
|
// Sig returns the event string signature according to the ABI spec.
|
||||||
// abi definition to identify event names and types.
|
//
|
||||||
func (e Event) Id() common.Hash {
|
// Example
|
||||||
|
//
|
||||||
|
// event foo(uint32 a, int b) = "foo(uint32,int256)"
|
||||||
|
//
|
||||||
|
// Please note that "int" is substitute for its canonical representation "int256"
|
||||||
|
func (e Event) Sig() string {
|
||||||
types := make([]string, len(e.Inputs))
|
types := make([]string, len(e.Inputs))
|
||||||
i := 0
|
for i, input := range e.Inputs {
|
||||||
for _, input := range e.Inputs {
|
|
||||||
types[i] = input.Type.String()
|
types[i] = input.Type.String()
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
return common.BytesToHash(crypto.Keccak256([]byte(fmt.Sprintf("%v(%v)", e.Name, strings.Join(types, ",")))))
|
return fmt.Sprintf("%v(%v)", e.RawName, strings.Join(types, ","))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID returns the canonical representation of the event's signature used by the
|
||||||
|
// abi definition to identify event names and types.
|
||||||
|
func (e Event) ID() common.Hash {
|
||||||
|
return common.BytesToHash(crypto.Keccak256([]byte(e.Sig())))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ func TestEventId(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for name, event := range abi.Events {
|
for name, event := range abi.Events {
|
||||||
if event.Id() != test.expectations[name] {
|
if event.ID() != test.expectations[name] {
|
||||||
t.Errorf("expected id to be %x, got %x", test.expectations[name], event.Id())
|
t.Errorf("expected id to be %x, got %x", test.expectations[name], event.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,23 @@ import (
|
|||||||
// If the method is `Const` no transaction needs to be created for this
|
// If the method is `Const` no transaction needs to be created for this
|
||||||
// particular Method call. It can easily be simulated using a local VM.
|
// particular Method call. It can easily be simulated using a local VM.
|
||||||
// For example a `Balance()` method only needs to retrieve something
|
// For example a `Balance()` method only needs to retrieve something
|
||||||
// from the storage and therefor requires no Tx to be send to the
|
// from the storage and therefore requires no Tx to be send to the
|
||||||
// network. A method such as `Transact` does require a Tx and thus will
|
// network. A method such as `Transact` does require a Tx and thus will
|
||||||
// be flagged `true`.
|
// be flagged `false`.
|
||||||
// Input specifies the required input parameters for this gives method.
|
// Input specifies the required input parameters for this gives method.
|
||||||
type Method struct {
|
type Method struct {
|
||||||
Name string
|
// Name is the method name used for internal representation. It's derived from
|
||||||
|
// the raw name and a suffix will be added in the case of a function overload.
|
||||||
|
//
|
||||||
|
// e.g.
|
||||||
|
// There are two functions have same name:
|
||||||
|
// * foo(int,int)
|
||||||
|
// * foo(uint,uint)
|
||||||
|
// The method name of the first one will be resolved as foo while the second one
|
||||||
|
// will be resolved as foo0.
|
||||||
|
Name string
|
||||||
|
// RawName is the raw method name parsed from ABI.
|
||||||
|
RawName string
|
||||||
Const bool
|
Const bool
|
||||||
Inputs Arguments
|
Inputs Arguments
|
||||||
Outputs Arguments
|
Outputs Arguments
|
||||||
@@ -42,7 +53,7 @@ type Method struct {
|
|||||||
//
|
//
|
||||||
// Example
|
// Example
|
||||||
//
|
//
|
||||||
// function foo(uint32 a, int b) = "foo(uint32,int256)"
|
// function foo(uint32 a, int b) = "foo(uint32,int256)"
|
||||||
//
|
//
|
||||||
// Please note that "int" is substitute for its canonical representation "int256"
|
// Please note that "int" is substitute for its canonical representation "int256"
|
||||||
func (method Method) Sig() string {
|
func (method Method) Sig() string {
|
||||||
@@ -50,7 +61,7 @@ func (method Method) Sig() string {
|
|||||||
for i, input := range method.Inputs {
|
for i, input := range method.Inputs {
|
||||||
types[i] = input.Type.String()
|
types[i] = input.Type.String()
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%v(%v)", method.Name, strings.Join(types, ","))
|
return fmt.Sprintf("%v(%v)", method.RawName, strings.Join(types, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (method Method) String() string {
|
func (method Method) String() string {
|
||||||
@@ -69,9 +80,11 @@ func (method Method) String() string {
|
|||||||
if method.Const {
|
if method.Const {
|
||||||
constant = "constant "
|
constant = "constant "
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("function %v(%v) %sreturns(%v)", method.Name, strings.Join(inputs, ", "), constant, strings.Join(outputs, ", "))
|
return fmt.Sprintf("function %v(%v) %sreturns(%v)", method.RawName, strings.Join(inputs, ", "), constant, strings.Join(outputs, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (method Method) Id() []byte {
|
// ID returns the canonical representation of the method's signature used by the
|
||||||
|
// abi definition to identify method names and types.
|
||||||
|
func (method Method) ID() []byte {
|
||||||
return crypto.Keccak256([]byte(method.Sig()))[:4]
|
return crypto.Keccak256([]byte(method.Sig()))[:4]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2016 The go-ethereum Authors
|
// Copyright 2018 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
@@ -23,9 +23,13 @@ import (
|
|||||||
|
|
||||||
const methoddata = `
|
const methoddata = `
|
||||||
[
|
[
|
||||||
{ "type" : "function", "name" : "balance", "constant" : true },
|
{"type": "function", "name": "balance", "constant": true },
|
||||||
{ "type" : "function", "name" : "send", "constant" : false, "inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
|
{"type": "function", "name": "send", "constant": false, "inputs": [{ "name": "amount", "type": "uint256" }]},
|
||||||
{ "type" : "function", "name" : "transfer", "constant" : false, "inputs" : [ { "name" : "from", "type" : "address" }, { "name" : "to", "type" : "address" }, { "name" : "value", "type" : "uint256" } ], "outputs" : [ { "name" : "success", "type" : "bool" } ] }
|
{"type": "function", "name": "transfer", "constant": false, "inputs": [{"name": "from", "type": "address"}, {"name": "to", "type": "address"}, {"name": "value", "type": "uint256"}], "outputs": [{"name": "success", "type": "bool"}]},
|
||||||
|
{"constant":false,"inputs":[{"components":[{"name":"x","type":"uint256"},{"name":"y","type":"uint256"}],"name":"a","type":"tuple"}],"name":"tuple","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},
|
||||||
|
{"constant":false,"inputs":[{"components":[{"name":"x","type":"uint256"},{"name":"y","type":"uint256"}],"name":"a","type":"tuple[]"}],"name":"tupleSlice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},
|
||||||
|
{"constant":false,"inputs":[{"components":[{"name":"x","type":"uint256"},{"name":"y","type":"uint256"}],"name":"a","type":"tuple[5]"}],"name":"tupleArray","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},
|
||||||
|
{"constant":false,"inputs":[{"components":[{"name":"x","type":"uint256"},{"name":"y","type":"uint256"}],"name":"a","type":"tuple[5][]"}],"name":"complexTuple","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}
|
||||||
]`
|
]`
|
||||||
|
|
||||||
func TestMethodString(t *testing.T) {
|
func TestMethodString(t *testing.T) {
|
||||||
@@ -45,6 +49,22 @@ func TestMethodString(t *testing.T) {
|
|||||||
method: "transfer",
|
method: "transfer",
|
||||||
expectation: "function transfer(address from, address to, uint256 value) returns(bool success)",
|
expectation: "function transfer(address from, address to, uint256 value) returns(bool success)",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
method: "tuple",
|
||||||
|
expectation: "function tuple((uint256,uint256) a) returns()",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "tupleArray",
|
||||||
|
expectation: "function tupleArray((uint256,uint256)[5] a) returns()",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "tupleSlice",
|
||||||
|
expectation: "function tupleSlice((uint256,uint256)[] a) returns()",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "complexTuple",
|
||||||
|
expectation: "function complexTuple((uint256,uint256)[5][] a) returns()",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
abi, err := JSON(strings.NewReader(methoddata))
|
abi, err := JSON(strings.NewReader(methoddata))
|
||||||
@@ -59,3 +79,50 @@ func TestMethodString(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMethodSig(t *testing.T) {
|
||||||
|
var cases = []struct {
|
||||||
|
method string
|
||||||
|
expect string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
method: "balance",
|
||||||
|
expect: "balance()",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "send",
|
||||||
|
expect: "send(uint256)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "transfer",
|
||||||
|
expect: "transfer(address,address,uint256)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "tuple",
|
||||||
|
expect: "tuple((uint256,uint256))",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "tupleArray",
|
||||||
|
expect: "tupleArray((uint256,uint256)[5])",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "tupleSlice",
|
||||||
|
expect: "tupleSlice((uint256,uint256)[])",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
method: "complexTuple",
|
||||||
|
expect: "complexTuple((uint256,uint256)[5][])",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
abi, err := JSON(strings.NewReader(methoddata))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range cases {
|
||||||
|
got := abi.Methods[test.method].Sig()
|
||||||
|
if got != test.expect {
|
||||||
|
t.Errorf("expected string to be %s, got %s", test.expect, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sig := abi.Methods["slice"].Id()
|
sig := abi.Methods["slice"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
||||||
|
|
||||||
@@ -648,7 +648,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var addrA, addrB = common.Address{1}, common.Address{2}
|
var addrA, addrB = common.Address{1}, common.Address{2}
|
||||||
sig = abi.Methods["sliceAddress"].Id()
|
sig = abi.Methods["sliceAddress"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{32}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{32}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes(addrA[:], 32)...)
|
sig = append(sig, common.LeftPadBytes(addrA[:], 32)...)
|
||||||
@@ -663,7 +663,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var addrC, addrD = common.Address{3}, common.Address{4}
|
var addrC, addrD = common.Address{3}, common.Address{4}
|
||||||
sig = abi.Methods["sliceMultiAddress"].Id()
|
sig = abi.Methods["sliceMultiAddress"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{64}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{64}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{160}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{160}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
||||||
@@ -681,7 +681,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
t.Errorf("expected %x got %x", sig, packed)
|
t.Errorf("expected %x got %x", sig, packed)
|
||||||
}
|
}
|
||||||
|
|
||||||
sig = abi.Methods["slice256"].Id()
|
sig = abi.Methods["slice256"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
||||||
|
|
||||||
@@ -695,7 +695,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a := [2][2]*big.Int{{big.NewInt(1), big.NewInt(1)}, {big.NewInt(2), big.NewInt(0)}}
|
a := [2][2]*big.Int{{big.NewInt(1), big.NewInt(1)}, {big.NewInt(2), big.NewInt(0)}}
|
||||||
sig = abi.Methods["nestedArray"].Id()
|
sig = abi.Methods["nestedArray"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)
|
||||||
@@ -712,7 +712,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
t.Errorf("expected %x got %x", sig, packed)
|
t.Errorf("expected %x got %x", sig, packed)
|
||||||
}
|
}
|
||||||
|
|
||||||
sig = abi.Methods["nestedArray2"].Id()
|
sig = abi.Methods["nestedArray2"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{0x20}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{0x20}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{0x40}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{0x40}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{0x80}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{0x80}, 32)...)
|
||||||
@@ -728,7 +728,7 @@ func TestMethodPack(t *testing.T) {
|
|||||||
t.Errorf("expected %x got %x", sig, packed)
|
t.Errorf("expected %x got %x", sig, packed)
|
||||||
}
|
}
|
||||||
|
|
||||||
sig = abi.Methods["nestedSlice"].Id()
|
sig = abi.Methods["nestedSlice"].ID()
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{0x20}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{0x20}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{0x02}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{0x02}, 32)...)
|
||||||
sig = append(sig, common.LeftPadBytes([]byte{0x40}, 32)...)
|
sig = append(sig, common.LeftPadBytes([]byte{0x40}, 32)...)
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ func indirect(v reflect.Value) reflect.Value {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// indirectInterfaceOrPtr recursively dereferences the value until value is not interface.
|
||||||
|
func indirectInterfaceOrPtr(v reflect.Value) reflect.Value {
|
||||||
|
if (v.Kind() == reflect.Interface || v.Kind() == reflect.Ptr) && v.Elem().IsValid() {
|
||||||
|
return indirect(v.Elem())
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
// reflectIntKind returns the reflect using the given size and
|
// reflectIntKind returns the reflect using the given size and
|
||||||
// unsignedness.
|
// unsignedness.
|
||||||
func reflectIntKindAndType(unsigned bool, size int) (reflect.Kind, reflect.Type) {
|
func reflectIntKindAndType(unsigned bool, size int) (reflect.Kind, reflect.Type) {
|
||||||
@@ -74,7 +82,7 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
|||||||
func set(dst, src reflect.Value) error {
|
func set(dst, src reflect.Value) error {
|
||||||
dstType, srcType := dst.Type(), src.Type()
|
dstType, srcType := dst.Type(), src.Type()
|
||||||
switch {
|
switch {
|
||||||
case dstType.Kind() == reflect.Interface:
|
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid():
|
||||||
return set(dst.Elem(), src)
|
return set(dst.Elem(), src)
|
||||||
case dstType.Kind() == reflect.Ptr && dstType.Elem() != derefbigT:
|
case dstType.Kind() == reflect.Ptr && dstType.Elem() != derefbigT:
|
||||||
return set(dst.Elem(), src)
|
return set(dst.Elem(), src)
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ func NewType(t string, components []ArgumentMarshaling) (typ Type, err error) {
|
|||||||
if strings.Count(t, "[") != strings.Count(t, "]") {
|
if strings.Count(t, "[") != strings.Count(t, "]") {
|
||||||
return Type{}, fmt.Errorf("invalid arg type in abi")
|
return Type{}, fmt.Errorf("invalid arg type in abi")
|
||||||
}
|
}
|
||||||
|
|
||||||
typ.stringKind = t
|
typ.stringKind = t
|
||||||
|
|
||||||
// if there are brackets, get ready to go into slice/array mode and
|
// if there are brackets, get ready to go into slice/array mode and
|
||||||
@@ -92,9 +91,7 @@ func NewType(t string, components []ArgumentMarshaling) (typ Type, err error) {
|
|||||||
typ.Kind = reflect.Slice
|
typ.Kind = reflect.Slice
|
||||||
typ.Elem = &embeddedType
|
typ.Elem = &embeddedType
|
||||||
typ.Type = reflect.SliceOf(embeddedType.Type)
|
typ.Type = reflect.SliceOf(embeddedType.Type)
|
||||||
if embeddedType.T == TupleTy {
|
typ.stringKind = embeddedType.stringKind + sliced
|
||||||
typ.stringKind = embeddedType.stringKind + sliced
|
|
||||||
}
|
|
||||||
} else if len(intz) == 1 {
|
} else if len(intz) == 1 {
|
||||||
// is a array
|
// is a array
|
||||||
typ.T = ArrayTy
|
typ.T = ArrayTy
|
||||||
@@ -105,9 +102,7 @@ func NewType(t string, components []ArgumentMarshaling) (typ Type, err error) {
|
|||||||
return Type{}, fmt.Errorf("abi: error parsing variable size: %v", err)
|
return Type{}, fmt.Errorf("abi: error parsing variable size: %v", err)
|
||||||
}
|
}
|
||||||
typ.Type = reflect.ArrayOf(typ.Size, embeddedType.Type)
|
typ.Type = reflect.ArrayOf(typ.Size, embeddedType.Type)
|
||||||
if embeddedType.T == TupleTy {
|
typ.stringKind = embeddedType.stringKind + sliced
|
||||||
typ.stringKind = embeddedType.stringKind + sliced
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return Type{}, fmt.Errorf("invalid formatting of array type")
|
return Type{}, fmt.Errorf("invalid formatting of array type")
|
||||||
}
|
}
|
||||||
@@ -188,6 +183,7 @@ func NewType(t string, components []ArgumentMarshaling) (typ Type, err error) {
|
|||||||
fields = append(fields, reflect.StructField{
|
fields = append(fields, reflect.StructField{
|
||||||
Name: ToCamelCase(c.Name), // reflect.StructOf will panic for any exported field.
|
Name: ToCamelCase(c.Name), // reflect.StructOf will panic for any exported field.
|
||||||
Type: cType.Type,
|
Type: cType.Type,
|
||||||
|
Tag: reflect.StructTag("json:\"" + c.Name + "\""),
|
||||||
})
|
})
|
||||||
elems = append(elems, &cType)
|
elems = append(elems, &cType)
|
||||||
names = append(names, c.Name)
|
names = append(names, c.Name)
|
||||||
|
|||||||
@@ -95,8 +95,14 @@ func TestTypeRegexp(t *testing.T) {
|
|||||||
// {"fixed[2]", nil, Type{}},
|
// {"fixed[2]", nil, Type{}},
|
||||||
// {"fixed128x128[]", nil, Type{}},
|
// {"fixed128x128[]", nil, Type{}},
|
||||||
// {"fixed128x128[2]", nil, Type{}},
|
// {"fixed128x128[2]", nil, Type{}},
|
||||||
{"tuple", []ArgumentMarshaling{{Name: "a", Type: "int64"}}, Type{Kind: reflect.Struct, T: TupleTy, Type: reflect.TypeOf(struct{ A int64 }{}), stringKind: "(int64)",
|
{"tuple", []ArgumentMarshaling{{Name: "a", Type: "int64"}}, Type{Kind: reflect.Struct, T: TupleTy, Type: reflect.TypeOf(struct {
|
||||||
|
A int64 `json:"a"`
|
||||||
|
}{}), stringKind: "(int64)",
|
||||||
TupleElems: []*Type{{Kind: reflect.Int64, T: IntTy, Type: reflect.TypeOf(int64(0)), Size: 64, stringKind: "int64"}}, TupleRawNames: []string{"a"}}},
|
TupleElems: []*Type{{Kind: reflect.Int64, T: IntTy, Type: reflect.TypeOf(int64(0)), Size: 64, stringKind: "int64"}}, TupleRawNames: []string{"a"}}},
|
||||||
|
{"tuple with long name", []ArgumentMarshaling{{Name: "aTypicalParamName", Type: "int64"}}, Type{Kind: reflect.Struct, T: TupleTy, Type: reflect.TypeOf(struct {
|
||||||
|
ATypicalParamName int64 `json:"aTypicalParamName"`
|
||||||
|
}{}), stringKind: "(int64)",
|
||||||
|
TupleElems: []*Type{{Kind: reflect.Int64, T: IntTy, Type: reflect.TypeOf(int64(0)), Size: 64, stringKind: "int64"}}, TupleRawNames: []string{"aTypicalParamName"}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err
|
|||||||
totalSize.Add(totalSize, bigOffsetEnd)
|
totalSize.Add(totalSize, bigOffsetEnd)
|
||||||
totalSize.Add(totalSize, lengthBig)
|
totalSize.Add(totalSize, lengthBig)
|
||||||
if totalSize.BitLen() > 63 {
|
if totalSize.BitLen() > 63 {
|
||||||
return 0, 0, fmt.Errorf("abi length larger than int64: %v", totalSize)
|
return 0, 0, fmt.Errorf("abi: length larger than int64: %v", totalSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if totalSize.Cmp(outputLength) > 0 {
|
if totalSize.Cmp(outputLength) > 0 {
|
||||||
|
|||||||
@@ -512,6 +512,11 @@ func TestMethodMultiReturn(t *testing.T) {
|
|||||||
Int *big.Int
|
Int *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newInterfaceSlice := func(len int) interface{} {
|
||||||
|
slice := make([]interface{}, len)
|
||||||
|
return &slice
|
||||||
|
}
|
||||||
|
|
||||||
abi, data, expected := methodMultiReturn(require.New(t))
|
abi, data, expected := methodMultiReturn(require.New(t))
|
||||||
bigint := new(big.Int)
|
bigint := new(big.Int)
|
||||||
var testCases = []struct {
|
var testCases = []struct {
|
||||||
@@ -539,6 +544,16 @@ func TestMethodMultiReturn(t *testing.T) {
|
|||||||
&[2]interface{}{&expected.Int, &expected.String},
|
&[2]interface{}{&expected.Int, &expected.String},
|
||||||
"",
|
"",
|
||||||
"Can unpack into an array",
|
"Can unpack into an array",
|
||||||
|
}, {
|
||||||
|
&[2]interface{}{},
|
||||||
|
&[2]interface{}{expected.Int, expected.String},
|
||||||
|
"",
|
||||||
|
"Can unpack into interface array",
|
||||||
|
}, {
|
||||||
|
newInterfaceSlice(2),
|
||||||
|
&[]interface{}{expected.Int, expected.String},
|
||||||
|
"",
|
||||||
|
"Can unpack into interface slice",
|
||||||
}, {
|
}, {
|
||||||
&[]interface{}{new(int), new(int)},
|
&[]interface{}{new(int), new(int)},
|
||||||
&[]interface{}{&expected.Int, &expected.String},
|
&[]interface{}{&expected.Int, &expected.String},
|
||||||
@@ -950,25 +965,21 @@ func TestUnpackTuple(t *testing.T) {
|
|||||||
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001")) // ret[a] = 1
|
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001")) // ret[a] = 1
|
||||||
buff.Write(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) // ret[b] = -1
|
buff.Write(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) // ret[b] = -1
|
||||||
|
|
||||||
|
// If the result is single tuple, use struct as return value container directly.
|
||||||
v := struct {
|
v := struct {
|
||||||
Ret struct {
|
|
||||||
A *big.Int
|
|
||||||
B *big.Int
|
|
||||||
}
|
|
||||||
}{Ret: struct {
|
|
||||||
A *big.Int
|
A *big.Int
|
||||||
B *big.Int
|
B *big.Int
|
||||||
}{new(big.Int), new(big.Int)}}
|
}{new(big.Int), new(big.Int)}
|
||||||
|
|
||||||
err = abi.Unpack(&v, "tuple", buff.Bytes())
|
err = abi.Unpack(&v, "tuple", buff.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
} else {
|
} else {
|
||||||
if v.Ret.A.Cmp(big.NewInt(1)) != 0 {
|
if v.A.Cmp(big.NewInt(1)) != 0 {
|
||||||
t.Errorf("unexpected value unpacked: want %x, got %x", 1, v.Ret.A)
|
t.Errorf("unexpected value unpacked: want %x, got %x", 1, v.A)
|
||||||
}
|
}
|
||||||
if v.Ret.B.Cmp(big.NewInt(-1)) != 0 {
|
if v.B.Cmp(big.NewInt(-1)) != 0 {
|
||||||
t.Errorf("unexpected value unpacked: want %x, got %x", v.Ret.B, -1)
|
t.Errorf("unexpected value unpacked: want %x, got %x", v.B, -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
package accounts
|
package accounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
"golang.org/x/crypto/sha3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Account represents an Ethereum account located at a specific location defined
|
// Account represents an Ethereum account located at a specific location defined
|
||||||
@@ -33,6 +35,13 @@ type Account struct {
|
|||||||
URL URL `json:"url"` // Optional resource locator within a backend
|
URL URL `json:"url"` // Optional resource locator within a backend
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
MimetypeDataWithValidator = "data/validator"
|
||||||
|
MimetypeTypedData = "data/typed"
|
||||||
|
MimetypeClique = "application/x-clique-header"
|
||||||
|
MimetypeTextPlain = "text/plain"
|
||||||
|
)
|
||||||
|
|
||||||
// Wallet represents a software or hardware wallet that might contain one or more
|
// Wallet represents a software or hardware wallet that might contain one or more
|
||||||
// accounts (derived from the same seed).
|
// accounts (derived from the same seed).
|
||||||
type Wallet interface {
|
type Wallet interface {
|
||||||
@@ -83,12 +92,34 @@ type Wallet interface {
|
|||||||
// opposed to decending into a child path to allow discovering accounts starting
|
// opposed to decending into a child path to allow discovering accounts starting
|
||||||
// from non zero components.
|
// from non zero components.
|
||||||
//
|
//
|
||||||
|
// Some hardware wallets switched derivation paths through their evolution, so
|
||||||
|
// this method supports providing multiple bases to discover old user accounts
|
||||||
|
// too. Only the last base will be used to derive the next empty account.
|
||||||
|
//
|
||||||
// You can disable automatic account discovery by calling SelfDerive with a nil
|
// You can disable automatic account discovery by calling SelfDerive with a nil
|
||||||
// chain state reader.
|
// chain state reader.
|
||||||
SelfDerive(base DerivationPath, chain ethereum.ChainStateReader)
|
SelfDerive(bases []DerivationPath, chain ethereum.ChainStateReader)
|
||||||
|
|
||||||
// SignHash requests the wallet to sign the given hash.
|
// SignData requests the wallet to sign the hash of the given data
|
||||||
|
// It looks up the account specified either solely via its address contained within,
|
||||||
|
// or optionally with the aid of any location metadata from the embedded URL field.
|
||||||
//
|
//
|
||||||
|
// If the wallet requires additional authentication to sign the request (e.g.
|
||||||
|
// a password to decrypt the account, or a PIN code o verify the transaction),
|
||||||
|
// an AuthNeededError instance will be returned, containing infos for the user
|
||||||
|
// about which fields or actions are needed. The user may retry by providing
|
||||||
|
// the needed details via SignDataWithPassphrase, or by other means (e.g. unlock
|
||||||
|
// the account in a keystore).
|
||||||
|
SignData(account Account, mimeType string, data []byte) ([]byte, error)
|
||||||
|
|
||||||
|
// SignDataWithPassphrase is identical to SignData, but also takes a password
|
||||||
|
// NOTE: there's an chance that an erroneous call might mistake the two strings, and
|
||||||
|
// supply password in the mimetype field, or vice versa. Thus, an implementation
|
||||||
|
// should never echo the mimetype or return the mimetype in the error-response
|
||||||
|
SignDataWithPassphrase(account Account, passphrase, mimeType string, data []byte) ([]byte, error)
|
||||||
|
|
||||||
|
// SignText requests the wallet to sign the hash of a given piece of data, prefixed
|
||||||
|
// by the Ethereum prefix scheme
|
||||||
// It looks up the account specified either solely via its address contained within,
|
// It looks up the account specified either solely via its address contained within,
|
||||||
// or optionally with the aid of any location metadata from the embedded URL field.
|
// or optionally with the aid of any location metadata from the embedded URL field.
|
||||||
//
|
//
|
||||||
@@ -98,7 +129,10 @@ type Wallet interface {
|
|||||||
// about which fields or actions are needed. The user may retry by providing
|
// about which fields or actions are needed. The user may retry by providing
|
||||||
// the needed details via SignHashWithPassphrase, or by other means (e.g. unlock
|
// the needed details via SignHashWithPassphrase, or by other means (e.g. unlock
|
||||||
// the account in a keystore).
|
// the account in a keystore).
|
||||||
SignHash(account Account, hash []byte) ([]byte, error)
|
SignText(account Account, text []byte) ([]byte, error)
|
||||||
|
|
||||||
|
// SignTextWithPassphrase is identical to Signtext, but also takes a password
|
||||||
|
SignTextWithPassphrase(account Account, passphrase string, hash []byte) ([]byte, error)
|
||||||
|
|
||||||
// SignTx requests the wallet to sign the given transaction.
|
// SignTx requests the wallet to sign the given transaction.
|
||||||
//
|
//
|
||||||
@@ -113,18 +147,7 @@ type Wallet interface {
|
|||||||
// the account in a keystore).
|
// the account in a keystore).
|
||||||
SignTx(account Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
|
SignTx(account Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
|
||||||
|
|
||||||
// SignHashWithPassphrase requests the wallet to sign the given hash with the
|
// SignTxWithPassphrase is identical to SignTx, but also takes a password
|
||||||
// given passphrase as extra authentication information.
|
|
||||||
//
|
|
||||||
// It looks up the account specified either solely via its address contained within,
|
|
||||||
// or optionally with the aid of any location metadata from the embedded URL field.
|
|
||||||
SignHashWithPassphrase(account Account, passphrase string, hash []byte) ([]byte, error)
|
|
||||||
|
|
||||||
// SignTxWithPassphrase requests the wallet to sign the given transaction, with the
|
|
||||||
// given passphrase as extra authentication information.
|
|
||||||
//
|
|
||||||
// It looks up the account specified either solely via its address contained within,
|
|
||||||
// or optionally with the aid of any location metadata from the embedded URL field.
|
|
||||||
SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
|
SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +171,32 @@ type Backend interface {
|
|||||||
Subscribe(sink chan<- WalletEvent) event.Subscription
|
Subscribe(sink chan<- WalletEvent) event.Subscription
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TextHash is a helper function that calculates a hash for the given message that can be
|
||||||
|
// safely used to calculate a signature from.
|
||||||
|
//
|
||||||
|
// The hash is calulcated as
|
||||||
|
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||||
|
//
|
||||||
|
// This gives context to the signed message and prevents signing of transactions.
|
||||||
|
func TextHash(data []byte) []byte {
|
||||||
|
hash, _ := TextAndHash(data)
|
||||||
|
return hash
|
||||||
|
}
|
||||||
|
|
||||||
|
// TextAndHash is a helper function that calculates a hash for the given message that can be
|
||||||
|
// safely used to calculate a signature from.
|
||||||
|
//
|
||||||
|
// The hash is calulcated as
|
||||||
|
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
|
||||||
|
//
|
||||||
|
// This gives context to the signed message and prevents signing of transactions.
|
||||||
|
func TextAndHash(data []byte) ([]byte, string) {
|
||||||
|
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), string(data))
|
||||||
|
hasher := sha3.NewLegacyKeccak256()
|
||||||
|
hasher.Write([]byte(msg))
|
||||||
|
return hasher.Sum(nil), msg
|
||||||
|
}
|
||||||
|
|
||||||
// WalletEventType represents the different event types that can be fired by
|
// WalletEventType represents the different event types that can be fired by
|
||||||
// the wallet subscription subsystem.
|
// the wallet subscription subsystem.
|
||||||
type WalletEventType int
|
type WalletEventType int
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2018 The go-ethereum Authors
|
// Copyright 2015 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
@@ -14,24 +14,19 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package storage
|
package accounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"bytes"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
func TestTextHash(t *testing.T) {
|
||||||
ErrInit = iota
|
hash := TextHash([]byte("Hello Joe"))
|
||||||
ErrNotFound
|
want := hexutil.MustDecode("0xa080337ae51c4e064c189e113edd0ba391df9206e2f49db658bb32cf2911730b")
|
||||||
ErrUnauthorized
|
if !bytes.Equal(hash, want) {
|
||||||
ErrInvalidValue
|
t.Fatalf("wrong hash: %x", hash)
|
||||||
ErrDataOverflow
|
}
|
||||||
ErrNothingToReturn
|
}
|
||||||
ErrInvalidSignature
|
|
||||||
ErrNotSynced
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrChunkNotFound = errors.New("chunk not found")
|
|
||||||
ErrChunkInvalid = errors.New("invalid chunk")
|
|
||||||
)
|
|
||||||
@@ -35,7 +35,7 @@ var ErrNotSupported = errors.New("not supported")
|
|||||||
|
|
||||||
// ErrInvalidPassphrase is returned when a decryption operation receives a bad
|
// ErrInvalidPassphrase is returned when a decryption operation receives a bad
|
||||||
// passphrase.
|
// passphrase.
|
||||||
var ErrInvalidPassphrase = errors.New("invalid passphrase")
|
var ErrInvalidPassphrase = errors.New("invalid password")
|
||||||
|
|
||||||
// ErrWalletAlreadyOpen is returned if a wallet is attempted to be opened the
|
// ErrWalletAlreadyOpen is returned if a wallet is attempted to be opened the
|
||||||
// second time.
|
// second time.
|
||||||
|
|||||||
231
accounts/external/backend.go
vendored
Normal file
231
accounts/external/backend.go
vendored
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package external
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/signer/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ExternalBackend struct {
|
||||||
|
signers []accounts.Wallet
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eb *ExternalBackend) Wallets() []accounts.Wallet {
|
||||||
|
return eb.signers
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewExternalBackend(endpoint string) (*ExternalBackend, error) {
|
||||||
|
signer, err := NewExternalSigner(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &ExternalBackend{
|
||||||
|
signers: []accounts.Wallet{signer},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eb *ExternalBackend) Subscribe(sink chan<- accounts.WalletEvent) event.Subscription {
|
||||||
|
return event.NewSubscription(func(quit <-chan struct{}) error {
|
||||||
|
<-quit
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExternalSigner provides an API to interact with an external signer (clef)
|
||||||
|
// It proxies request to the external signer while forwarding relevant
|
||||||
|
// request headers
|
||||||
|
type ExternalSigner struct {
|
||||||
|
client *rpc.Client
|
||||||
|
endpoint string
|
||||||
|
status string
|
||||||
|
cacheMu sync.RWMutex
|
||||||
|
cache []accounts.Account
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewExternalSigner(endpoint string) (*ExternalSigner, error) {
|
||||||
|
client, err := rpc.Dial(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
extsigner := &ExternalSigner{
|
||||||
|
client: client,
|
||||||
|
endpoint: endpoint,
|
||||||
|
}
|
||||||
|
// Check if reachable
|
||||||
|
version, err := extsigner.pingVersion()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
extsigner.status = fmt.Sprintf("ok [version=%v]", version)
|
||||||
|
return extsigner, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) URL() accounts.URL {
|
||||||
|
return accounts.URL{
|
||||||
|
Scheme: "extapi",
|
||||||
|
Path: api.endpoint,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) Status() (string, error) {
|
||||||
|
return api.status, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) Open(passphrase string) error {
|
||||||
|
return fmt.Errorf("operation not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) Close() error {
|
||||||
|
return fmt.Errorf("operation not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) Accounts() []accounts.Account {
|
||||||
|
var accnts []accounts.Account
|
||||||
|
res, err := api.listAccounts()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("account listing failed", "error", err)
|
||||||
|
return accnts
|
||||||
|
}
|
||||||
|
for _, addr := range res {
|
||||||
|
accnts = append(accnts, accounts.Account{
|
||||||
|
URL: accounts.URL{
|
||||||
|
Scheme: "extapi",
|
||||||
|
Path: api.endpoint,
|
||||||
|
},
|
||||||
|
Address: addr,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
api.cacheMu.Lock()
|
||||||
|
api.cache = accnts
|
||||||
|
api.cacheMu.Unlock()
|
||||||
|
return accnts
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) Contains(account accounts.Account) bool {
|
||||||
|
api.cacheMu.RLock()
|
||||||
|
defer api.cacheMu.RUnlock()
|
||||||
|
for _, a := range api.cache {
|
||||||
|
if a.Address == account.Address && (account.URL == (accounts.URL{}) || account.URL == api.URL()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error) {
|
||||||
|
return accounts.Account{}, fmt.Errorf("operation not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader) {
|
||||||
|
log.Error("operation SelfDerive not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) signHash(account accounts.Account, hash []byte) ([]byte, error) {
|
||||||
|
return []byte{}, fmt.Errorf("operation not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
||||||
|
func (api *ExternalSigner) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
||||||
|
var res hexutil.Bytes
|
||||||
|
var signAddress = common.NewMixedcaseAddress(account.Address)
|
||||||
|
if err := api.client.Call(&res, "account_signData",
|
||||||
|
mimeType,
|
||||||
|
&signAddress, // Need to use the pointer here, because of how MarshalJSON is defined
|
||||||
|
hexutil.Encode(data)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// If V is on 27/28-form, convert to to 0/1 for Clique
|
||||||
|
if mimeType == accounts.MimetypeClique && (res[64] == 27 || res[64] == 28) {
|
||||||
|
res[64] -= 27 // Transform V from 27/28 to 0/1 for Clique use
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) SignText(account accounts.Account, text []byte) ([]byte, error) {
|
||||||
|
var res hexutil.Bytes
|
||||||
|
var signAddress = common.NewMixedcaseAddress(account.Address)
|
||||||
|
if err := api.client.Call(&res, "account_signData",
|
||||||
|
accounts.MimetypeTextPlain,
|
||||||
|
&signAddress, // Need to use the pointer here, because of how MarshalJSON is defined
|
||||||
|
hexutil.Encode(text)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
||||||
|
res := ethapi.SignTransactionResult{}
|
||||||
|
data := hexutil.Bytes(tx.Data())
|
||||||
|
var to *common.MixedcaseAddress
|
||||||
|
if tx.To() != nil {
|
||||||
|
t := common.NewMixedcaseAddress(*tx.To())
|
||||||
|
to = &t
|
||||||
|
}
|
||||||
|
args := &core.SendTxArgs{
|
||||||
|
Data: &data,
|
||||||
|
Nonce: hexutil.Uint64(tx.Nonce()),
|
||||||
|
Value: hexutil.Big(*tx.Value()),
|
||||||
|
Gas: hexutil.Uint64(tx.Gas()),
|
||||||
|
GasPrice: hexutil.Big(*tx.GasPrice()),
|
||||||
|
To: to,
|
||||||
|
From: common.NewMixedcaseAddress(account.Address),
|
||||||
|
}
|
||||||
|
if err := api.client.Call(&res, "account_signTransaction", args); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return res.Tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
|
||||||
|
return []byte{}, fmt.Errorf("password-operations not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
||||||
|
return nil, fmt.Errorf("password-operations not supported on external signers")
|
||||||
|
}
|
||||||
|
func (api *ExternalSigner) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("password-operations not supported on external signers")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) listAccounts() ([]common.Address, error) {
|
||||||
|
var res []common.Address
|
||||||
|
if err := api.client.Call(&res, "account_list"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *ExternalSigner) pingVersion() (string, error) {
|
||||||
|
var v string
|
||||||
|
if err := api.client.Call(&v, "account_version"); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
package accounts
|
package accounts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
@@ -34,10 +35,10 @@ var DefaultRootDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60,
|
|||||||
// at m/44'/60'/0'/0/1, etc.
|
// at m/44'/60'/0'/0/1, etc.
|
||||||
var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0, 0}
|
var DefaultBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0, 0}
|
||||||
|
|
||||||
// DefaultLedgerBaseDerivationPath is the base path from which custom derivation endpoints
|
// LegacyLedgerBaseDerivationPath is the legacy base path from which custom derivation
|
||||||
// are incremented. As such, the first account will be at m/44'/60'/0'/0, the second
|
// endpoints are incremented. As such, the first account will be at m/44'/60'/0'/0, the
|
||||||
// at m/44'/60'/0'/1, etc.
|
// second at m/44'/60'/0'/1, etc.
|
||||||
var DefaultLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
var LegacyLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000 + 60, 0x80000000 + 0, 0}
|
||||||
|
|
||||||
// DerivationPath represents the computer friendly version of a hierarchical
|
// DerivationPath represents the computer friendly version of a hierarchical
|
||||||
// deterministic wallet account derivaion path.
|
// deterministic wallet account derivaion path.
|
||||||
@@ -133,3 +134,19 @@ func (path DerivationPath) String() string {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON turns a derivation path into its json-serialized string
|
||||||
|
func (path DerivationPath) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(path.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON a json-serialized string back into a derivation path
|
||||||
|
func (path *DerivationPath) UnmarshalJSON(b []byte) error {
|
||||||
|
var dp string
|
||||||
|
var err error
|
||||||
|
if err = json.Unmarshal(b, &dp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*path, err = ParseDerivationPath(dp)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
ErrLocked = accounts.NewAuthNeededError("password or unlock")
|
ErrLocked = accounts.NewAuthNeededError("password or unlock")
|
||||||
ErrNoMatch = errors.New("no key for given address or file")
|
ErrNoMatch = errors.New("no key for given address or file")
|
||||||
ErrDecrypt = errors.New("could not decrypt key with given passphrase")
|
ErrDecrypt = errors.New("could not decrypt key with given password")
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeyStoreType is the reflect type of a keystore backend.
|
// KeyStoreType is the reflect type of a keystore backend.
|
||||||
@@ -137,8 +137,10 @@ func (ks *KeyStore) refreshWallets() {
|
|||||||
accs := ks.cache.accounts()
|
accs := ks.cache.accounts()
|
||||||
|
|
||||||
// Transform the current list of wallets into the new one
|
// Transform the current list of wallets into the new one
|
||||||
wallets := make([]accounts.Wallet, 0, len(accs))
|
var (
|
||||||
events := []accounts.WalletEvent{}
|
wallets = make([]accounts.Wallet, 0, len(accs))
|
||||||
|
events []accounts.WalletEvent
|
||||||
|
)
|
||||||
|
|
||||||
for _, account := range accs {
|
for _, account := range accs {
|
||||||
// Drop wallets while they were in front of the next account
|
// Drop wallets while they were in front of the next account
|
||||||
|
|||||||
@@ -379,9 +379,9 @@ func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
new := NewPlaintextKeyStore
|
newKs := NewPlaintextKeyStore
|
||||||
if encrypted {
|
if encrypted {
|
||||||
new = func(kd string) *KeyStore { return NewKeyStore(kd, veryLightScryptN, veryLightScryptP) }
|
newKs = func(kd string) *KeyStore { return NewKeyStore(kd, veryLightScryptN, veryLightScryptP) }
|
||||||
}
|
}
|
||||||
return d, new(d)
|
return d, newKs(d)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
@@ -97,9 +98,9 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
|
// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
|
||||||
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
|
func StoreKey(dir, auth string, scryptN, scryptP int) (accounts.Account, error) {
|
||||||
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP, false}, rand.Reader, auth)
|
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP, false}, rand.Reader, auth)
|
||||||
return a.Address, err
|
return a, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error {
|
func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func TestKeyStorePassphraseDecryptionFail(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if _, err = ks.GetKey(k1.Address, account.URL.Path, "bar"); err != ErrDecrypt {
|
if _, err = ks.GetKey(k1.Address, account.URL.Path, "bar"); err != ErrDecrypt {
|
||||||
t.Fatalf("wrong error for invalid passphrase\ngot %q\nwant %q", err, ErrDecrypt)
|
t.Fatalf("wrong error for invalid password\ngot %q\nwant %q", err, ErrDecrypt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
accounts/keystore/testdata/keystore/README
vendored
2
accounts/keystore/testdata/keystore/README
vendored
@@ -1,5 +1,5 @@
|
|||||||
This directory contains accounts for testing.
|
This directory contains accounts for testing.
|
||||||
The passphrase that unlocks them is "foobar".
|
The password that unlocks them is "foobar".
|
||||||
|
|
||||||
The "good" key files which are supposed to be loadable are:
|
The "good" key files which are supposed to be loadable are:
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
ethereum "github.com/ethereum/go-ethereum"
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// keystoreWallet implements the accounts.Wallet interface for the original
|
// keystoreWallet implements the accounts.Wallet interface for the original
|
||||||
@@ -76,13 +77,14 @@ func (w *keystoreWallet) Derive(path accounts.DerivationPath, pin bool) (account
|
|||||||
|
|
||||||
// SelfDerive implements accounts.Wallet, but is a noop for plain wallets since
|
// SelfDerive implements accounts.Wallet, but is a noop for plain wallets since
|
||||||
// there is no notion of hierarchical account derivation for plain keystore accounts.
|
// there is no notion of hierarchical account derivation for plain keystore accounts.
|
||||||
func (w *keystoreWallet) SelfDerive(base accounts.DerivationPath, chain ethereum.ChainStateReader) {}
|
func (w *keystoreWallet) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader) {
|
||||||
|
}
|
||||||
|
|
||||||
// SignHash implements accounts.Wallet, attempting to sign the given hash with
|
// signHash attempts to sign the given hash with
|
||||||
// the given account. If the wallet does not wrap this particular account, an
|
// the given account. If the wallet does not wrap this particular account, an
|
||||||
// error is returned to avoid account leakage (even though in theory we may be
|
// error is returned to avoid account leakage (even though in theory we may be
|
||||||
// able to sign via our shared keystore backend).
|
// able to sign via our shared keystore backend).
|
||||||
func (w *keystoreWallet) SignHash(account accounts.Account, hash []byte) ([]byte, error) {
|
func (w *keystoreWallet) signHash(account accounts.Account, hash []byte) ([]byte, error) {
|
||||||
// Make sure the requested account is contained within
|
// Make sure the requested account is contained within
|
||||||
if !w.Contains(account) {
|
if !w.Contains(account) {
|
||||||
return nil, accounts.ErrUnknownAccount
|
return nil, accounts.ErrUnknownAccount
|
||||||
@@ -91,6 +93,36 @@ func (w *keystoreWallet) SignHash(account accounts.Account, hash []byte) ([]byte
|
|||||||
return w.keystore.SignHash(account, hash)
|
return w.keystore.SignHash(account, hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
||||||
|
func (w *keystoreWallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
||||||
|
return w.signHash(account, crypto.Keccak256(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignDataWithPassphrase signs keccak256(data). The mimetype parameter describes the type of data being signed
|
||||||
|
func (w *keystoreWallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
|
||||||
|
// Make sure the requested account is contained within
|
||||||
|
if !w.Contains(account) {
|
||||||
|
return nil, accounts.ErrUnknownAccount
|
||||||
|
}
|
||||||
|
// Account seems valid, request the keystore to sign
|
||||||
|
return w.keystore.SignHashWithPassphrase(account, passphrase, crypto.Keccak256(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *keystoreWallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
|
||||||
|
return w.signHash(account, accounts.TextHash(text))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignTextWithPassphrase implements accounts.Wallet, attempting to sign the
|
||||||
|
// given hash with the given account using passphrase as extra authentication.
|
||||||
|
func (w *keystoreWallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
|
||||||
|
// Make sure the requested account is contained within
|
||||||
|
if !w.Contains(account) {
|
||||||
|
return nil, accounts.ErrUnknownAccount
|
||||||
|
}
|
||||||
|
// Account seems valid, request the keystore to sign
|
||||||
|
return w.keystore.SignHashWithPassphrase(account, passphrase, accounts.TextHash(text))
|
||||||
|
}
|
||||||
|
|
||||||
// SignTx implements accounts.Wallet, attempting to sign the given transaction
|
// SignTx implements accounts.Wallet, attempting to sign the given transaction
|
||||||
// with the given account. If the wallet does not wrap this particular account,
|
// with the given account. If the wallet does not wrap this particular account,
|
||||||
// an error is returned to avoid account leakage (even though in theory we may
|
// an error is returned to avoid account leakage (even though in theory we may
|
||||||
@@ -104,17 +136,6 @@ func (w *keystoreWallet) SignTx(account accounts.Account, tx *types.Transaction,
|
|||||||
return w.keystore.SignTx(account, tx, chainID)
|
return w.keystore.SignTx(account, tx, chainID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignHashWithPassphrase implements accounts.Wallet, attempting to sign the
|
|
||||||
// given hash with the given account using passphrase as extra authentication.
|
|
||||||
func (w *keystoreWallet) SignHashWithPassphrase(account accounts.Account, passphrase string, hash []byte) ([]byte, error) {
|
|
||||||
// Make sure the requested account is contained within
|
|
||||||
if !w.Contains(account) {
|
|
||||||
return nil, accounts.ErrUnknownAccount
|
|
||||||
}
|
|
||||||
// Account seems valid, request the keystore to sign
|
|
||||||
return w.keystore.SignHashWithPassphrase(account, passphrase, hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given
|
// SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given
|
||||||
// transaction with the given account using passphrase as extra authentication.
|
// transaction with the given account using passphrase as extra authentication.
|
||||||
func (w *keystoreWallet) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
func (w *keystoreWallet) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// +build darwin,!ios freebsd linux,!arm64 netbsd solaris
|
// +build darwin,!ios,cgo freebsd linux,!arm64 netbsd solaris
|
||||||
|
|
||||||
package keystore
|
package keystore
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// +build ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
|
// +build darwin,!cgo ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
|
||||||
|
|
||||||
// This is the fallback implementation of directory watching.
|
// This is the fallback implementation of directory watching.
|
||||||
// It is used on unsupported platforms.
|
// It is used on unsupported platforms.
|
||||||
|
|||||||
@@ -21,12 +21,22 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Config contains the settings of the global account manager.
|
||||||
|
//
|
||||||
|
// TODO(rjl493456442, karalabe, holiman): Get rid of this when account management
|
||||||
|
// is removed in favor of Clef.
|
||||||
|
type Config struct {
|
||||||
|
InsecureUnlockAllowed bool // Whether account unlocking in insecure environment is allowed
|
||||||
|
}
|
||||||
|
|
||||||
// Manager is an overarching account manager that can communicate with various
|
// Manager is an overarching account manager that can communicate with various
|
||||||
// backends for signing transactions.
|
// backends for signing transactions.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
|
config *Config // Global account manager configurations
|
||||||
backends map[reflect.Type][]Backend // Index of backends currently registered
|
backends map[reflect.Type][]Backend // Index of backends currently registered
|
||||||
updaters []event.Subscription // Wallet update subscriptions for all backends
|
updaters []event.Subscription // Wallet update subscriptions for all backends
|
||||||
updates chan WalletEvent // Subscription sink for backend wallet changes
|
updates chan WalletEvent // Subscription sink for backend wallet changes
|
||||||
@@ -40,7 +50,7 @@ type Manager struct {
|
|||||||
|
|
||||||
// NewManager creates a generic account manager to sign transaction via various
|
// NewManager creates a generic account manager to sign transaction via various
|
||||||
// supported backends.
|
// supported backends.
|
||||||
func NewManager(backends ...Backend) *Manager {
|
func NewManager(config *Config, backends ...Backend) *Manager {
|
||||||
// Retrieve the initial list of wallets from the backends and sort by URL
|
// Retrieve the initial list of wallets from the backends and sort by URL
|
||||||
var wallets []Wallet
|
var wallets []Wallet
|
||||||
for _, backend := range backends {
|
for _, backend := range backends {
|
||||||
@@ -55,6 +65,7 @@ func NewManager(backends ...Backend) *Manager {
|
|||||||
}
|
}
|
||||||
// Assemble the account manager and return
|
// Assemble the account manager and return
|
||||||
am := &Manager{
|
am := &Manager{
|
||||||
|
config: config,
|
||||||
backends: make(map[reflect.Type][]Backend),
|
backends: make(map[reflect.Type][]Backend),
|
||||||
updaters: subs,
|
updaters: subs,
|
||||||
updates: updates,
|
updates: updates,
|
||||||
@@ -77,6 +88,11 @@ func (am *Manager) Close() error {
|
|||||||
return <-errc
|
return <-errc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config returns the configuration of account manager.
|
||||||
|
func (am *Manager) Config() *Config {
|
||||||
|
return am.config
|
||||||
|
}
|
||||||
|
|
||||||
// update is the wallet event loop listening for notifications from the backends
|
// update is the wallet event loop listening for notifications from the backends
|
||||||
// and updating the cache of wallets.
|
// and updating the cache of wallets.
|
||||||
func (am *Manager) update() {
|
func (am *Manager) update() {
|
||||||
@@ -147,6 +163,20 @@ func (am *Manager) Wallet(url string) (Wallet, error) {
|
|||||||
return nil, ErrUnknownWallet
|
return nil, ErrUnknownWallet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Accounts returns all account addresses of all wallets within the account manager
|
||||||
|
func (am *Manager) Accounts() []common.Address {
|
||||||
|
am.lock.RLock()
|
||||||
|
defer am.lock.RUnlock()
|
||||||
|
|
||||||
|
addresses := make([]common.Address, 0) // return [] instead of nil if empty
|
||||||
|
for _, wallet := range am.wallets {
|
||||||
|
for _, account := range wallet.Accounts() {
|
||||||
|
addresses = append(addresses, account.Address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addresses
|
||||||
|
}
|
||||||
|
|
||||||
// Find attempts to locate the wallet corresponding to a specific account. Since
|
// Find attempts to locate the wallet corresponding to a specific account. Since
|
||||||
// accounts can be dynamically added to and removed from wallets, this method has
|
// accounts can be dynamically added to and removed from wallets, this method has
|
||||||
// a linear runtime in the number of wallets.
|
// a linear runtime in the number of wallets.
|
||||||
|
|||||||
102
accounts/scwallet/README.md
Normal file
102
accounts/scwallet/README.md
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
# Using the smartcard wallet
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
* A USB smartcard reader
|
||||||
|
* A keycard that supports the status app
|
||||||
|
* PCSCD version 4.3 running on your system **Only version 4.3 is currently supported**
|
||||||
|
|
||||||
|
## Preparing the smartcard
|
||||||
|
|
||||||
|
**WARNING: FOILLOWING THESE INSTRUCTIONS WILL DESTROY THE MASTER KEY ON YOUR CARD. ONLY PROCEED IF NO FUNDS ARE ASSOCIATED WITH THESE ACCOUNTS**
|
||||||
|
|
||||||
|
You can use status' [keycard-cli](https://github.com/status-im/keycard-cli) and you should get _at least_ version 2.1.1 of their [smartcard application](https://github.com/status-im/status-keycard/releases/download/2.2.1/keycard_v2.2.1.cap)
|
||||||
|
|
||||||
|
You also need to make sure that the PCSC daemon is running on your system.
|
||||||
|
|
||||||
|
Then, you can install the application to the card by typing:
|
||||||
|
|
||||||
|
```
|
||||||
|
keycard install -a keycard_v2.2.1.cap && keycard init
|
||||||
|
```
|
||||||
|
|
||||||
|
At the end of this process, you will be provided with a PIN, a PUK and a pairing password. Write them down, you'll need them shortly.
|
||||||
|
|
||||||
|
Start `geth` with the `console` command. You will notice the following warning:
|
||||||
|
|
||||||
|
```
|
||||||
|
WARN [04-09|16:58:38.898] Failed to open wallet url=keycard://044def09 err="smartcard: pairing password needed"
|
||||||
|
```
|
||||||
|
|
||||||
|
Write down the URL (`keycard://044def09` in this example). Then ask `geth` to open the wallet:
|
||||||
|
|
||||||
|
```
|
||||||
|
> personal.openWallet("keycard://044def09")
|
||||||
|
Please enter the pairing password:
|
||||||
|
```
|
||||||
|
|
||||||
|
Enter the pairing password that you have received during card initialization. Same with the PIN that you will subsequently be
|
||||||
|
asked for.
|
||||||
|
|
||||||
|
If everything goes well, you should see your new account when typing `personal` on the console:
|
||||||
|
|
||||||
|
```
|
||||||
|
> personal
|
||||||
|
WARN [04-09|17:02:07.330] Smartcard wallet account derivation failed url=keycard://044def09 err="Unexpected response status Cla=0x80, Ins=0xd1, Sw=0x6985"
|
||||||
|
{
|
||||||
|
listAccounts: [],
|
||||||
|
listWallets: [{
|
||||||
|
status: "Empty, waiting for initialization",
|
||||||
|
url: "keycard://044def09"
|
||||||
|
}],
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
So the communication with the card is working, but there is no key associated with this wallet. Let's create it:
|
||||||
|
|
||||||
|
```
|
||||||
|
> personal.initializeWallet("keycard://044def09")
|
||||||
|
"tilt ... impact"
|
||||||
|
```
|
||||||
|
|
||||||
|
You should get a list of words, this is your seed so write them down. Your wallet should now be initialized:
|
||||||
|
|
||||||
|
```
|
||||||
|
> personal.listWallets
|
||||||
|
[{
|
||||||
|
accounts: [{
|
||||||
|
address: "0x678b7cd55c61917defb23546a41803c5bfefbc7a",
|
||||||
|
url: "keycard://044d/m/44'/60'/0'/0/0"
|
||||||
|
}],
|
||||||
|
status: "Online",
|
||||||
|
url: "keycard://044def09"
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
|
You're all set!
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
1. Start `geth` with the `console` command
|
||||||
|
2. Check the card's URL by checking `personal.listWallets`:
|
||||||
|
|
||||||
|
```
|
||||||
|
listWallets: [{
|
||||||
|
status: "Online, can derive public keys",
|
||||||
|
url: "keycard://a4d73015"
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Open the wallet, you will be prompted for your pairing password, then PIN:
|
||||||
|
|
||||||
|
```
|
||||||
|
personal.openWallet("keycard://a4d73015")
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Check that creation was successful by typing e.g. `personal`. Then use it like a regular wallet.
|
||||||
|
|
||||||
|
## Known issues
|
||||||
|
|
||||||
|
* Starting geth with a valid card seems to make firefox crash.
|
||||||
|
* PCSC version 4.4 should work, but is currently untested
|
||||||
87
accounts/scwallet/apdu.go
Normal file
87
accounts/scwallet/apdu.go
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
// Copyright 2018 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package scwallet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// commandAPDU represents an application data unit sent to a smartcard.
|
||||||
|
type commandAPDU struct {
|
||||||
|
Cla, Ins, P1, P2 uint8 // Class, Instruction, Parameter 1, Parameter 2
|
||||||
|
Data []byte // Command data
|
||||||
|
Le uint8 // Command data length
|
||||||
|
}
|
||||||
|
|
||||||
|
// serialize serializes a command APDU.
|
||||||
|
func (ca commandAPDU) serialize() ([]byte, error) {
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, ca.Cla); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, ca.Ins); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, ca.P1); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, ca.P2); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(ca.Data) > 0 {
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, uint8(len(ca.Data))); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, ca.Data); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := binary.Write(buf, binary.BigEndian, ca.Le); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// responseAPDU represents an application data unit received from a smart card.
|
||||||
|
type responseAPDU struct {
|
||||||
|
Data []byte // response data
|
||||||
|
Sw1, Sw2 uint8 // status words 1 and 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// deserialize deserializes a response APDU.
|
||||||
|
func (ra *responseAPDU) deserialize(data []byte) error {
|
||||||
|
if len(data) < 2 {
|
||||||
|
return fmt.Errorf("can not deserialize data: payload too short (%d < 2)", len(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
ra.Data = make([]byte, len(data)-2)
|
||||||
|
|
||||||
|
buf := bytes.NewReader(data)
|
||||||
|
if err := binary.Read(buf, binary.BigEndian, &ra.Data); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := binary.Read(buf, binary.BigEndian, &ra.Sw1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := binary.Read(buf, binary.BigEndian, &ra.Sw2); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
302
accounts/scwallet/hub.go
Normal file
302
accounts/scwallet/hub.go
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
// Copyright 2018 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// This package implements support for smartcard-based hardware wallets such as
|
||||||
|
// the one written by Status: https://github.com/status-im/hardware-wallet
|
||||||
|
//
|
||||||
|
// This implementation of smartcard wallets have a different interaction process
|
||||||
|
// to other types of hardware wallet. The process works like this:
|
||||||
|
//
|
||||||
|
// 1. (First use with a given client) Establish a pairing between hardware
|
||||||
|
// wallet and client. This requires a secret value called a 'pairing password'.
|
||||||
|
// You can pair with an unpaired wallet with `personal.openWallet(URI, pairing password)`.
|
||||||
|
// 2. (First use only) Initialize the wallet, which generates a keypair, stores
|
||||||
|
// it on the wallet, and returns it so the user can back it up. You can
|
||||||
|
// initialize a wallet with `personal.initializeWallet(URI)`.
|
||||||
|
// 3. Connect to the wallet using the pairing information established in step 1.
|
||||||
|
// You can connect to a paired wallet with `personal.openWallet(URI, PIN)`.
|
||||||
|
// 4. Interact with the wallet as normal.
|
||||||
|
|
||||||
|
package scwallet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
pcsc "github.com/gballet/go-libpcsclite"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Scheme is the URI prefix for smartcard wallets.
|
||||||
|
const Scheme = "keycard"
|
||||||
|
|
||||||
|
// refreshCycle is the maximum time between wallet refreshes (if USB hotplug
|
||||||
|
// notifications don't work).
|
||||||
|
const refreshCycle = time.Second
|
||||||
|
|
||||||
|
// refreshThrottling is the minimum time between wallet refreshes to avoid thrashing.
|
||||||
|
const refreshThrottling = 500 * time.Millisecond
|
||||||
|
|
||||||
|
// smartcardPairing contains information about a smart card we have paired with
|
||||||
|
// or might pair with the hub.
|
||||||
|
type smartcardPairing struct {
|
||||||
|
PublicKey []byte `json:"publicKey"`
|
||||||
|
PairingIndex uint8 `json:"pairingIndex"`
|
||||||
|
PairingKey []byte `json:"pairingKey"`
|
||||||
|
Accounts map[common.Address]accounts.DerivationPath `json:"accounts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hub is a accounts.Backend that can find and handle generic PC/SC hardware wallets.
|
||||||
|
type Hub struct {
|
||||||
|
scheme string // Protocol scheme prefixing account and wallet URLs.
|
||||||
|
|
||||||
|
context *pcsc.Client
|
||||||
|
datadir string
|
||||||
|
pairings map[string]smartcardPairing
|
||||||
|
|
||||||
|
refreshed time.Time // Time instance when the list of wallets was last refreshed
|
||||||
|
wallets map[string]*Wallet // Mapping from reader names to wallet instances
|
||||||
|
updateFeed event.Feed // Event feed to notify wallet additions/removals
|
||||||
|
updateScope event.SubscriptionScope // Subscription scope tracking current live listeners
|
||||||
|
updating bool // Whether the event notification loop is running
|
||||||
|
|
||||||
|
quit chan chan error
|
||||||
|
|
||||||
|
stateLock sync.RWMutex // Protects the internals of the hub from racey access
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hub *Hub) readPairings() error {
|
||||||
|
hub.pairings = make(map[string]smartcardPairing)
|
||||||
|
pairingFile, err := os.Open(filepath.Join(hub.datadir, "smartcards.json"))
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pairingData, err := ioutil.ReadAll(pairingFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var pairings []smartcardPairing
|
||||||
|
if err := json.Unmarshal(pairingData, &pairings); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pairing := range pairings {
|
||||||
|
hub.pairings[string(pairing.PublicKey)] = pairing
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hub *Hub) writePairings() error {
|
||||||
|
pairingFile, err := os.OpenFile(filepath.Join(hub.datadir, "smartcards.json"), os.O_RDWR|os.O_CREATE, 0755)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer pairingFile.Close()
|
||||||
|
|
||||||
|
pairings := make([]smartcardPairing, 0, len(hub.pairings))
|
||||||
|
for _, pairing := range hub.pairings {
|
||||||
|
pairings = append(pairings, pairing)
|
||||||
|
}
|
||||||
|
|
||||||
|
pairingData, err := json.Marshal(pairings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := pairingFile.Write(pairingData); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hub *Hub) pairing(wallet *Wallet) *smartcardPairing {
|
||||||
|
if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok {
|
||||||
|
return &pairing
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hub *Hub) setPairing(wallet *Wallet, pairing *smartcardPairing) error {
|
||||||
|
if pairing == nil {
|
||||||
|
delete(hub.pairings, string(wallet.PublicKey))
|
||||||
|
} else {
|
||||||
|
hub.pairings[string(wallet.PublicKey)] = *pairing
|
||||||
|
}
|
||||||
|
return hub.writePairings()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewHub creates a new hardware wallet manager for smartcards.
|
||||||
|
func NewHub(daemonPath string, scheme string, datadir string) (*Hub, error) {
|
||||||
|
context, err := pcsc.EstablishContext(daemonPath, pcsc.ScopeSystem)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
hub := &Hub{
|
||||||
|
scheme: scheme,
|
||||||
|
context: context,
|
||||||
|
datadir: datadir,
|
||||||
|
wallets: make(map[string]*Wallet),
|
||||||
|
quit: make(chan chan error),
|
||||||
|
}
|
||||||
|
if err := hub.readPairings(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
hub.refreshWallets()
|
||||||
|
return hub, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wallets implements accounts.Backend, returning all the currently tracked smart
|
||||||
|
// cards that appear to be hardware wallets.
|
||||||
|
func (hub *Hub) Wallets() []accounts.Wallet {
|
||||||
|
// Make sure the list of wallets is up to date
|
||||||
|
hub.refreshWallets()
|
||||||
|
|
||||||
|
hub.stateLock.RLock()
|
||||||
|
defer hub.stateLock.RUnlock()
|
||||||
|
|
||||||
|
cpy := make([]accounts.Wallet, 0, len(hub.wallets))
|
||||||
|
for _, wallet := range hub.wallets {
|
||||||
|
cpy = append(cpy, wallet)
|
||||||
|
}
|
||||||
|
sort.Sort(accounts.WalletsByURL(cpy))
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
// refreshWallets scans the devices attached to the machine and updates the
|
||||||
|
// list of wallets based on the found devices.
|
||||||
|
func (hub *Hub) refreshWallets() {
|
||||||
|
// Don't scan the USB like crazy it the user fetches wallets in a loop
|
||||||
|
hub.stateLock.RLock()
|
||||||
|
elapsed := time.Since(hub.refreshed)
|
||||||
|
hub.stateLock.RUnlock()
|
||||||
|
|
||||||
|
if elapsed < refreshThrottling {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Retrieve all the smart card reader to check for cards
|
||||||
|
readers, err := hub.context.ListReaders()
|
||||||
|
if err != nil {
|
||||||
|
// This is a perverted hack, the scard library returns an error if no card
|
||||||
|
// readers are present instead of simply returning an empty list. We don't
|
||||||
|
// want to fill the user's log with errors, so filter those out.
|
||||||
|
if err.Error() != "scard: Cannot find a smart card reader." {
|
||||||
|
log.Error("Failed to enumerate smart card readers", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Transform the current list of wallets into the new one
|
||||||
|
hub.stateLock.Lock()
|
||||||
|
|
||||||
|
events := []accounts.WalletEvent{}
|
||||||
|
seen := make(map[string]struct{})
|
||||||
|
|
||||||
|
for _, reader := range readers {
|
||||||
|
// Mark the reader as present
|
||||||
|
seen[reader] = struct{}{}
|
||||||
|
|
||||||
|
// If we alreay know about this card, skip to the next reader, otherwise clean up
|
||||||
|
if wallet, ok := hub.wallets[reader]; ok {
|
||||||
|
if err := wallet.ping(); err == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
wallet.Close()
|
||||||
|
events = append(events, accounts.WalletEvent{Wallet: wallet, Kind: accounts.WalletDropped})
|
||||||
|
delete(hub.wallets, reader)
|
||||||
|
}
|
||||||
|
// New card detected, try to connect to it
|
||||||
|
card, err := hub.context.Connect(reader, pcsc.ShareShared, pcsc.ProtocolAny)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("Failed to open smart card", "reader", reader, "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
wallet := NewWallet(hub, card)
|
||||||
|
if err = wallet.connect(); err != nil {
|
||||||
|
log.Debug("Failed to connect to smart card", "reader", reader, "err", err)
|
||||||
|
card.Disconnect(pcsc.LeaveCard)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Card connected, start tracking in amongs the wallets
|
||||||
|
hub.wallets[reader] = wallet
|
||||||
|
events = append(events, accounts.WalletEvent{Wallet: wallet, Kind: accounts.WalletArrived})
|
||||||
|
}
|
||||||
|
// Remove any wallets no longer present
|
||||||
|
for reader, wallet := range hub.wallets {
|
||||||
|
if _, ok := seen[reader]; !ok {
|
||||||
|
wallet.Close()
|
||||||
|
events = append(events, accounts.WalletEvent{Wallet: wallet, Kind: accounts.WalletDropped})
|
||||||
|
delete(hub.wallets, reader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hub.refreshed = time.Now()
|
||||||
|
hub.stateLock.Unlock()
|
||||||
|
|
||||||
|
for _, event := range events {
|
||||||
|
hub.updateFeed.Send(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe implements accounts.Backend, creating an async subscription to
|
||||||
|
// receive notifications on the addition or removal of smart card wallets.
|
||||||
|
func (hub *Hub) Subscribe(sink chan<- accounts.WalletEvent) event.Subscription {
|
||||||
|
// We need the mutex to reliably start/stop the update loop
|
||||||
|
hub.stateLock.Lock()
|
||||||
|
defer hub.stateLock.Unlock()
|
||||||
|
|
||||||
|
// Subscribe the caller and track the subscriber count
|
||||||
|
sub := hub.updateScope.Track(hub.updateFeed.Subscribe(sink))
|
||||||
|
|
||||||
|
// Subscribers require an active notification loop, start it
|
||||||
|
if !hub.updating {
|
||||||
|
hub.updating = true
|
||||||
|
go hub.updater()
|
||||||
|
}
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
|
||||||
|
// updater is responsible for maintaining an up-to-date list of wallets managed
|
||||||
|
// by the smart card hub, and for firing wallet addition/removal events.
|
||||||
|
func (hub *Hub) updater() {
|
||||||
|
for {
|
||||||
|
// TODO: Wait for a USB hotplug event (not supported yet) or a refresh timeout
|
||||||
|
// <-hub.changes
|
||||||
|
time.Sleep(refreshCycle)
|
||||||
|
|
||||||
|
// Run the wallet refresher
|
||||||
|
hub.refreshWallets()
|
||||||
|
|
||||||
|
// If all our subscribers left, stop the updater
|
||||||
|
hub.stateLock.Lock()
|
||||||
|
if hub.updateScope.Count() == 0 {
|
||||||
|
hub.updating = false
|
||||||
|
hub.stateLock.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hub.stateLock.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
346
accounts/scwallet/securechannel.go
Normal file
346
accounts/scwallet/securechannel.go
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
// Copyright 2018 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package scwallet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"crypto/aes"
|
||||||
|
"crypto/cipher"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/sha256"
|
||||||
|
"crypto/sha512"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
pcsc "github.com/gballet/go-libpcsclite"
|
||||||
|
"github.com/wsddn/go-ecdh"
|
||||||
|
"golang.org/x/crypto/pbkdf2"
|
||||||
|
"golang.org/x/text/unicode/norm"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxPayloadSize = 223
|
||||||
|
pairP1FirstStep = 0
|
||||||
|
pairP1LastStep = 1
|
||||||
|
|
||||||
|
scSecretLength = 32
|
||||||
|
scBlockSize = 16
|
||||||
|
|
||||||
|
insOpenSecureChannel = 0x10
|
||||||
|
insMutuallyAuthenticate = 0x11
|
||||||
|
insPair = 0x12
|
||||||
|
insUnpair = 0x13
|
||||||
|
|
||||||
|
pairingSalt = "Keycard Pairing Password Salt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SecureChannelSession enables secure communication with a hardware wallet.
|
||||||
|
type SecureChannelSession struct {
|
||||||
|
card *pcsc.Card // A handle to the smartcard for communication
|
||||||
|
secret []byte // A shared secret generated from our ECDSA keys
|
||||||
|
publicKey []byte // Our own ephemeral public key
|
||||||
|
PairingKey []byte // A permanent shared secret for a pairing, if present
|
||||||
|
sessionEncKey []byte // The current session encryption key
|
||||||
|
sessionMacKey []byte // The current session MAC key
|
||||||
|
iv []byte // The current IV
|
||||||
|
PairingIndex uint8 // The pairing index
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSecureChannelSession creates a new secure channel for the given card and public key.
|
||||||
|
func NewSecureChannelSession(card *pcsc.Card, keyData []byte) (*SecureChannelSession, error) {
|
||||||
|
// Generate an ECDSA keypair for ourselves
|
||||||
|
gen := ecdh.NewEllipticECDH(crypto.S256())
|
||||||
|
private, public, err := gen.GenerateKey(rand.Reader)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cardPublic, ok := gen.Unmarshal(keyData)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("Could not unmarshal public key from card")
|
||||||
|
}
|
||||||
|
|
||||||
|
secret, err := gen.GenerateSharedSecret(private, cardPublic)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &SecureChannelSession{
|
||||||
|
card: card,
|
||||||
|
secret: secret,
|
||||||
|
publicKey: gen.Marshal(public),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pair establishes a new pairing with the smartcard.
|
||||||
|
func (s *SecureChannelSession) Pair(pairingPassword []byte) error {
|
||||||
|
secretHash := pbkdf2.Key(norm.NFKD.Bytes(pairingPassword), norm.NFKD.Bytes([]byte(pairingSalt)), 50000, 32, sha256.New)
|
||||||
|
|
||||||
|
challenge := make([]byte, 32)
|
||||||
|
if _, err := rand.Read(challenge); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := s.pair(pairP1FirstStep, challenge)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
md := sha256.New()
|
||||||
|
md.Write(secretHash[:])
|
||||||
|
md.Write(challenge)
|
||||||
|
|
||||||
|
expectedCryptogram := md.Sum(nil)
|
||||||
|
cardCryptogram := response.Data[:32]
|
||||||
|
cardChallenge := response.Data[32:64]
|
||||||
|
|
||||||
|
if !bytes.Equal(expectedCryptogram, cardCryptogram) {
|
||||||
|
return fmt.Errorf("Invalid card cryptogram %v != %v", expectedCryptogram, cardCryptogram)
|
||||||
|
}
|
||||||
|
|
||||||
|
md.Reset()
|
||||||
|
md.Write(secretHash[:])
|
||||||
|
md.Write(cardChallenge)
|
||||||
|
response, err = s.pair(pairP1LastStep, md.Sum(nil))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
md.Reset()
|
||||||
|
md.Write(secretHash[:])
|
||||||
|
md.Write(response.Data[1:])
|
||||||
|
s.PairingKey = md.Sum(nil)
|
||||||
|
s.PairingIndex = response.Data[0]
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unpair disestablishes an existing pairing.
|
||||||
|
func (s *SecureChannelSession) Unpair() error {
|
||||||
|
if s.PairingKey == nil {
|
||||||
|
return fmt.Errorf("Cannot unpair: not paired")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := s.transmitEncrypted(claSCWallet, insUnpair, s.PairingIndex, 0, []byte{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.PairingKey = nil
|
||||||
|
// Close channel
|
||||||
|
s.iv = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open initializes the secure channel.
|
||||||
|
func (s *SecureChannelSession) Open() error {
|
||||||
|
if s.iv != nil {
|
||||||
|
return fmt.Errorf("Session already opened")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := s.open()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the encryption/mac key by hashing our shared secret,
|
||||||
|
// pairing key, and the first bytes returned from the Open APDU.
|
||||||
|
md := sha512.New()
|
||||||
|
md.Write(s.secret)
|
||||||
|
md.Write(s.PairingKey)
|
||||||
|
md.Write(response.Data[:scSecretLength])
|
||||||
|
keyData := md.Sum(nil)
|
||||||
|
s.sessionEncKey = keyData[:scSecretLength]
|
||||||
|
s.sessionMacKey = keyData[scSecretLength : scSecretLength*2]
|
||||||
|
|
||||||
|
// The IV is the last bytes returned from the Open APDU.
|
||||||
|
s.iv = response.Data[scSecretLength:]
|
||||||
|
|
||||||
|
return s.mutuallyAuthenticate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// mutuallyAuthenticate is an internal method to authenticate both ends of the
|
||||||
|
// connection.
|
||||||
|
func (s *SecureChannelSession) mutuallyAuthenticate() error {
|
||||||
|
data := make([]byte, scSecretLength)
|
||||||
|
if _, err := rand.Read(data); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := s.transmitEncrypted(claSCWallet, insMutuallyAuthenticate, 0, 0, data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if response.Sw1 != 0x90 || response.Sw2 != 0x00 {
|
||||||
|
return fmt.Errorf("Got unexpected response from MUTUALLY_AUTHENTICATE: 0x%x%x", response.Sw1, response.Sw2)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(response.Data) != scSecretLength {
|
||||||
|
return fmt.Errorf("Response from MUTUALLY_AUTHENTICATE was %d bytes, expected %d", len(response.Data), scSecretLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// open is an internal method that sends an open APDU.
|
||||||
|
func (s *SecureChannelSession) open() (*responseAPDU, error) {
|
||||||
|
return transmit(s.card, &commandAPDU{
|
||||||
|
Cla: claSCWallet,
|
||||||
|
Ins: insOpenSecureChannel,
|
||||||
|
P1: s.PairingIndex,
|
||||||
|
P2: 0,
|
||||||
|
Data: s.publicKey,
|
||||||
|
Le: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// pair is an internal method that sends a pair APDU.
|
||||||
|
func (s *SecureChannelSession) pair(p1 uint8, data []byte) (*responseAPDU, error) {
|
||||||
|
return transmit(s.card, &commandAPDU{
|
||||||
|
Cla: claSCWallet,
|
||||||
|
Ins: insPair,
|
||||||
|
P1: p1,
|
||||||
|
P2: 0,
|
||||||
|
Data: data,
|
||||||
|
Le: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// transmitEncrypted sends an encrypted message, and decrypts and returns the response.
|
||||||
|
func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []byte) (*responseAPDU, error) {
|
||||||
|
if s.iv == nil {
|
||||||
|
return nil, fmt.Errorf("Channel not open")
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := s.encryptAPDU(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
meta := [16]byte{cla, ins, p1, p2, byte(len(data) + scBlockSize)}
|
||||||
|
if err = s.updateIV(meta[:], data); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fulldata := make([]byte, len(s.iv)+len(data))
|
||||||
|
copy(fulldata, s.iv)
|
||||||
|
copy(fulldata[len(s.iv):], data)
|
||||||
|
|
||||||
|
response, err := transmit(s.card, &commandAPDU{
|
||||||
|
Cla: cla,
|
||||||
|
Ins: ins,
|
||||||
|
P1: p1,
|
||||||
|
P2: p2,
|
||||||
|
Data: fulldata,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
rmeta := [16]byte{byte(len(response.Data))}
|
||||||
|
rmac := response.Data[:len(s.iv)]
|
||||||
|
rdata := response.Data[len(s.iv):]
|
||||||
|
plainData, err := s.decryptAPDU(rdata)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = s.updateIV(rmeta[:], rdata); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !bytes.Equal(s.iv, rmac) {
|
||||||
|
return nil, fmt.Errorf("Invalid MAC in response")
|
||||||
|
}
|
||||||
|
|
||||||
|
rapdu := &responseAPDU{}
|
||||||
|
rapdu.deserialize(plainData)
|
||||||
|
|
||||||
|
if rapdu.Sw1 != sw1Ok {
|
||||||
|
return nil, fmt.Errorf("Unexpected response status Cla=0x%x, Ins=0x%x, Sw=0x%x%x", cla, ins, rapdu.Sw1, rapdu.Sw2)
|
||||||
|
}
|
||||||
|
|
||||||
|
return rapdu, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// encryptAPDU is an internal method that serializes and encrypts an APDU.
|
||||||
|
func (s *SecureChannelSession) encryptAPDU(data []byte) ([]byte, error) {
|
||||||
|
if len(data) > maxPayloadSize {
|
||||||
|
return nil, fmt.Errorf("Payload of %d bytes exceeds maximum of %d", len(data), maxPayloadSize)
|
||||||
|
}
|
||||||
|
data = pad(data, 0x80)
|
||||||
|
|
||||||
|
ret := make([]byte, len(data))
|
||||||
|
|
||||||
|
a, err := aes.NewCipher(s.sessionEncKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
crypter := cipher.NewCBCEncrypter(a, s.iv)
|
||||||
|
crypter.CryptBlocks(ret, data)
|
||||||
|
return ret, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// pad applies message padding to a 16 byte boundary.
|
||||||
|
func pad(data []byte, terminator byte) []byte {
|
||||||
|
padded := make([]byte, (len(data)/16+1)*16)
|
||||||
|
copy(padded, data)
|
||||||
|
padded[len(data)] = terminator
|
||||||
|
return padded
|
||||||
|
}
|
||||||
|
|
||||||
|
// decryptAPDU is an internal method that decrypts and deserializes an APDU.
|
||||||
|
func (s *SecureChannelSession) decryptAPDU(data []byte) ([]byte, error) {
|
||||||
|
a, err := aes.NewCipher(s.sessionEncKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := make([]byte, len(data))
|
||||||
|
|
||||||
|
crypter := cipher.NewCBCDecrypter(a, s.iv)
|
||||||
|
crypter.CryptBlocks(ret, data)
|
||||||
|
return unpad(ret, 0x80)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpad strips padding from a message.
|
||||||
|
func unpad(data []byte, terminator byte) ([]byte, error) {
|
||||||
|
for i := 1; i <= 16; i++ {
|
||||||
|
switch data[len(data)-i] {
|
||||||
|
case 0:
|
||||||
|
continue
|
||||||
|
case terminator:
|
||||||
|
return data[:len(data)-i], nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("Expected end of padding, got %d", data[len(data)-i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Expected end of padding, got 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
// updateIV is an internal method that updates the initialization vector after
|
||||||
|
// each message exchanged.
|
||||||
|
func (s *SecureChannelSession) updateIV(meta, data []byte) error {
|
||||||
|
data = pad(data, 0)
|
||||||
|
a, err := aes.NewCipher(s.sessionMacKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
crypter := cipher.NewCBCEncrypter(a, make([]byte, 16))
|
||||||
|
crypter.CryptBlocks(meta, meta)
|
||||||
|
crypter.CryptBlocks(data, data)
|
||||||
|
// The first 16 bytes of the last block is the MAC
|
||||||
|
s.iv = data[len(data)-32 : len(data)-16]
|
||||||
|
return nil
|
||||||
|
}
|
||||||
1082
accounts/scwallet/wallet.go
Normal file
1082
accounts/scwallet/wallet.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,31 +14,18 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package feed
|
package accounts
|
||||||
|
|
||||||
import "github.com/ethereum/go-ethereum/common/hexutil"
|
// AccountsByURL implements sort.Interface for []Account based on the URL field.
|
||||||
|
type AccountsByURL []Account
|
||||||
|
|
||||||
type binarySerializer interface {
|
func (a AccountsByURL) Len() int { return len(a) }
|
||||||
binaryPut(serializedData []byte) error
|
func (a AccountsByURL) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||||
binaryLength() int
|
func (a AccountsByURL) Less(i, j int) bool { return a[i].URL.Cmp(a[j].URL) < 0 }
|
||||||
binaryGet(serializedData []byte) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Values interface represents a string key-value store
|
// WalletsByURL implements sort.Interface for []Wallet based on the URL field.
|
||||||
// useful for building query strings
|
type WalletsByURL []Wallet
|
||||||
type Values interface {
|
|
||||||
Get(key string) string
|
|
||||||
Set(key, value string)
|
|
||||||
}
|
|
||||||
|
|
||||||
type valueSerializer interface {
|
func (w WalletsByURL) Len() int { return len(w) }
|
||||||
FromValues(values Values) error
|
func (w WalletsByURL) Swap(i, j int) { w[i], w[j] = w[j], w[i] }
|
||||||
AppendValues(values Values)
|
func (w WalletsByURL) Less(i, j int) bool { return w[i].URL().Cmp(w[j].URL()) < 0 }
|
||||||
}
|
|
||||||
|
|
||||||
// Hex serializes the structure and converts it to a hex string
|
|
||||||
func Hex(bin binarySerializer) string {
|
|
||||||
b := make([]byte, bin.binaryLength())
|
|
||||||
bin.binaryPut(b)
|
|
||||||
return hexutil.Encode(b)
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017 The go-ethereum Authors
|
// Copyright 2018 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/karalabe/hid"
|
"github.com/karalabe/usb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LedgerScheme is the protocol scheme prefixing account and wallet URLs.
|
// LedgerScheme is the protocol scheme prefixing account and wallet URLs.
|
||||||
@@ -64,21 +65,41 @@ type Hub struct {
|
|||||||
// TODO(karalabe): remove if hotplug lands on Windows
|
// TODO(karalabe): remove if hotplug lands on Windows
|
||||||
commsPend int // Number of operations blocking enumeration
|
commsPend int // Number of operations blocking enumeration
|
||||||
commsLock sync.Mutex // Lock protecting the pending counter and enumeration
|
commsLock sync.Mutex // Lock protecting the pending counter and enumeration
|
||||||
|
enumFails uint32 // Number of times enumeration has failed
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLedgerHub creates a new hardware wallet manager for Ledger devices.
|
// NewLedgerHub creates a new hardware wallet manager for Ledger devices.
|
||||||
func NewLedgerHub() (*Hub, error) {
|
func NewLedgerHub() (*Hub, error) {
|
||||||
return newHub(LedgerScheme, 0x2c97, []uint16{0x0000 /* Ledger Blue */, 0x0001 /* Ledger Nano S */}, 0xffa0, 0, newLedgerDriver)
|
return newHub(LedgerScheme, 0x2c97, []uint16{
|
||||||
|
// Original product IDs
|
||||||
|
0x0000, /* Ledger Blue */
|
||||||
|
0x0001, /* Ledger Nano S */
|
||||||
|
0x0004, /* Ledger Nano X */
|
||||||
|
|
||||||
|
// Upcoming product IDs: https://www.ledger.com/2019/05/17/windows-10-update-sunsetting-u2f-tunnel-transport-for-ledger-devices/
|
||||||
|
0x0015, /* HID + U2F + WebUSB Ledger Blue */
|
||||||
|
0x1015, /* HID + U2F + WebUSB Ledger Nano S */
|
||||||
|
0x4015, /* HID + U2F + WebUSB Ledger Nano X */
|
||||||
|
0x0011, /* HID + WebUSB Ledger Blue */
|
||||||
|
0x1011, /* HID + WebUSB Ledger Nano S */
|
||||||
|
0x4011, /* HID + WebUSB Ledger Nano X */
|
||||||
|
}, 0xffa0, 0, newLedgerDriver)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTrezorHub creates a new hardware wallet manager for Trezor devices.
|
// NewTrezorHubWithHID creates a new hardware wallet manager for Trezor devices.
|
||||||
func NewTrezorHub() (*Hub, error) {
|
func NewTrezorHubWithHID() (*Hub, error) {
|
||||||
return newHub(TrezorScheme, 0x534c, []uint16{0x0001 /* Trezor 1 */}, 0xff00, 0, newTrezorDriver)
|
return newHub(TrezorScheme, 0x534c, []uint16{0x0001 /* Trezor HID */}, 0xff00, 0, newTrezorDriver)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTrezorHubWithWebUSB creates a new hardware wallet manager for Trezor devices with
|
||||||
|
// firmware version > 1.8.0
|
||||||
|
func NewTrezorHubWithWebUSB() (*Hub, error) {
|
||||||
|
return newHub(TrezorScheme, 0x1209, []uint16{0x53c1 /* Trezor WebUSB */}, 0xffff /* No usage id on webusb, don't match unset (0) */, 0, newTrezorDriver)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHub creates a new hardware wallet manager for generic USB devices.
|
// newHub creates a new hardware wallet manager for generic USB devices.
|
||||||
func newHub(scheme string, vendorID uint16, productIDs []uint16, usageID uint16, endpointID int, makeDriver func(log.Logger) driver) (*Hub, error) {
|
func newHub(scheme string, vendorID uint16, productIDs []uint16, usageID uint16, endpointID int, makeDriver func(log.Logger) driver) (*Hub, error) {
|
||||||
if !hid.Supported() {
|
if !usb.Supported() {
|
||||||
return nil, errors.New("unsupported platform")
|
return nil, errors.New("unsupported platform")
|
||||||
}
|
}
|
||||||
hub := &Hub{
|
hub := &Hub{
|
||||||
@@ -119,8 +140,12 @@ func (hub *Hub) refreshWallets() {
|
|||||||
if elapsed < refreshThrottling {
|
if elapsed < refreshThrottling {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// If USB enumeration is continually failing, don't keep trying indefinitely
|
||||||
|
if atomic.LoadUint32(&hub.enumFails) > 2 {
|
||||||
|
return
|
||||||
|
}
|
||||||
// Retrieve the current list of USB wallet devices
|
// Retrieve the current list of USB wallet devices
|
||||||
var devices []hid.DeviceInfo
|
var devices []usb.DeviceInfo
|
||||||
|
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
// hidapi on Linux opens the device during enumeration to retrieve some infos,
|
// hidapi on Linux opens the device during enumeration to retrieve some infos,
|
||||||
@@ -135,8 +160,22 @@ func (hub *Hub) refreshWallets() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, info := range hid.Enumerate(hub.vendorID, 0) {
|
infos, err := usb.Enumerate(hub.vendorID, 0)
|
||||||
|
if err != nil {
|
||||||
|
failcount := atomic.AddUint32(&hub.enumFails, 1)
|
||||||
|
if runtime.GOOS == "linux" {
|
||||||
|
// See rationale before the enumeration why this is needed and only on Linux.
|
||||||
|
hub.commsLock.Unlock()
|
||||||
|
}
|
||||||
|
log.Error("Failed to enumerate USB devices", "hub", hub.scheme,
|
||||||
|
"vendor", hub.vendorID, "failcount", failcount, "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
atomic.StoreUint32(&hub.enumFails, 0)
|
||||||
|
|
||||||
|
for _, info := range infos {
|
||||||
for _, id := range hub.productIDs {
|
for _, id := range hub.productIDs {
|
||||||
|
// Windows and Macos use UsageID matching, Linux uses Interface matching
|
||||||
if info.ProductID == id && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) {
|
if info.ProductID == id && (info.UsagePage == hub.usageID || info.Interface == hub.endpointID) {
|
||||||
devices = append(devices, info)
|
devices = append(devices, info)
|
||||||
break
|
break
|
||||||
@@ -150,8 +189,10 @@ func (hub *Hub) refreshWallets() {
|
|||||||
// Transform the current list of wallets into the new one
|
// Transform the current list of wallets into the new one
|
||||||
hub.stateLock.Lock()
|
hub.stateLock.Lock()
|
||||||
|
|
||||||
wallets := make([]accounts.Wallet, 0, len(devices))
|
var (
|
||||||
events := []accounts.WalletEvent{}
|
wallets = make([]accounts.Wallet, 0, len(devices))
|
||||||
|
events []accounts.WalletEvent
|
||||||
|
)
|
||||||
|
|
||||||
for _, device := range devices {
|
for _, device := range devices {
|
||||||
url := accounts.URL{Scheme: hub.scheme, Path: device.Path}
|
url := accounts.URL{Scheme: hub.scheme, Path: device.Path}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,905 +0,0 @@
|
|||||||
// This file originates from the SatoshiLabs Trezor `common` repository at:
|
|
||||||
// https://github.com/trezor/trezor-common/blob/master/protob/messages.proto
|
|
||||||
// dated 28.07.2017, commit dd8ec3231fb5f7992360aff9bdfe30bb58130f4b.
|
|
||||||
|
|
||||||
syntax = "proto2";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Messages for TREZOR communication
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Sugar for easier handling in Java
|
|
||||||
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
|
||||||
option java_outer_classname = "TrezorMessage";
|
|
||||||
|
|
||||||
import "types.proto";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping between Trezor wire identifier (uint) and a protobuf message
|
|
||||||
*/
|
|
||||||
enum MessageType {
|
|
||||||
MessageType_Initialize = 0 [(wire_in) = true];
|
|
||||||
MessageType_Ping = 1 [(wire_in) = true];
|
|
||||||
MessageType_Success = 2 [(wire_out) = true];
|
|
||||||
MessageType_Failure = 3 [(wire_out) = true];
|
|
||||||
MessageType_ChangePin = 4 [(wire_in) = true];
|
|
||||||
MessageType_WipeDevice = 5 [(wire_in) = true];
|
|
||||||
MessageType_FirmwareErase = 6 [(wire_in) = true, (wire_bootloader) = true];
|
|
||||||
MessageType_FirmwareUpload = 7 [(wire_in) = true, (wire_bootloader) = true];
|
|
||||||
MessageType_FirmwareRequest = 8 [(wire_out) = true, (wire_bootloader) = true];
|
|
||||||
MessageType_GetEntropy = 9 [(wire_in) = true];
|
|
||||||
MessageType_Entropy = 10 [(wire_out) = true];
|
|
||||||
MessageType_GetPublicKey = 11 [(wire_in) = true];
|
|
||||||
MessageType_PublicKey = 12 [(wire_out) = true];
|
|
||||||
MessageType_LoadDevice = 13 [(wire_in) = true];
|
|
||||||
MessageType_ResetDevice = 14 [(wire_in) = true];
|
|
||||||
MessageType_SignTx = 15 [(wire_in) = true];
|
|
||||||
MessageType_SimpleSignTx = 16 [(wire_in) = true, deprecated = true];
|
|
||||||
MessageType_Features = 17 [(wire_out) = true];
|
|
||||||
MessageType_PinMatrixRequest = 18 [(wire_out) = true];
|
|
||||||
MessageType_PinMatrixAck = 19 [(wire_in) = true, (wire_tiny) = true];
|
|
||||||
MessageType_Cancel = 20 [(wire_in) = true];
|
|
||||||
MessageType_TxRequest = 21 [(wire_out) = true];
|
|
||||||
MessageType_TxAck = 22 [(wire_in) = true];
|
|
||||||
MessageType_CipherKeyValue = 23 [(wire_in) = true];
|
|
||||||
MessageType_ClearSession = 24 [(wire_in) = true];
|
|
||||||
MessageType_ApplySettings = 25 [(wire_in) = true];
|
|
||||||
MessageType_ButtonRequest = 26 [(wire_out) = true];
|
|
||||||
MessageType_ButtonAck = 27 [(wire_in) = true, (wire_tiny) = true];
|
|
||||||
MessageType_ApplyFlags = 28 [(wire_in) = true];
|
|
||||||
MessageType_GetAddress = 29 [(wire_in) = true];
|
|
||||||
MessageType_Address = 30 [(wire_out) = true];
|
|
||||||
MessageType_SelfTest = 32 [(wire_in) = true, (wire_bootloader) = true];
|
|
||||||
MessageType_BackupDevice = 34 [(wire_in) = true];
|
|
||||||
MessageType_EntropyRequest = 35 [(wire_out) = true];
|
|
||||||
MessageType_EntropyAck = 36 [(wire_in) = true];
|
|
||||||
MessageType_SignMessage = 38 [(wire_in) = true];
|
|
||||||
MessageType_VerifyMessage = 39 [(wire_in) = true];
|
|
||||||
MessageType_MessageSignature = 40 [(wire_out) = true];
|
|
||||||
MessageType_PassphraseRequest = 41 [(wire_out) = true];
|
|
||||||
MessageType_PassphraseAck = 42 [(wire_in) = true, (wire_tiny) = true];
|
|
||||||
MessageType_EstimateTxSize = 43 [(wire_in) = true, deprecated = true];
|
|
||||||
MessageType_TxSize = 44 [(wire_out) = true, deprecated = true];
|
|
||||||
MessageType_RecoveryDevice = 45 [(wire_in) = true];
|
|
||||||
MessageType_WordRequest = 46 [(wire_out) = true];
|
|
||||||
MessageType_WordAck = 47 [(wire_in) = true];
|
|
||||||
MessageType_CipheredKeyValue = 48 [(wire_out) = true];
|
|
||||||
MessageType_EncryptMessage = 49 [(wire_in) = true, deprecated = true];
|
|
||||||
MessageType_EncryptedMessage = 50 [(wire_out) = true, deprecated = true];
|
|
||||||
MessageType_DecryptMessage = 51 [(wire_in) = true, deprecated = true];
|
|
||||||
MessageType_DecryptedMessage = 52 [(wire_out) = true, deprecated = true];
|
|
||||||
MessageType_SignIdentity = 53 [(wire_in) = true];
|
|
||||||
MessageType_SignedIdentity = 54 [(wire_out) = true];
|
|
||||||
MessageType_GetFeatures = 55 [(wire_in) = true];
|
|
||||||
MessageType_EthereumGetAddress = 56 [(wire_in) = true];
|
|
||||||
MessageType_EthereumAddress = 57 [(wire_out) = true];
|
|
||||||
MessageType_EthereumSignTx = 58 [(wire_in) = true];
|
|
||||||
MessageType_EthereumTxRequest = 59 [(wire_out) = true];
|
|
||||||
MessageType_EthereumTxAck = 60 [(wire_in) = true];
|
|
||||||
MessageType_GetECDHSessionKey = 61 [(wire_in) = true];
|
|
||||||
MessageType_ECDHSessionKey = 62 [(wire_out) = true];
|
|
||||||
MessageType_SetU2FCounter = 63 [(wire_in) = true];
|
|
||||||
MessageType_EthereumSignMessage = 64 [(wire_in) = true];
|
|
||||||
MessageType_EthereumVerifyMessage = 65 [(wire_in) = true];
|
|
||||||
MessageType_EthereumMessageSignature = 66 [(wire_out) = true];
|
|
||||||
MessageType_DebugLinkDecision = 100 [(wire_debug_in) = true, (wire_tiny) = true];
|
|
||||||
MessageType_DebugLinkGetState = 101 [(wire_debug_in) = true];
|
|
||||||
MessageType_DebugLinkState = 102 [(wire_debug_out) = true];
|
|
||||||
MessageType_DebugLinkStop = 103 [(wire_debug_in) = true];
|
|
||||||
MessageType_DebugLinkLog = 104 [(wire_debug_out) = true];
|
|
||||||
MessageType_DebugLinkMemoryRead = 110 [(wire_debug_in) = true];
|
|
||||||
MessageType_DebugLinkMemory = 111 [(wire_debug_out) = true];
|
|
||||||
MessageType_DebugLinkMemoryWrite = 112 [(wire_debug_in) = true];
|
|
||||||
MessageType_DebugLinkFlashErase = 113 [(wire_debug_in) = true];
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////
|
|
||||||
// Basic messages //
|
|
||||||
////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Reset device to default state and ask for device details
|
|
||||||
* @next Features
|
|
||||||
*/
|
|
||||||
message Initialize {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask for device details (no device reset)
|
|
||||||
* @next Features
|
|
||||||
*/
|
|
||||||
message GetFeatures {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Reports various information about the device
|
|
||||||
* @prev Initialize
|
|
||||||
* @prev GetFeatures
|
|
||||||
*/
|
|
||||||
message Features {
|
|
||||||
optional string vendor = 1; // name of the manufacturer, e.g. "bitcointrezor.com"
|
|
||||||
optional uint32 major_version = 2; // major version of the device, e.g. 1
|
|
||||||
optional uint32 minor_version = 3; // minor version of the device, e.g. 0
|
|
||||||
optional uint32 patch_version = 4; // patch version of the device, e.g. 0
|
|
||||||
optional bool bootloader_mode = 5; // is device in bootloader mode?
|
|
||||||
optional string device_id = 6; // device's unique identifier
|
|
||||||
optional bool pin_protection = 7; // is device protected by PIN?
|
|
||||||
optional bool passphrase_protection = 8; // is node/mnemonic encrypted using passphrase?
|
|
||||||
optional string language = 9; // device language
|
|
||||||
optional string label = 10; // device description label
|
|
||||||
repeated CoinType coins = 11; // supported coins
|
|
||||||
optional bool initialized = 12; // does device contain seed?
|
|
||||||
optional bytes revision = 13; // SCM revision of firmware
|
|
||||||
optional bytes bootloader_hash = 14; // hash of the bootloader
|
|
||||||
optional bool imported = 15; // was storage imported from an external source?
|
|
||||||
optional bool pin_cached = 16; // is PIN already cached in session?
|
|
||||||
optional bool passphrase_cached = 17; // is passphrase already cached in session?
|
|
||||||
optional bool firmware_present = 18; // is valid firmware loaded?
|
|
||||||
optional bool needs_backup = 19; // does storage need backup? (equals to Storage.needs_backup)
|
|
||||||
optional uint32 flags = 20; // device flags (equals to Storage.flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: clear session (removes cached PIN, passphrase, etc).
|
|
||||||
* @next Success
|
|
||||||
*/
|
|
||||||
message ClearSession {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: change language and/or label of the device
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
* @next ButtonRequest
|
|
||||||
* @next PinMatrixRequest
|
|
||||||
*/
|
|
||||||
message ApplySettings {
|
|
||||||
optional string language = 1;
|
|
||||||
optional string label = 2;
|
|
||||||
optional bool use_passphrase = 3;
|
|
||||||
optional bytes homescreen = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: set flags of the device
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message ApplyFlags {
|
|
||||||
optional uint32 flags = 1; // bitmask, can only set bits, not unset
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Starts workflow for setting/changing/removing the PIN
|
|
||||||
* @next ButtonRequest
|
|
||||||
* @next PinMatrixRequest
|
|
||||||
*/
|
|
||||||
message ChangePin {
|
|
||||||
optional bool remove = 1; // is PIN removal requested?
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Test if the device is alive, device sends back the message in Success response
|
|
||||||
* @next Success
|
|
||||||
*/
|
|
||||||
message Ping {
|
|
||||||
optional string message = 1; // message to send back in Success message
|
|
||||||
optional bool button_protection = 2; // ask for button press
|
|
||||||
optional bool pin_protection = 3; // ask for PIN if set in device
|
|
||||||
optional bool passphrase_protection = 4; // ask for passphrase if set in device
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Success of the previous request
|
|
||||||
*/
|
|
||||||
message Success {
|
|
||||||
optional string message = 1; // human readable description of action or request-specific payload
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Failure of the previous request
|
|
||||||
*/
|
|
||||||
message Failure {
|
|
||||||
optional FailureType code = 1; // computer-readable definition of the error state
|
|
||||||
optional string message = 2; // human-readable message of the error state
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device is waiting for HW button press.
|
|
||||||
* @next ButtonAck
|
|
||||||
* @next Cancel
|
|
||||||
*/
|
|
||||||
message ButtonRequest {
|
|
||||||
optional ButtonRequestType code = 1;
|
|
||||||
optional string data = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Computer agrees to wait for HW button press
|
|
||||||
* @prev ButtonRequest
|
|
||||||
*/
|
|
||||||
message ButtonAck {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device is asking computer to show PIN matrix and awaits PIN encoded using this matrix scheme
|
|
||||||
* @next PinMatrixAck
|
|
||||||
* @next Cancel
|
|
||||||
*/
|
|
||||||
message PinMatrixRequest {
|
|
||||||
optional PinMatrixRequestType type = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Computer responds with encoded PIN
|
|
||||||
* @prev PinMatrixRequest
|
|
||||||
*/
|
|
||||||
message PinMatrixAck {
|
|
||||||
required string pin = 1; // matrix encoded PIN entered by user
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Abort last operation that required user interaction
|
|
||||||
* @prev ButtonRequest
|
|
||||||
* @prev PinMatrixRequest
|
|
||||||
* @prev PassphraseRequest
|
|
||||||
*/
|
|
||||||
message Cancel {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device awaits encryption passphrase
|
|
||||||
* @next PassphraseAck
|
|
||||||
* @next Cancel
|
|
||||||
*/
|
|
||||||
message PassphraseRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Send passphrase back
|
|
||||||
* @prev PassphraseRequest
|
|
||||||
*/
|
|
||||||
message PassphraseAck {
|
|
||||||
required string passphrase = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Request a sample of random data generated by hardware RNG. May be used for testing.
|
|
||||||
* @next ButtonRequest
|
|
||||||
* @next Entropy
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message GetEntropy {
|
|
||||||
required uint32 size = 1; // size of requested entropy
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Reply with random data generated by internal RNG
|
|
||||||
* @prev GetEntropy
|
|
||||||
*/
|
|
||||||
message Entropy {
|
|
||||||
required bytes entropy = 1; // stream of random generated bytes
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device for public key corresponding to address_n path
|
|
||||||
* @next PassphraseRequest
|
|
||||||
* @next PublicKey
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message GetPublicKey {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
optional string ecdsa_curve_name = 2; // ECDSA curve name to use
|
|
||||||
optional bool show_display = 3; // optionally show on display before sending the result
|
|
||||||
optional string coin_name = 4 [default='Bitcoin'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Contains public key derived from device private seed
|
|
||||||
* @prev GetPublicKey
|
|
||||||
*/
|
|
||||||
message PublicKey {
|
|
||||||
required HDNodeType node = 1; // BIP32 public node
|
|
||||||
optional string xpub = 2; // serialized form of public node
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device for address corresponding to address_n path
|
|
||||||
* @next PassphraseRequest
|
|
||||||
* @next Address
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message GetAddress {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
optional string coin_name = 2 [default='Bitcoin'];
|
|
||||||
optional bool show_display = 3 ; // optionally show on display before sending the result
|
|
||||||
optional MultisigRedeemScriptType multisig = 4; // filled if we are showing a multisig address
|
|
||||||
optional InputScriptType script_type = 5 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device for Ethereum address corresponding to address_n path
|
|
||||||
* @next PassphraseRequest
|
|
||||||
* @next EthereumAddress
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message EthereumGetAddress {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
optional bool show_display = 2; // optionally show on display before sending the result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Contains address derived from device private seed
|
|
||||||
* @prev GetAddress
|
|
||||||
*/
|
|
||||||
message Address {
|
|
||||||
required string address = 1; // Coin address in Base58 encoding
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Contains an Ethereum address derived from device private seed
|
|
||||||
* @prev EthereumGetAddress
|
|
||||||
*/
|
|
||||||
message EthereumAddress {
|
|
||||||
required bytes address = 1; // Coin address as an Ethereum 160 bit hash
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Request device to wipe all sensitive data and settings
|
|
||||||
* @next ButtonRequest
|
|
||||||
*/
|
|
||||||
message WipeDevice {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Load seed and related internal settings from the computer
|
|
||||||
* @next ButtonRequest
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message LoadDevice {
|
|
||||||
optional string mnemonic = 1; // seed encoded as BIP-39 mnemonic (12, 18 or 24 words)
|
|
||||||
optional HDNodeType node = 2; // BIP-32 node
|
|
||||||
optional string pin = 3; // set PIN protection
|
|
||||||
optional bool passphrase_protection = 4; // enable master node encryption using passphrase
|
|
||||||
optional string language = 5 [default='english']; // device language
|
|
||||||
optional string label = 6; // device label
|
|
||||||
optional bool skip_checksum = 7; // do not test mnemonic for valid BIP-39 checksum
|
|
||||||
optional uint32 u2f_counter = 8; // U2F counter
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to do initialization involving user interaction
|
|
||||||
* @next EntropyRequest
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message ResetDevice {
|
|
||||||
optional bool display_random = 1; // display entropy generated by the device before asking for additional entropy
|
|
||||||
optional uint32 strength = 2 [default=256]; // strength of seed in bits
|
|
||||||
optional bool passphrase_protection = 3; // enable master node encryption using passphrase
|
|
||||||
optional bool pin_protection = 4; // enable PIN protection
|
|
||||||
optional string language = 5 [default='english']; // device language
|
|
||||||
optional string label = 6; // device label
|
|
||||||
optional uint32 u2f_counter = 7; // U2F counter
|
|
||||||
optional bool skip_backup = 8; // postpone seed backup to BackupDevice workflow
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Perform backup of the device seed if not backed up using ResetDevice
|
|
||||||
* @next ButtonRequest
|
|
||||||
*/
|
|
||||||
message BackupDevice {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Ask for additional entropy from host computer
|
|
||||||
* @prev ResetDevice
|
|
||||||
* @next EntropyAck
|
|
||||||
*/
|
|
||||||
message EntropyRequest {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Provide additional entropy for seed generation function
|
|
||||||
* @prev EntropyRequest
|
|
||||||
* @next ButtonRequest
|
|
||||||
*/
|
|
||||||
message EntropyAck {
|
|
||||||
optional bytes entropy = 1; // 256 bits (32 bytes) of random data
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Start recovery workflow asking user for specific words of mnemonic
|
|
||||||
* Used to recovery device safely even on untrusted computer.
|
|
||||||
* @next WordRequest
|
|
||||||
*/
|
|
||||||
message RecoveryDevice {
|
|
||||||
optional uint32 word_count = 1; // number of words in BIP-39 mnemonic
|
|
||||||
optional bool passphrase_protection = 2; // enable master node encryption using passphrase
|
|
||||||
optional bool pin_protection = 3; // enable PIN protection
|
|
||||||
optional string language = 4 [default='english']; // device language
|
|
||||||
optional string label = 5; // device label
|
|
||||||
optional bool enforce_wordlist = 6; // enforce BIP-39 wordlist during the process
|
|
||||||
// 7 reserved for unused recovery method
|
|
||||||
optional uint32 type = 8; // supported recovery type (see RecoveryType)
|
|
||||||
optional uint32 u2f_counter = 9; // U2F counter
|
|
||||||
optional bool dry_run = 10; // perform dry-run recovery workflow (for safe mnemonic validation)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device is waiting for user to enter word of the mnemonic
|
|
||||||
* Its position is shown only on device's internal display.
|
|
||||||
* @prev RecoveryDevice
|
|
||||||
* @prev WordAck
|
|
||||||
*/
|
|
||||||
message WordRequest {
|
|
||||||
optional WordRequestType type = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Computer replies with word from the mnemonic
|
|
||||||
* @prev WordRequest
|
|
||||||
* @next WordRequest
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message WordAck {
|
|
||||||
required string word = 1; // one word of mnemonic on asked position
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////
|
|
||||||
// Message signing messages //
|
|
||||||
//////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to sign message
|
|
||||||
* @next MessageSignature
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message SignMessage {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
required bytes message = 2; // message to be signed
|
|
||||||
optional string coin_name = 3 [default='Bitcoin']; // coin to use for signing
|
|
||||||
optional InputScriptType script_type = 4 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to verify message
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message VerifyMessage {
|
|
||||||
optional string address = 1; // address to verify
|
|
||||||
optional bytes signature = 2; // signature to verify
|
|
||||||
optional bytes message = 3; // message to verify
|
|
||||||
optional string coin_name = 4 [default='Bitcoin']; // coin to use for verifying
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Signed message
|
|
||||||
* @prev SignMessage
|
|
||||||
*/
|
|
||||||
message MessageSignature {
|
|
||||||
optional string address = 1; // address used to sign the message
|
|
||||||
optional bytes signature = 2; // signature of the message
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////
|
|
||||||
// Encryption/decryption //
|
|
||||||
///////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to encrypt message
|
|
||||||
* @next EncryptedMessage
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message EncryptMessage {
|
|
||||||
optional bytes pubkey = 1; // public key
|
|
||||||
optional bytes message = 2; // message to encrypt
|
|
||||||
optional bool display_only = 3; // show just on display? (don't send back via wire)
|
|
||||||
repeated uint32 address_n = 4; // BIP-32 path to derive the signing key from master node
|
|
||||||
optional string coin_name = 5 [default='Bitcoin']; // coin to use for signing
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Encrypted message
|
|
||||||
* @prev EncryptMessage
|
|
||||||
*/
|
|
||||||
message EncryptedMessage {
|
|
||||||
optional bytes nonce = 1; // nonce used during encryption
|
|
||||||
optional bytes message = 2; // encrypted message
|
|
||||||
optional bytes hmac = 3; // message hmac
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to decrypt message
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message DecryptMessage {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the decryption key from master node
|
|
||||||
optional bytes nonce = 2; // nonce used during encryption
|
|
||||||
optional bytes message = 3; // message to decrypt
|
|
||||||
optional bytes hmac = 4; // message hmac
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Decrypted message
|
|
||||||
* @prev DecryptedMessage
|
|
||||||
*/
|
|
||||||
message DecryptedMessage {
|
|
||||||
optional bytes message = 1; // decrypted message
|
|
||||||
optional string address = 2; // address used to sign the message (if used)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to encrypt or decrypt value of given key
|
|
||||||
* @next CipheredKeyValue
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message CipherKeyValue {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
optional string key = 2; // key component of key:value
|
|
||||||
optional bytes value = 3; // value component of key:value
|
|
||||||
optional bool encrypt = 4; // are we encrypting (True) or decrypting (False)?
|
|
||||||
optional bool ask_on_encrypt = 5; // should we ask on encrypt operation?
|
|
||||||
optional bool ask_on_decrypt = 6; // should we ask on decrypt operation?
|
|
||||||
optional bytes iv = 7; // initialization vector (will be computed if not set)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Return ciphered/deciphered value
|
|
||||||
* @prev CipherKeyValue
|
|
||||||
*/
|
|
||||||
message CipheredKeyValue {
|
|
||||||
optional bytes value = 1; // ciphered/deciphered value
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////
|
|
||||||
// Transaction signing messages //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Estimated size of the transaction
|
|
||||||
* This behaves exactly like SignTx, which means that it can ask using TxRequest
|
|
||||||
* This call is non-blocking (except possible PassphraseRequest to unlock the seed)
|
|
||||||
* @next TxSize
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message EstimateTxSize {
|
|
||||||
required uint32 outputs_count = 1; // number of transaction outputs
|
|
||||||
required uint32 inputs_count = 2; // number of transaction inputs
|
|
||||||
optional string coin_name = 3 [default='Bitcoin']; // coin to use
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Estimated size of the transaction
|
|
||||||
* @prev EstimateTxSize
|
|
||||||
*/
|
|
||||||
message TxSize {
|
|
||||||
optional uint32 tx_size = 1; // estimated size of transaction in bytes
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to sign transaction
|
|
||||||
* @next PassphraseRequest
|
|
||||||
* @next PinMatrixRequest
|
|
||||||
* @next TxRequest
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message SignTx {
|
|
||||||
required uint32 outputs_count = 1; // number of transaction outputs
|
|
||||||
required uint32 inputs_count = 2; // number of transaction inputs
|
|
||||||
optional string coin_name = 3 [default='Bitcoin']; // coin to use
|
|
||||||
optional uint32 version = 4 [default=1]; // transaction version
|
|
||||||
optional uint32 lock_time = 5 [default=0]; // transaction lock_time
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Simplified transaction signing
|
|
||||||
* This method doesn't support streaming, so there are hardware limits in number of inputs and outputs.
|
|
||||||
* In case of success, the result is returned using TxRequest message.
|
|
||||||
* @next PassphraseRequest
|
|
||||||
* @next PinMatrixRequest
|
|
||||||
* @next TxRequest
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message SimpleSignTx {
|
|
||||||
repeated TxInputType inputs = 1; // transaction inputs
|
|
||||||
repeated TxOutputType outputs = 2; // transaction outputs
|
|
||||||
repeated TransactionType transactions = 3; // transactions whose outputs are used to build current inputs
|
|
||||||
optional string coin_name = 4 [default='Bitcoin']; // coin to use
|
|
||||||
optional uint32 version = 5 [default=1]; // transaction version
|
|
||||||
optional uint32 lock_time = 6 [default=0]; // transaction lock_time
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device asks for information for signing transaction or returns the last result
|
|
||||||
* If request_index is set, device awaits TxAck message (with fields filled in according to request_type)
|
|
||||||
* If signature_index is set, 'signature' contains signed input of signature_index's input
|
|
||||||
* @prev SignTx
|
|
||||||
* @prev SimpleSignTx
|
|
||||||
* @prev TxAck
|
|
||||||
*/
|
|
||||||
message TxRequest {
|
|
||||||
optional RequestType request_type = 1; // what should be filled in TxAck message?
|
|
||||||
optional TxRequestDetailsType details = 2; // request for tx details
|
|
||||||
optional TxRequestSerializedType serialized = 3; // serialized data and request for next
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Reported transaction data
|
|
||||||
* @prev TxRequest
|
|
||||||
* @next TxRequest
|
|
||||||
*/
|
|
||||||
message TxAck {
|
|
||||||
optional TransactionType tx = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to sign transaction
|
|
||||||
* All fields are optional from the protocol's point of view. Each field defaults to value `0` if missing.
|
|
||||||
* Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
|
|
||||||
* @next PassphraseRequest
|
|
||||||
* @next PinMatrixRequest
|
|
||||||
* @next EthereumTxRequest
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message EthereumSignTx {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
optional bytes nonce = 2; // <=256 bit unsigned big endian
|
|
||||||
optional bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
|
|
||||||
optional bytes gas_limit = 4; // <=256 bit unsigned big endian
|
|
||||||
optional bytes to = 5; // 160 bit address hash
|
|
||||||
optional bytes value = 6; // <=256 bit unsigned big endian (in wei)
|
|
||||||
optional bytes data_initial_chunk = 7; // The initial data chunk (<= 1024 bytes)
|
|
||||||
optional uint32 data_length = 8; // Length of transaction payload
|
|
||||||
optional uint32 chain_id = 9; // Chain Id for EIP 155
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device asks for more data from transaction payload, or returns the signature.
|
|
||||||
* If data_length is set, device awaits that many more bytes of payload.
|
|
||||||
* Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
|
|
||||||
* @prev EthereumSignTx
|
|
||||||
* @next EthereumTxAck
|
|
||||||
*/
|
|
||||||
message EthereumTxRequest {
|
|
||||||
optional uint32 data_length = 1; // Number of bytes being requested (<= 1024)
|
|
||||||
optional uint32 signature_v = 2; // Computed signature (recovery parameter, limited to 27 or 28)
|
|
||||||
optional bytes signature_r = 3; // Computed signature R component (256 bit)
|
|
||||||
optional bytes signature_s = 4; // Computed signature S component (256 bit)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Transaction payload data.
|
|
||||||
* @prev EthereumTxRequest
|
|
||||||
* @next EthereumTxRequest
|
|
||||||
*/
|
|
||||||
message EthereumTxAck {
|
|
||||||
optional bytes data_chunk = 1; // Bytes from transaction payload (<= 1024 bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////
|
|
||||||
// Ethereum: Message signing messages //
|
|
||||||
////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to sign message
|
|
||||||
* @next EthereumMessageSignature
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message EthereumSignMessage {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
required bytes message = 2; // message to be signed
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to verify message
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message EthereumVerifyMessage {
|
|
||||||
optional bytes address = 1; // address to verify
|
|
||||||
optional bytes signature = 2; // signature to verify
|
|
||||||
optional bytes message = 3; // message to verify
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Signed message
|
|
||||||
* @prev EthereumSignMessage
|
|
||||||
*/
|
|
||||||
message EthereumMessageSignature {
|
|
||||||
optional bytes address = 1; // address used to sign the message
|
|
||||||
optional bytes signature = 2; // signature of the message
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////
|
|
||||||
// Identity messages //
|
|
||||||
///////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to sign identity
|
|
||||||
* @next SignedIdentity
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message SignIdentity {
|
|
||||||
optional IdentityType identity = 1; // identity
|
|
||||||
optional bytes challenge_hidden = 2; // non-visible challenge
|
|
||||||
optional string challenge_visual = 3; // challenge shown on display (e.g. date+time)
|
|
||||||
optional string ecdsa_curve_name = 4; // ECDSA curve name to use
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device provides signed identity
|
|
||||||
* @prev SignIdentity
|
|
||||||
*/
|
|
||||||
message SignedIdentity {
|
|
||||||
optional string address = 1; // identity address
|
|
||||||
optional bytes public_key = 2; // identity public key
|
|
||||||
optional bytes signature = 3; // signature of the identity data
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
// ECDH messages //
|
|
||||||
///////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to generate ECDH session key
|
|
||||||
* @next ECDHSessionKey
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message GetECDHSessionKey {
|
|
||||||
optional IdentityType identity = 1; // identity
|
|
||||||
optional bytes peer_public_key = 2; // peer's public key
|
|
||||||
optional string ecdsa_curve_name = 3; // ECDSA curve name to use
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device provides ECDH session key
|
|
||||||
* @prev GetECDHSessionKey
|
|
||||||
*/
|
|
||||||
message ECDHSessionKey {
|
|
||||||
optional bytes session_key = 1; // ECDH session key
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
// U2F messages //
|
|
||||||
///////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Set U2F counter
|
|
||||||
* @next Success
|
|
||||||
*/
|
|
||||||
message SetU2FCounter {
|
|
||||||
optional uint32 u2f_counter = 1; // counter
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////
|
|
||||||
// Bootloader messages //
|
|
||||||
/////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to erase its firmware (so it can be replaced via FirmwareUpload)
|
|
||||||
* @next Success
|
|
||||||
* @next FirmwareRequest
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message FirmwareErase {
|
|
||||||
optional uint32 length = 1; // length of new firmware
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Ask for firmware chunk
|
|
||||||
* @next FirmwareUpload
|
|
||||||
*/
|
|
||||||
message FirmwareRequest {
|
|
||||||
optional uint32 offset = 1; // offset of requested firmware chunk
|
|
||||||
optional uint32 length = 2; // length of requested firmware chunk
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Send firmware in binary form to the device
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message FirmwareUpload {
|
|
||||||
required bytes payload = 1; // firmware to be loaded into device
|
|
||||||
optional bytes hash = 2; // hash of the payload
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Perform a device self-test
|
|
||||||
* @next Success
|
|
||||||
* @next Failure
|
|
||||||
*/
|
|
||||||
message SelfTest {
|
|
||||||
optional bytes payload = 1; // payload to be used in self-test
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
// Debug messages (only available if DebugLink is enabled) //
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: "Press" the button on the device
|
|
||||||
* @next Success
|
|
||||||
*/
|
|
||||||
message DebugLinkDecision {
|
|
||||||
required bool yes_no = 1; // true for "Confirm", false for "Cancel"
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Computer asks for device state
|
|
||||||
* @next DebugLinkState
|
|
||||||
*/
|
|
||||||
message DebugLinkGetState {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device current state
|
|
||||||
* @prev DebugLinkGetState
|
|
||||||
*/
|
|
||||||
message DebugLinkState {
|
|
||||||
optional bytes layout = 1; // raw buffer of display
|
|
||||||
optional string pin = 2; // current PIN, blank if PIN is not set/enabled
|
|
||||||
optional string matrix = 3; // current PIN matrix
|
|
||||||
optional string mnemonic = 4; // current BIP-39 mnemonic
|
|
||||||
optional HDNodeType node = 5; // current BIP-32 node
|
|
||||||
optional bool passphrase_protection = 6; // is node/mnemonic encrypted using passphrase?
|
|
||||||
optional string reset_word = 7; // word on device display during ResetDevice workflow
|
|
||||||
optional bytes reset_entropy = 8; // current entropy during ResetDevice workflow
|
|
||||||
optional string recovery_fake_word = 9; // (fake) word on display during RecoveryDevice workflow
|
|
||||||
optional uint32 recovery_word_pos = 10; // index of mnemonic word the device is expecting during RecoveryDevice workflow
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Ask device to restart
|
|
||||||
*/
|
|
||||||
message DebugLinkStop {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device wants host to log event
|
|
||||||
*/
|
|
||||||
message DebugLinkLog {
|
|
||||||
optional uint32 level = 1;
|
|
||||||
optional string bucket = 2;
|
|
||||||
optional string text = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Read memory from device
|
|
||||||
* @next DebugLinkMemory
|
|
||||||
*/
|
|
||||||
message DebugLinkMemoryRead {
|
|
||||||
optional uint32 address = 1;
|
|
||||||
optional uint32 length = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Response: Device sends memory back
|
|
||||||
* @prev DebugLinkMemoryRead
|
|
||||||
*/
|
|
||||||
message DebugLinkMemory {
|
|
||||||
optional bytes memory = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Write memory to device.
|
|
||||||
* WARNING: Writing to the wrong location can irreparably break the device.
|
|
||||||
*/
|
|
||||||
message DebugLinkMemoryWrite {
|
|
||||||
optional uint32 address = 1;
|
|
||||||
optional bytes memory = 2;
|
|
||||||
optional bool flash = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Request: Erase block of flash on device
|
|
||||||
* WARNING: Writing to the wrong location can irreparably break the device.
|
|
||||||
*/
|
|
||||||
message DebugLinkFlashErase {
|
|
||||||
optional uint32 sector = 1;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
// Copyright 2017 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
// This file contains the implementation for interacting with the Trezor hardware
|
|
||||||
// wallets. The wire protocol spec can be found on the SatoshiLabs website:
|
|
||||||
// https://doc.satoshilabs.com/trezor-tech/api-protobuf.html
|
|
||||||
|
|
||||||
//go:generate protoc --go_out=import_path=trezor:. types.proto messages.proto
|
|
||||||
|
|
||||||
// Package trezor contains the wire protocol wrapper in Go.
|
|
||||||
package trezor
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Type returns the protocol buffer type number of a specific message. If the
|
|
||||||
// message is nil, this method panics!
|
|
||||||
func Type(msg proto.Message) uint16 {
|
|
||||||
return uint16(MessageType_value["MessageType_"+reflect.TypeOf(msg).Elem().Name()])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name returns the friendly message type name of a specific protocol buffer
|
|
||||||
// type number.
|
|
||||||
func Name(kind uint16) string {
|
|
||||||
name := MessageType_name[int32(kind)]
|
|
||||||
if len(name) < 12 {
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
return name[12:]
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,278 +0,0 @@
|
|||||||
// This file originates from the SatoshiLabs Trezor `common` repository at:
|
|
||||||
// https://github.com/trezor/trezor-common/blob/master/protob/types.proto
|
|
||||||
// dated 28.07.2017, commit dd8ec3231fb5f7992360aff9bdfe30bb58130f4b.
|
|
||||||
|
|
||||||
syntax = "proto2";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Types for TREZOR communication
|
|
||||||
*
|
|
||||||
* @author Marek Palatinus <slush@satoshilabs.com>
|
|
||||||
* @version 1.2
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Sugar for easier handling in Java
|
|
||||||
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
|
||||||
option java_outer_classname = "TrezorType";
|
|
||||||
|
|
||||||
import "google/protobuf/descriptor.proto";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options for specifying message direction and type of wire (normal/debug)
|
|
||||||
*/
|
|
||||||
extend google.protobuf.EnumValueOptions {
|
|
||||||
optional bool wire_in = 50002; // message can be transmitted via wire from PC to TREZOR
|
|
||||||
optional bool wire_out = 50003; // message can be transmitted via wire from TREZOR to PC
|
|
||||||
optional bool wire_debug_in = 50004; // message can be transmitted via debug wire from PC to TREZOR
|
|
||||||
optional bool wire_debug_out = 50005; // message can be transmitted via debug wire from TREZOR to PC
|
|
||||||
optional bool wire_tiny = 50006; // message is handled by TREZOR when the USB stack is in tiny mode
|
|
||||||
optional bool wire_bootloader = 50007; // message is only handled by TREZOR Bootloader
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of failures returned by Failure message
|
|
||||||
* @used_in Failure
|
|
||||||
*/
|
|
||||||
enum FailureType {
|
|
||||||
Failure_UnexpectedMessage = 1;
|
|
||||||
Failure_ButtonExpected = 2;
|
|
||||||
Failure_DataError = 3;
|
|
||||||
Failure_ActionCancelled = 4;
|
|
||||||
Failure_PinExpected = 5;
|
|
||||||
Failure_PinCancelled = 6;
|
|
||||||
Failure_PinInvalid = 7;
|
|
||||||
Failure_InvalidSignature = 8;
|
|
||||||
Failure_ProcessError = 9;
|
|
||||||
Failure_NotEnoughFunds = 10;
|
|
||||||
Failure_NotInitialized = 11;
|
|
||||||
Failure_FirmwareError = 99;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of script which will be used for transaction output
|
|
||||||
* @used_in TxOutputType
|
|
||||||
*/
|
|
||||||
enum OutputScriptType {
|
|
||||||
PAYTOADDRESS = 0; // used for all addresses (bitcoin, p2sh, witness)
|
|
||||||
PAYTOSCRIPTHASH = 1; // p2sh address (deprecated; use PAYTOADDRESS)
|
|
||||||
PAYTOMULTISIG = 2; // only for change output
|
|
||||||
PAYTOOPRETURN = 3; // op_return
|
|
||||||
PAYTOWITNESS = 4; // only for change output
|
|
||||||
PAYTOP2SHWITNESS = 5; // only for change output
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of script which will be used for transaction output
|
|
||||||
* @used_in TxInputType
|
|
||||||
*/
|
|
||||||
enum InputScriptType {
|
|
||||||
SPENDADDRESS = 0; // standard p2pkh address
|
|
||||||
SPENDMULTISIG = 1; // p2sh multisig address
|
|
||||||
EXTERNAL = 2; // reserved for external inputs (coinjoin)
|
|
||||||
SPENDWITNESS = 3; // native segwit
|
|
||||||
SPENDP2SHWITNESS = 4; // segwit over p2sh (backward compatible)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of information required by transaction signing process
|
|
||||||
* @used_in TxRequest
|
|
||||||
*/
|
|
||||||
enum RequestType {
|
|
||||||
TXINPUT = 0;
|
|
||||||
TXOUTPUT = 1;
|
|
||||||
TXMETA = 2;
|
|
||||||
TXFINISHED = 3;
|
|
||||||
TXEXTRADATA = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of button request
|
|
||||||
* @used_in ButtonRequest
|
|
||||||
*/
|
|
||||||
enum ButtonRequestType {
|
|
||||||
ButtonRequest_Other = 1;
|
|
||||||
ButtonRequest_FeeOverThreshold = 2;
|
|
||||||
ButtonRequest_ConfirmOutput = 3;
|
|
||||||
ButtonRequest_ResetDevice = 4;
|
|
||||||
ButtonRequest_ConfirmWord = 5;
|
|
||||||
ButtonRequest_WipeDevice = 6;
|
|
||||||
ButtonRequest_ProtectCall = 7;
|
|
||||||
ButtonRequest_SignTx = 8;
|
|
||||||
ButtonRequest_FirmwareCheck = 9;
|
|
||||||
ButtonRequest_Address = 10;
|
|
||||||
ButtonRequest_PublicKey = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of PIN request
|
|
||||||
* @used_in PinMatrixRequest
|
|
||||||
*/
|
|
||||||
enum PinMatrixRequestType {
|
|
||||||
PinMatrixRequestType_Current = 1;
|
|
||||||
PinMatrixRequestType_NewFirst = 2;
|
|
||||||
PinMatrixRequestType_NewSecond = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of recovery procedure. These should be used as bitmask, e.g.,
|
|
||||||
* `RecoveryDeviceType_ScrambledWords | RecoveryDeviceType_Matrix`
|
|
||||||
* listing every method supported by the host computer.
|
|
||||||
*
|
|
||||||
* Note that ScrambledWords must be supported by every implementation
|
|
||||||
* for backward compatibility; there is no way to not support it.
|
|
||||||
*
|
|
||||||
* @used_in RecoveryDevice
|
|
||||||
*/
|
|
||||||
enum RecoveryDeviceType {
|
|
||||||
// use powers of two when extending this field
|
|
||||||
RecoveryDeviceType_ScrambledWords = 0; // words in scrambled order
|
|
||||||
RecoveryDeviceType_Matrix = 1; // matrix recovery type
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of Recovery Word request
|
|
||||||
* @used_in WordRequest
|
|
||||||
*/
|
|
||||||
enum WordRequestType {
|
|
||||||
WordRequestType_Plain = 0;
|
|
||||||
WordRequestType_Matrix9 = 1;
|
|
||||||
WordRequestType_Matrix6 = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing BIP32 (hierarchical deterministic) node
|
|
||||||
* Used for imports of private key into the device and exporting public key out of device
|
|
||||||
* @used_in PublicKey
|
|
||||||
* @used_in LoadDevice
|
|
||||||
* @used_in DebugLinkState
|
|
||||||
* @used_in Storage
|
|
||||||
*/
|
|
||||||
message HDNodeType {
|
|
||||||
required uint32 depth = 1;
|
|
||||||
required uint32 fingerprint = 2;
|
|
||||||
required uint32 child_num = 3;
|
|
||||||
required bytes chain_code = 4;
|
|
||||||
optional bytes private_key = 5;
|
|
||||||
optional bytes public_key = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
message HDNodePathType {
|
|
||||||
required HDNodeType node = 1; // BIP-32 node in deserialized form
|
|
||||||
repeated uint32 address_n = 2; // BIP-32 path to derive the key from node
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing Coin
|
|
||||||
* @used_in Features
|
|
||||||
*/
|
|
||||||
message CoinType {
|
|
||||||
optional string coin_name = 1;
|
|
||||||
optional string coin_shortcut = 2;
|
|
||||||
optional uint32 address_type = 3 [default=0];
|
|
||||||
optional uint64 maxfee_kb = 4;
|
|
||||||
optional uint32 address_type_p2sh = 5 [default=5];
|
|
||||||
optional string signed_message_header = 8;
|
|
||||||
optional uint32 xpub_magic = 9 [default=76067358]; // default=0x0488b21e
|
|
||||||
optional uint32 xprv_magic = 10 [default=76066276]; // default=0x0488ade4
|
|
||||||
optional bool segwit = 11;
|
|
||||||
optional uint32 forkid = 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of redeem script used in input
|
|
||||||
* @used_in TxInputType
|
|
||||||
*/
|
|
||||||
message MultisigRedeemScriptType {
|
|
||||||
repeated HDNodePathType pubkeys = 1; // pubkeys from multisig address (sorted lexicographically)
|
|
||||||
repeated bytes signatures = 2; // existing signatures for partially signed input
|
|
||||||
optional uint32 m = 3; // "m" from n, how many valid signatures is necessary for spending
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing transaction input
|
|
||||||
* @used_in SimpleSignTx
|
|
||||||
* @used_in TransactionType
|
|
||||||
*/
|
|
||||||
message TxInputType {
|
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
||||||
required bytes prev_hash = 2; // hash of previous transaction output to spend by this input
|
|
||||||
required uint32 prev_index = 3; // index of previous output to spend
|
|
||||||
optional bytes script_sig = 4; // script signature, unset for tx to sign
|
|
||||||
optional uint32 sequence = 5 [default=4294967295]; // sequence (default=0xffffffff)
|
|
||||||
optional InputScriptType script_type = 6 [default=SPENDADDRESS]; // defines template of input script
|
|
||||||
optional MultisigRedeemScriptType multisig = 7; // Filled if input is going to spend multisig tx
|
|
||||||
optional uint64 amount = 8; // amount of previous transaction output (for segwit only)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing transaction output
|
|
||||||
* @used_in SimpleSignTx
|
|
||||||
* @used_in TransactionType
|
|
||||||
*/
|
|
||||||
message TxOutputType {
|
|
||||||
optional string address = 1; // target coin address in Base58 encoding
|
|
||||||
repeated uint32 address_n = 2; // BIP-32 path to derive the key from master node; has higher priority than "address"
|
|
||||||
required uint64 amount = 3; // amount to spend in satoshis
|
|
||||||
required OutputScriptType script_type = 4; // output script type
|
|
||||||
optional MultisigRedeemScriptType multisig = 5; // defines multisig address; script_type must be PAYTOMULTISIG
|
|
||||||
optional bytes op_return_data = 6; // defines op_return data; script_type must be PAYTOOPRETURN, amount must be 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing compiled transaction output
|
|
||||||
* @used_in TransactionType
|
|
||||||
*/
|
|
||||||
message TxOutputBinType {
|
|
||||||
required uint64 amount = 1;
|
|
||||||
required bytes script_pubkey = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing transaction
|
|
||||||
* @used_in SimpleSignTx
|
|
||||||
*/
|
|
||||||
message TransactionType {
|
|
||||||
optional uint32 version = 1;
|
|
||||||
repeated TxInputType inputs = 2;
|
|
||||||
repeated TxOutputBinType bin_outputs = 3;
|
|
||||||
repeated TxOutputType outputs = 5;
|
|
||||||
optional uint32 lock_time = 4;
|
|
||||||
optional uint32 inputs_cnt = 6;
|
|
||||||
optional uint32 outputs_cnt = 7;
|
|
||||||
optional bytes extra_data = 8;
|
|
||||||
optional uint32 extra_data_len = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing request details
|
|
||||||
* @used_in TxRequest
|
|
||||||
*/
|
|
||||||
message TxRequestDetailsType {
|
|
||||||
optional uint32 request_index = 1; // device expects TxAck message from the computer
|
|
||||||
optional bytes tx_hash = 2; // tx_hash of requested transaction
|
|
||||||
optional uint32 extra_data_len = 3; // length of requested extra data
|
|
||||||
optional uint32 extra_data_offset = 4; // offset of requested extra data
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing serialized data
|
|
||||||
* @used_in TxRequest
|
|
||||||
*/
|
|
||||||
message TxRequestSerializedType {
|
|
||||||
optional uint32 signature_index = 1; // 'signature' field contains signed input of this index
|
|
||||||
optional bytes signature = 2; // signature of the signature_index input
|
|
||||||
optional bytes serialized_tx = 3; // part of serialized and signed transaction
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure representing identity data
|
|
||||||
* @used_in IdentityType
|
|
||||||
*/
|
|
||||||
message IdentityType {
|
|
||||||
optional string proto = 1; // proto part of URI
|
|
||||||
optional string user = 2; // user part of URI
|
|
||||||
optional string host = 3; // host part of URI
|
|
||||||
optional string port = 4; // port part of URI
|
|
||||||
optional string path = 5; // path part of URI
|
|
||||||
optional uint32 index = 6 [default=0]; // identity index
|
|
||||||
}
|
|
||||||
@@ -32,6 +32,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
@@ -341,7 +342,7 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
op = ledgerP1ContTransactionData
|
op = ledgerP1ContTransactionData
|
||||||
}
|
}
|
||||||
// Extract the Ethereum signature and do a sanity validation
|
// Extract the Ethereum signature and do a sanity validation
|
||||||
if len(reply) != 65 {
|
if len(reply) != crypto.SignatureLength {
|
||||||
return common.Address{}, nil, errors.New("reply lacks signature")
|
return common.Address{}, nil, errors.New("reply lacks signature")
|
||||||
}
|
}
|
||||||
signature := append(reply[1:], reply[0])
|
signature := append(reply[1:], reply[0])
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/accounts/usbwallet/internal/trezor"
|
"github.com/ethereum/go-ethereum/accounts/usbwallet/trezor"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
@@ -41,6 +41,9 @@ import (
|
|||||||
// encoded passphrase.
|
// encoded passphrase.
|
||||||
var ErrTrezorPINNeeded = errors.New("trezor: pin needed")
|
var ErrTrezorPINNeeded = errors.New("trezor: pin needed")
|
||||||
|
|
||||||
|
// ErrTrezorPassphraseNeeded is returned if opening the trezor requires a passphrase
|
||||||
|
var ErrTrezorPassphraseNeeded = errors.New("trezor: passphrase needed")
|
||||||
|
|
||||||
// errTrezorReplyInvalidHeader is the error message returned by a Trezor data exchange
|
// errTrezorReplyInvalidHeader is the error message returned by a Trezor data exchange
|
||||||
// if the device replies with a mismatching header. This usually means the device
|
// if the device replies with a mismatching header. This usually means the device
|
||||||
// is in browser mode.
|
// is in browser mode.
|
||||||
@@ -48,12 +51,13 @@ var errTrezorReplyInvalidHeader = errors.New("trezor: invalid reply header")
|
|||||||
|
|
||||||
// trezorDriver implements the communication with a Trezor hardware wallet.
|
// trezorDriver implements the communication with a Trezor hardware wallet.
|
||||||
type trezorDriver struct {
|
type trezorDriver struct {
|
||||||
device io.ReadWriter // USB device connection to communicate through
|
device io.ReadWriter // USB device connection to communicate through
|
||||||
version [3]uint32 // Current version of the Trezor firmware
|
version [3]uint32 // Current version of the Trezor firmware
|
||||||
label string // Current textual label of the Trezor device
|
label string // Current textual label of the Trezor device
|
||||||
pinwait bool // Flags whether the device is waiting for PIN entry
|
pinwait bool // Flags whether the device is waiting for PIN entry
|
||||||
failure error // Any failure that would make the device unusable
|
passphrasewait bool // Flags whether the device is waiting for passphrase entry
|
||||||
log log.Logger // Contextual logger to tag the trezor with its id
|
failure error // Any failure that would make the device unusable
|
||||||
|
log log.Logger // Contextual logger to tag the trezor with its id
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTrezorDriver creates a new instance of a Trezor USB protocol driver.
|
// newTrezorDriver creates a new instance of a Trezor USB protocol driver.
|
||||||
@@ -79,19 +83,21 @@ func (w *trezorDriver) Status() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open implements usbwallet.driver, attempting to initialize the connection to
|
// Open implements usbwallet.driver, attempting to initialize the connection to
|
||||||
// the Trezor hardware wallet. Initializing the Trezor is a two phase operation:
|
// the Trezor hardware wallet. Initializing the Trezor is a two or three phase operation:
|
||||||
// * The first phase is to initialize the connection and read the wallet's
|
// * The first phase is to initialize the connection and read the wallet's
|
||||||
// features. This phase is invoked is the provided passphrase is empty. The
|
// features. This phase is invoked if the provided passphrase is empty. The
|
||||||
// device will display the pinpad as a result and will return an appropriate
|
// device will display the pinpad as a result and will return an appropriate
|
||||||
// error to notify the user that a second open phase is needed.
|
// error to notify the user that a second open phase is needed.
|
||||||
// * The second phase is to unlock access to the Trezor, which is done by the
|
// * The second phase is to unlock access to the Trezor, which is done by the
|
||||||
// user actually providing a passphrase mapping a keyboard keypad to the pin
|
// user actually providing a passphrase mapping a keyboard keypad to the pin
|
||||||
// number of the user (shuffled according to the pinpad displayed).
|
// number of the user (shuffled according to the pinpad displayed).
|
||||||
|
// * If needed the device will ask for passphrase which will require calling
|
||||||
|
// open again with the actual passphrase (3rd phase)
|
||||||
func (w *trezorDriver) Open(device io.ReadWriter, passphrase string) error {
|
func (w *trezorDriver) Open(device io.ReadWriter, passphrase string) error {
|
||||||
w.device, w.failure = device, nil
|
w.device, w.failure = device, nil
|
||||||
|
|
||||||
// If phase 1 is requested, init the connection and wait for user callback
|
// If phase 1 is requested, init the connection and wait for user callback
|
||||||
if passphrase == "" {
|
if passphrase == "" && !w.passphrasewait {
|
||||||
// If we're already waiting for a PIN entry, insta-return
|
// If we're already waiting for a PIN entry, insta-return
|
||||||
if w.pinwait {
|
if w.pinwait {
|
||||||
return ErrTrezorPINNeeded
|
return ErrTrezorPINNeeded
|
||||||
@@ -104,26 +110,46 @@ func (w *trezorDriver) Open(device io.ReadWriter, passphrase string) error {
|
|||||||
w.version = [3]uint32{features.GetMajorVersion(), features.GetMinorVersion(), features.GetPatchVersion()}
|
w.version = [3]uint32{features.GetMajorVersion(), features.GetMinorVersion(), features.GetPatchVersion()}
|
||||||
w.label = features.GetLabel()
|
w.label = features.GetLabel()
|
||||||
|
|
||||||
// Do a manual ping, forcing the device to ask for its PIN
|
// Do a manual ping, forcing the device to ask for its PIN and Passphrase
|
||||||
askPin := true
|
askPin := true
|
||||||
res, err := w.trezorExchange(&trezor.Ping{PinProtection: &askPin}, new(trezor.PinMatrixRequest), new(trezor.Success))
|
askPassphrase := true
|
||||||
|
res, err := w.trezorExchange(&trezor.Ping{PinProtection: &askPin, PassphraseProtection: &askPassphrase}, new(trezor.PinMatrixRequest), new(trezor.PassphraseRequest), new(trezor.Success))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Only return the PIN request if the device wasn't unlocked until now
|
// Only return the PIN request if the device wasn't unlocked until now
|
||||||
if res == 1 {
|
switch res {
|
||||||
return nil // Device responded with trezor.Success
|
case 0:
|
||||||
|
w.pinwait = true
|
||||||
|
return ErrTrezorPINNeeded
|
||||||
|
case 1:
|
||||||
|
w.pinwait = false
|
||||||
|
w.passphrasewait = true
|
||||||
|
return ErrTrezorPassphraseNeeded
|
||||||
|
case 2:
|
||||||
|
return nil // responded with trezor.Success
|
||||||
}
|
}
|
||||||
w.pinwait = true
|
|
||||||
return ErrTrezorPINNeeded
|
|
||||||
}
|
}
|
||||||
// Phase 2 requested with actual PIN entry
|
// Phase 2 requested with actual PIN entry
|
||||||
w.pinwait = false
|
if w.pinwait {
|
||||||
|
w.pinwait = false
|
||||||
if _, err := w.trezorExchange(&trezor.PinMatrixAck{Pin: &passphrase}, new(trezor.Success)); err != nil {
|
res, err := w.trezorExchange(&trezor.PinMatrixAck{Pin: &passphrase}, new(trezor.Success), new(trezor.PassphraseRequest))
|
||||||
w.failure = err
|
if err != nil {
|
||||||
return err
|
w.failure = err
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if res == 1 {
|
||||||
|
w.passphrasewait = true
|
||||||
|
return ErrTrezorPassphraseNeeded
|
||||||
|
}
|
||||||
|
} else if w.passphrasewait {
|
||||||
|
w.passphrasewait = false
|
||||||
|
if _, err := w.trezorExchange(&trezor.PassphraseAck{Passphrase: &passphrase}, new(trezor.Success)); err != nil {
|
||||||
|
w.failure = err
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +192,13 @@ func (w *trezorDriver) trezorDerive(derivationPath []uint32) (common.Address, er
|
|||||||
if _, err := w.trezorExchange(&trezor.EthereumGetAddress{AddressN: derivationPath}, address); err != nil {
|
if _, err := w.trezorExchange(&trezor.EthereumGetAddress{AddressN: derivationPath}, address); err != nil {
|
||||||
return common.Address{}, err
|
return common.Address{}, err
|
||||||
}
|
}
|
||||||
return common.BytesToAddress(address.GetAddress()), nil
|
if addr := address.GetAddressBin(); len(addr) > 0 { // Older firmwares use binary fomats
|
||||||
|
return common.BytesToAddress(addr), nil
|
||||||
|
}
|
||||||
|
if addr := address.GetAddressHex(); len(addr) > 0 { // Newer firmwares use hexadecimal fomats
|
||||||
|
return common.HexToAddress(addr), nil
|
||||||
|
}
|
||||||
|
return common.Address{}, errors.New("missing derived address")
|
||||||
}
|
}
|
||||||
|
|
||||||
// trezorSign sends the transaction to the Trezor wallet, and waits for the user
|
// trezorSign sends the transaction to the Trezor wallet, and waits for the user
|
||||||
@@ -185,7 +217,10 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
|
|||||||
DataLength: &length,
|
DataLength: &length,
|
||||||
}
|
}
|
||||||
if to := tx.To(); to != nil {
|
if to := tx.To(); to != nil {
|
||||||
request.To = (*to)[:] // Non contract deploy, set recipient explicitly
|
// Non contract deploy, set recipient explicitly
|
||||||
|
hex := to.Hex()
|
||||||
|
request.ToHex = &hex // Newer firmwares (old will ignore)
|
||||||
|
request.ToBin = (*to)[:] // Older firmwares (new will ignore)
|
||||||
}
|
}
|
||||||
if length > 1024 { // Send the data chunked if that was requested
|
if length > 1024 { // Send the data chunked if that was requested
|
||||||
request.DataInitialChunk, data = data[:1024], data[1024:]
|
request.DataInitialChunk, data = data[:1024], data[1024:]
|
||||||
|
|||||||
811
accounts/usbwallet/trezor/messages-common.pb.go
Normal file
811
accounts/usbwallet/trezor/messages-common.pb.go
Normal file
@@ -0,0 +1,811 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// source: messages-common.proto
|
||||||
|
|
||||||
|
package trezor
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
math "math"
|
||||||
|
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
type Failure_FailureType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
Failure_Failure_UnexpectedMessage Failure_FailureType = 1
|
||||||
|
Failure_Failure_ButtonExpected Failure_FailureType = 2
|
||||||
|
Failure_Failure_DataError Failure_FailureType = 3
|
||||||
|
Failure_Failure_ActionCancelled Failure_FailureType = 4
|
||||||
|
Failure_Failure_PinExpected Failure_FailureType = 5
|
||||||
|
Failure_Failure_PinCancelled Failure_FailureType = 6
|
||||||
|
Failure_Failure_PinInvalid Failure_FailureType = 7
|
||||||
|
Failure_Failure_InvalidSignature Failure_FailureType = 8
|
||||||
|
Failure_Failure_ProcessError Failure_FailureType = 9
|
||||||
|
Failure_Failure_NotEnoughFunds Failure_FailureType = 10
|
||||||
|
Failure_Failure_NotInitialized Failure_FailureType = 11
|
||||||
|
Failure_Failure_PinMismatch Failure_FailureType = 12
|
||||||
|
Failure_Failure_FirmwareError Failure_FailureType = 99
|
||||||
|
)
|
||||||
|
|
||||||
|
var Failure_FailureType_name = map[int32]string{
|
||||||
|
1: "Failure_UnexpectedMessage",
|
||||||
|
2: "Failure_ButtonExpected",
|
||||||
|
3: "Failure_DataError",
|
||||||
|
4: "Failure_ActionCancelled",
|
||||||
|
5: "Failure_PinExpected",
|
||||||
|
6: "Failure_PinCancelled",
|
||||||
|
7: "Failure_PinInvalid",
|
||||||
|
8: "Failure_InvalidSignature",
|
||||||
|
9: "Failure_ProcessError",
|
||||||
|
10: "Failure_NotEnoughFunds",
|
||||||
|
11: "Failure_NotInitialized",
|
||||||
|
12: "Failure_PinMismatch",
|
||||||
|
99: "Failure_FirmwareError",
|
||||||
|
}
|
||||||
|
|
||||||
|
var Failure_FailureType_value = map[string]int32{
|
||||||
|
"Failure_UnexpectedMessage": 1,
|
||||||
|
"Failure_ButtonExpected": 2,
|
||||||
|
"Failure_DataError": 3,
|
||||||
|
"Failure_ActionCancelled": 4,
|
||||||
|
"Failure_PinExpected": 5,
|
||||||
|
"Failure_PinCancelled": 6,
|
||||||
|
"Failure_PinInvalid": 7,
|
||||||
|
"Failure_InvalidSignature": 8,
|
||||||
|
"Failure_ProcessError": 9,
|
||||||
|
"Failure_NotEnoughFunds": 10,
|
||||||
|
"Failure_NotInitialized": 11,
|
||||||
|
"Failure_PinMismatch": 12,
|
||||||
|
"Failure_FirmwareError": 99,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Failure_FailureType) Enum() *Failure_FailureType {
|
||||||
|
p := new(Failure_FailureType)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Failure_FailureType) String() string {
|
||||||
|
return proto.EnumName(Failure_FailureType_name, int32(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Failure_FailureType) UnmarshalJSON(data []byte) error {
|
||||||
|
value, err := proto.UnmarshalJSONEnum(Failure_FailureType_value, data, "Failure_FailureType")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*x = Failure_FailureType(value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Failure_FailureType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{1, 0}
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Type of button request
|
||||||
|
type ButtonRequest_ButtonRequestType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
ButtonRequest_ButtonRequest_Other ButtonRequest_ButtonRequestType = 1
|
||||||
|
ButtonRequest_ButtonRequest_FeeOverThreshold ButtonRequest_ButtonRequestType = 2
|
||||||
|
ButtonRequest_ButtonRequest_ConfirmOutput ButtonRequest_ButtonRequestType = 3
|
||||||
|
ButtonRequest_ButtonRequest_ResetDevice ButtonRequest_ButtonRequestType = 4
|
||||||
|
ButtonRequest_ButtonRequest_ConfirmWord ButtonRequest_ButtonRequestType = 5
|
||||||
|
ButtonRequest_ButtonRequest_WipeDevice ButtonRequest_ButtonRequestType = 6
|
||||||
|
ButtonRequest_ButtonRequest_ProtectCall ButtonRequest_ButtonRequestType = 7
|
||||||
|
ButtonRequest_ButtonRequest_SignTx ButtonRequest_ButtonRequestType = 8
|
||||||
|
ButtonRequest_ButtonRequest_FirmwareCheck ButtonRequest_ButtonRequestType = 9
|
||||||
|
ButtonRequest_ButtonRequest_Address ButtonRequest_ButtonRequestType = 10
|
||||||
|
ButtonRequest_ButtonRequest_PublicKey ButtonRequest_ButtonRequestType = 11
|
||||||
|
ButtonRequest_ButtonRequest_MnemonicWordCount ButtonRequest_ButtonRequestType = 12
|
||||||
|
ButtonRequest_ButtonRequest_MnemonicInput ButtonRequest_ButtonRequestType = 13
|
||||||
|
ButtonRequest_ButtonRequest_PassphraseType ButtonRequest_ButtonRequestType = 14
|
||||||
|
ButtonRequest_ButtonRequest_UnknownDerivationPath ButtonRequest_ButtonRequestType = 15
|
||||||
|
)
|
||||||
|
|
||||||
|
var ButtonRequest_ButtonRequestType_name = map[int32]string{
|
||||||
|
1: "ButtonRequest_Other",
|
||||||
|
2: "ButtonRequest_FeeOverThreshold",
|
||||||
|
3: "ButtonRequest_ConfirmOutput",
|
||||||
|
4: "ButtonRequest_ResetDevice",
|
||||||
|
5: "ButtonRequest_ConfirmWord",
|
||||||
|
6: "ButtonRequest_WipeDevice",
|
||||||
|
7: "ButtonRequest_ProtectCall",
|
||||||
|
8: "ButtonRequest_SignTx",
|
||||||
|
9: "ButtonRequest_FirmwareCheck",
|
||||||
|
10: "ButtonRequest_Address",
|
||||||
|
11: "ButtonRequest_PublicKey",
|
||||||
|
12: "ButtonRequest_MnemonicWordCount",
|
||||||
|
13: "ButtonRequest_MnemonicInput",
|
||||||
|
14: "ButtonRequest_PassphraseType",
|
||||||
|
15: "ButtonRequest_UnknownDerivationPath",
|
||||||
|
}
|
||||||
|
|
||||||
|
var ButtonRequest_ButtonRequestType_value = map[string]int32{
|
||||||
|
"ButtonRequest_Other": 1,
|
||||||
|
"ButtonRequest_FeeOverThreshold": 2,
|
||||||
|
"ButtonRequest_ConfirmOutput": 3,
|
||||||
|
"ButtonRequest_ResetDevice": 4,
|
||||||
|
"ButtonRequest_ConfirmWord": 5,
|
||||||
|
"ButtonRequest_WipeDevice": 6,
|
||||||
|
"ButtonRequest_ProtectCall": 7,
|
||||||
|
"ButtonRequest_SignTx": 8,
|
||||||
|
"ButtonRequest_FirmwareCheck": 9,
|
||||||
|
"ButtonRequest_Address": 10,
|
||||||
|
"ButtonRequest_PublicKey": 11,
|
||||||
|
"ButtonRequest_MnemonicWordCount": 12,
|
||||||
|
"ButtonRequest_MnemonicInput": 13,
|
||||||
|
"ButtonRequest_PassphraseType": 14,
|
||||||
|
"ButtonRequest_UnknownDerivationPath": 15,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x ButtonRequest_ButtonRequestType) Enum() *ButtonRequest_ButtonRequestType {
|
||||||
|
p := new(ButtonRequest_ButtonRequestType)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x ButtonRequest_ButtonRequestType) String() string {
|
||||||
|
return proto.EnumName(ButtonRequest_ButtonRequestType_name, int32(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ButtonRequest_ButtonRequestType) UnmarshalJSON(data []byte) error {
|
||||||
|
value, err := proto.UnmarshalJSONEnum(ButtonRequest_ButtonRequestType_value, data, "ButtonRequest_ButtonRequestType")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*x = ButtonRequest_ButtonRequestType(value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ButtonRequest_ButtonRequestType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{2, 0}
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Type of PIN request
|
||||||
|
type PinMatrixRequest_PinMatrixRequestType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
PinMatrixRequest_PinMatrixRequestType_Current PinMatrixRequest_PinMatrixRequestType = 1
|
||||||
|
PinMatrixRequest_PinMatrixRequestType_NewFirst PinMatrixRequest_PinMatrixRequestType = 2
|
||||||
|
PinMatrixRequest_PinMatrixRequestType_NewSecond PinMatrixRequest_PinMatrixRequestType = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
var PinMatrixRequest_PinMatrixRequestType_name = map[int32]string{
|
||||||
|
1: "PinMatrixRequestType_Current",
|
||||||
|
2: "PinMatrixRequestType_NewFirst",
|
||||||
|
3: "PinMatrixRequestType_NewSecond",
|
||||||
|
}
|
||||||
|
|
||||||
|
var PinMatrixRequest_PinMatrixRequestType_value = map[string]int32{
|
||||||
|
"PinMatrixRequestType_Current": 1,
|
||||||
|
"PinMatrixRequestType_NewFirst": 2,
|
||||||
|
"PinMatrixRequestType_NewSecond": 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x PinMatrixRequest_PinMatrixRequestType) Enum() *PinMatrixRequest_PinMatrixRequestType {
|
||||||
|
p := new(PinMatrixRequest_PinMatrixRequestType)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x PinMatrixRequest_PinMatrixRequestType) String() string {
|
||||||
|
return proto.EnumName(PinMatrixRequest_PinMatrixRequestType_name, int32(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *PinMatrixRequest_PinMatrixRequestType) UnmarshalJSON(data []byte) error {
|
||||||
|
value, err := proto.UnmarshalJSONEnum(PinMatrixRequest_PinMatrixRequestType_value, data, "PinMatrixRequest_PinMatrixRequestType")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*x = PinMatrixRequest_PinMatrixRequestType(value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (PinMatrixRequest_PinMatrixRequestType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{4, 0}
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Success of the previous request
|
||||||
|
// @end
|
||||||
|
type Success struct {
|
||||||
|
Message *string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Success) Reset() { *m = Success{} }
|
||||||
|
func (m *Success) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Success) ProtoMessage() {}
|
||||||
|
func (*Success) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Success) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Success.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Success) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Success.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *Success) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Success.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Success) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Success.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Success) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Success.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Success proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Success) GetMessage() string {
|
||||||
|
if m != nil && m.Message != nil {
|
||||||
|
return *m.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Failure of the previous request
|
||||||
|
// @end
|
||||||
|
type Failure struct {
|
||||||
|
Code *Failure_FailureType `protobuf:"varint,1,opt,name=code,enum=hw.trezor.messages.common.Failure_FailureType" json:"code,omitempty"`
|
||||||
|
Message *string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Failure) Reset() { *m = Failure{} }
|
||||||
|
func (m *Failure) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Failure) ProtoMessage() {}
|
||||||
|
func (*Failure) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Failure) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Failure.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Failure) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Failure.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *Failure) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Failure.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Failure) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Failure.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Failure) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Failure.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Failure proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Failure) GetCode() Failure_FailureType {
|
||||||
|
if m != nil && m.Code != nil {
|
||||||
|
return *m.Code
|
||||||
|
}
|
||||||
|
return Failure_Failure_UnexpectedMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Failure) GetMessage() string {
|
||||||
|
if m != nil && m.Message != nil {
|
||||||
|
return *m.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Device is waiting for HW button press.
|
||||||
|
// @auxstart
|
||||||
|
// @next ButtonAck
|
||||||
|
type ButtonRequest struct {
|
||||||
|
Code *ButtonRequest_ButtonRequestType `protobuf:"varint,1,opt,name=code,enum=hw.trezor.messages.common.ButtonRequest_ButtonRequestType" json:"code,omitempty"`
|
||||||
|
Data *string `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ButtonRequest) Reset() { *m = ButtonRequest{} }
|
||||||
|
func (m *ButtonRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*ButtonRequest) ProtoMessage() {}
|
||||||
|
func (*ButtonRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ButtonRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_ButtonRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *ButtonRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_ButtonRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *ButtonRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ButtonRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *ButtonRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_ButtonRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *ButtonRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ButtonRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ButtonRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *ButtonRequest) GetCode() ButtonRequest_ButtonRequestType {
|
||||||
|
if m != nil && m.Code != nil {
|
||||||
|
return *m.Code
|
||||||
|
}
|
||||||
|
return ButtonRequest_ButtonRequest_Other
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ButtonRequest) GetData() string {
|
||||||
|
if m != nil && m.Data != nil {
|
||||||
|
return *m.Data
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Computer agrees to wait for HW button press
|
||||||
|
// @auxend
|
||||||
|
type ButtonAck struct {
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ButtonAck) Reset() { *m = ButtonAck{} }
|
||||||
|
func (m *ButtonAck) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*ButtonAck) ProtoMessage() {}
|
||||||
|
func (*ButtonAck) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ButtonAck) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_ButtonAck.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *ButtonAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_ButtonAck.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *ButtonAck) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ButtonAck.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *ButtonAck) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_ButtonAck.Size(m)
|
||||||
|
}
|
||||||
|
func (m *ButtonAck) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ButtonAck.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ButtonAck proto.InternalMessageInfo
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Device is asking computer to show PIN matrix and awaits PIN encoded using this matrix scheme
|
||||||
|
// @auxstart
|
||||||
|
// @next PinMatrixAck
|
||||||
|
type PinMatrixRequest struct {
|
||||||
|
Type *PinMatrixRequest_PinMatrixRequestType `protobuf:"varint,1,opt,name=type,enum=hw.trezor.messages.common.PinMatrixRequest_PinMatrixRequestType" json:"type,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PinMatrixRequest) Reset() { *m = PinMatrixRequest{} }
|
||||||
|
func (m *PinMatrixRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PinMatrixRequest) ProtoMessage() {}
|
||||||
|
func (*PinMatrixRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PinMatrixRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_PinMatrixRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_PinMatrixRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_PinMatrixRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_PinMatrixRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_PinMatrixRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_PinMatrixRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *PinMatrixRequest) GetType() PinMatrixRequest_PinMatrixRequestType {
|
||||||
|
if m != nil && m.Type != nil {
|
||||||
|
return *m.Type
|
||||||
|
}
|
||||||
|
return PinMatrixRequest_PinMatrixRequestType_Current
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Computer responds with encoded PIN
|
||||||
|
// @auxend
|
||||||
|
type PinMatrixAck struct {
|
||||||
|
Pin *string `protobuf:"bytes,1,req,name=pin" json:"pin,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PinMatrixAck) Reset() { *m = PinMatrixAck{} }
|
||||||
|
func (m *PinMatrixAck) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PinMatrixAck) ProtoMessage() {}
|
||||||
|
func (*PinMatrixAck) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{5}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PinMatrixAck) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_PinMatrixAck.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_PinMatrixAck.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixAck) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_PinMatrixAck.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixAck) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_PinMatrixAck.Size(m)
|
||||||
|
}
|
||||||
|
func (m *PinMatrixAck) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_PinMatrixAck.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_PinMatrixAck proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *PinMatrixAck) GetPin() string {
|
||||||
|
if m != nil && m.Pin != nil {
|
||||||
|
return *m.Pin
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Device awaits encryption passphrase
|
||||||
|
// @auxstart
|
||||||
|
// @next PassphraseAck
|
||||||
|
type PassphraseRequest struct {
|
||||||
|
OnDevice *bool `protobuf:"varint,1,opt,name=on_device,json=onDevice" json:"on_device,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseRequest) Reset() { *m = PassphraseRequest{} }
|
||||||
|
func (m *PassphraseRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PassphraseRequest) ProtoMessage() {}
|
||||||
|
func (*PassphraseRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_PassphraseRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *PassphraseRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_PassphraseRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *PassphraseRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_PassphraseRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *PassphraseRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_PassphraseRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *PassphraseRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_PassphraseRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_PassphraseRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *PassphraseRequest) GetOnDevice() bool {
|
||||||
|
if m != nil && m.OnDevice != nil {
|
||||||
|
return *m.OnDevice
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Send passphrase back
|
||||||
|
// @next PassphraseStateRequest
|
||||||
|
type PassphraseAck struct {
|
||||||
|
Passphrase *string `protobuf:"bytes,1,opt,name=passphrase" json:"passphrase,omitempty"`
|
||||||
|
State []byte `protobuf:"bytes,2,opt,name=state" json:"state,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseAck) Reset() { *m = PassphraseAck{} }
|
||||||
|
func (m *PassphraseAck) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PassphraseAck) ProtoMessage() {}
|
||||||
|
func (*PassphraseAck) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseAck) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_PassphraseAck.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *PassphraseAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_PassphraseAck.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *PassphraseAck) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_PassphraseAck.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *PassphraseAck) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_PassphraseAck.Size(m)
|
||||||
|
}
|
||||||
|
func (m *PassphraseAck) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_PassphraseAck.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_PassphraseAck proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *PassphraseAck) GetPassphrase() string {
|
||||||
|
if m != nil && m.Passphrase != nil {
|
||||||
|
return *m.Passphrase
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseAck) GetState() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.State
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Device awaits passphrase state
|
||||||
|
// @next PassphraseStateAck
|
||||||
|
type PassphraseStateRequest struct {
|
||||||
|
State []byte `protobuf:"bytes,1,opt,name=state" json:"state,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseStateRequest) Reset() { *m = PassphraseStateRequest{} }
|
||||||
|
func (m *PassphraseStateRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PassphraseStateRequest) ProtoMessage() {}
|
||||||
|
func (*PassphraseStateRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{8}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseStateRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_PassphraseStateRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_PassphraseStateRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_PassphraseStateRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_PassphraseStateRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_PassphraseStateRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_PassphraseStateRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *PassphraseStateRequest) GetState() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.State
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Send passphrase state back
|
||||||
|
// @auxend
|
||||||
|
type PassphraseStateAck struct {
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseStateAck) Reset() { *m = PassphraseStateAck{} }
|
||||||
|
func (m *PassphraseStateAck) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*PassphraseStateAck) ProtoMessage() {}
|
||||||
|
func (*PassphraseStateAck) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{9}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PassphraseStateAck) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_PassphraseStateAck.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_PassphraseStateAck.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateAck) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_PassphraseStateAck.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateAck) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_PassphraseStateAck.Size(m)
|
||||||
|
}
|
||||||
|
func (m *PassphraseStateAck) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_PassphraseStateAck.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_PassphraseStateAck proto.InternalMessageInfo
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Structure representing BIP32 (hierarchical deterministic) node
|
||||||
|
// Used for imports of private key into the device and exporting public key out of device
|
||||||
|
// @embed
|
||||||
|
type HDNodeType struct {
|
||||||
|
Depth *uint32 `protobuf:"varint,1,req,name=depth" json:"depth,omitempty"`
|
||||||
|
Fingerprint *uint32 `protobuf:"varint,2,req,name=fingerprint" json:"fingerprint,omitempty"`
|
||||||
|
ChildNum *uint32 `protobuf:"varint,3,req,name=child_num,json=childNum" json:"child_num,omitempty"`
|
||||||
|
ChainCode []byte `protobuf:"bytes,4,req,name=chain_code,json=chainCode" json:"chain_code,omitempty"`
|
||||||
|
PrivateKey []byte `protobuf:"bytes,5,opt,name=private_key,json=privateKey" json:"private_key,omitempty"`
|
||||||
|
PublicKey []byte `protobuf:"bytes,6,opt,name=public_key,json=publicKey" json:"public_key,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) Reset() { *m = HDNodeType{} }
|
||||||
|
func (m *HDNodeType) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*HDNodeType) ProtoMessage() {}
|
||||||
|
func (*HDNodeType) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_aaf30d059fdbc38d, []int{10}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_HDNodeType.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *HDNodeType) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_HDNodeType.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *HDNodeType) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_HDNodeType.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *HDNodeType) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_HDNodeType.Size(m)
|
||||||
|
}
|
||||||
|
func (m *HDNodeType) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_HDNodeType.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_HDNodeType proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *HDNodeType) GetDepth() uint32 {
|
||||||
|
if m != nil && m.Depth != nil {
|
||||||
|
return *m.Depth
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) GetFingerprint() uint32 {
|
||||||
|
if m != nil && m.Fingerprint != nil {
|
||||||
|
return *m.Fingerprint
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) GetChildNum() uint32 {
|
||||||
|
if m != nil && m.ChildNum != nil {
|
||||||
|
return *m.ChildNum
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) GetChainCode() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.ChainCode
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) GetPrivateKey() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.PrivateKey
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HDNodeType) GetPublicKey() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.PublicKey
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterEnum("hw.trezor.messages.common.Failure_FailureType", Failure_FailureType_name, Failure_FailureType_value)
|
||||||
|
proto.RegisterEnum("hw.trezor.messages.common.ButtonRequest_ButtonRequestType", ButtonRequest_ButtonRequestType_name, ButtonRequest_ButtonRequestType_value)
|
||||||
|
proto.RegisterEnum("hw.trezor.messages.common.PinMatrixRequest_PinMatrixRequestType", PinMatrixRequest_PinMatrixRequestType_name, PinMatrixRequest_PinMatrixRequestType_value)
|
||||||
|
proto.RegisterType((*Success)(nil), "hw.trezor.messages.common.Success")
|
||||||
|
proto.RegisterType((*Failure)(nil), "hw.trezor.messages.common.Failure")
|
||||||
|
proto.RegisterType((*ButtonRequest)(nil), "hw.trezor.messages.common.ButtonRequest")
|
||||||
|
proto.RegisterType((*ButtonAck)(nil), "hw.trezor.messages.common.ButtonAck")
|
||||||
|
proto.RegisterType((*PinMatrixRequest)(nil), "hw.trezor.messages.common.PinMatrixRequest")
|
||||||
|
proto.RegisterType((*PinMatrixAck)(nil), "hw.trezor.messages.common.PinMatrixAck")
|
||||||
|
proto.RegisterType((*PassphraseRequest)(nil), "hw.trezor.messages.common.PassphraseRequest")
|
||||||
|
proto.RegisterType((*PassphraseAck)(nil), "hw.trezor.messages.common.PassphraseAck")
|
||||||
|
proto.RegisterType((*PassphraseStateRequest)(nil), "hw.trezor.messages.common.PassphraseStateRequest")
|
||||||
|
proto.RegisterType((*PassphraseStateAck)(nil), "hw.trezor.messages.common.PassphraseStateAck")
|
||||||
|
proto.RegisterType((*HDNodeType)(nil), "hw.trezor.messages.common.HDNodeType")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("messages-common.proto", fileDescriptor_aaf30d059fdbc38d) }
|
||||||
|
|
||||||
|
var fileDescriptor_aaf30d059fdbc38d = []byte{
|
||||||
|
// 846 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xcd, 0x52, 0x23, 0x37,
|
||||||
|
0x10, 0x2e, 0xff, 0x80, 0xed, 0xb6, 0xd9, 0x08, 0xc5, 0x80, 0x09, 0xb0, 0x38, 0xc3, 0x21, 0x5c,
|
||||||
|
0xe2, 0x4a, 0xe5, 0x98, 0x53, 0x58, 0x83, 0x2b, 0xd4, 0x16, 0x86, 0x1a, 0xd8, 0xda, 0xa3, 0x4b,
|
||||||
|
0xd1, 0xf4, 0x32, 0x2a, 0xcf, 0x48, 0x13, 0x8d, 0x06, 0xf0, 0x5e, 0xf2, 0x6a, 0x79, 0x89, 0xbc,
|
||||||
|
0x42, 0xaa, 0x52, 0xb9, 0xe4, 0x11, 0xb6, 0x34, 0x3f, 0x78, 0xc6, 0x66, 0x39, 0xcd, 0xe8, 0xfb,
|
||||||
|
0xbe, 0xee, 0x96, 0xba, 0x3f, 0x09, 0x76, 0x42, 0x8c, 0x63, 0x76, 0x8f, 0xf1, 0x8f, 0x5c, 0x85,
|
||||||
|
0xa1, 0x92, 0xa3, 0x48, 0x2b, 0xa3, 0xe8, 0xbe, 0xff, 0x38, 0x32, 0x1a, 0x3f, 0x2b, 0x3d, 0x2a,
|
||||||
|
0x04, 0xa3, 0x4c, 0xe0, 0x9c, 0x40, 0xeb, 0x36, 0xe1, 0x1c, 0xe3, 0x98, 0x0e, 0xa0, 0x95, 0xb3,
|
||||||
|
0x83, 0xda, 0xb0, 0x76, 0xda, 0x71, 0x8b, 0xa5, 0xf3, 0x77, 0x03, 0x5a, 0x13, 0x26, 0x82, 0x44,
|
||||||
|
0x23, 0x7d, 0x07, 0x4d, 0xae, 0xbc, 0x4c, 0xf2, 0xe6, 0xe7, 0xd1, 0xe8, 0xab, 0xa9, 0x47, 0x79,
|
||||||
|
0x44, 0xf1, 0xbd, 0x5b, 0x44, 0xe8, 0xa6, 0xb1, 0xe5, 0x4a, 0xf5, 0x6a, 0xa5, 0xff, 0xea, 0xd0,
|
||||||
|
0x2d, 0xe9, 0xe9, 0x11, 0xec, 0xe7, 0xcb, 0xd9, 0x07, 0x89, 0x4f, 0x11, 0x72, 0x83, 0xde, 0x55,
|
||||||
|
0x26, 0x26, 0x35, 0xfa, 0x1d, 0xec, 0x16, 0xf4, 0xbb, 0xc4, 0x18, 0x25, 0x2f, 0x72, 0x09, 0xa9,
|
||||||
|
0xd3, 0x1d, 0xd8, 0x2e, 0xb8, 0x73, 0x66, 0xd8, 0x85, 0xd6, 0x4a, 0x93, 0x06, 0x3d, 0x80, 0xbd,
|
||||||
|
0x02, 0x3e, 0xe3, 0x46, 0x28, 0x39, 0x66, 0x92, 0x63, 0x10, 0xa0, 0x47, 0x9a, 0x74, 0x0f, 0xbe,
|
||||||
|
0x2d, 0xc8, 0x1b, 0xb1, 0x4c, 0xb6, 0x41, 0x07, 0xd0, 0x2f, 0x11, 0xcb, 0x90, 0x4d, 0xba, 0x0b,
|
||||||
|
0xb4, 0xc4, 0x5c, 0xca, 0x07, 0x16, 0x08, 0x8f, 0xb4, 0xe8, 0x21, 0x0c, 0x0a, 0x3c, 0x07, 0x6f,
|
||||||
|
0xc5, 0xbd, 0x64, 0x26, 0xd1, 0x48, 0xda, 0x95, 0x7c, 0x5a, 0xd9, 0xf6, 0x67, 0xfb, 0xeb, 0x94,
|
||||||
|
0x8f, 0x34, 0x55, 0xe6, 0x42, 0xaa, 0xe4, 0xde, 0x9f, 0x24, 0xd2, 0x8b, 0x09, 0xac, 0x70, 0x97,
|
||||||
|
0x52, 0x18, 0xc1, 0x02, 0xf1, 0x19, 0x3d, 0xd2, 0x5d, 0xd9, 0xfa, 0x95, 0x88, 0x43, 0x66, 0xb8,
|
||||||
|
0x4f, 0x7a, 0x74, 0x1f, 0x76, 0x0a, 0x62, 0x22, 0x74, 0xf8, 0xc8, 0x34, 0x66, 0xb5, 0xb8, 0xf3,
|
||||||
|
0x4f, 0x13, 0xb6, 0xb2, 0xbe, 0xb9, 0xf8, 0x47, 0x82, 0xb1, 0xa1, 0xd3, 0xca, 0x74, 0x7f, 0x79,
|
||||||
|
0x65, 0xba, 0x95, 0xb8, 0xea, 0xaa, 0x34, 0x69, 0x0a, 0x4d, 0x8f, 0x19, 0x96, 0x8f, 0x39, 0xfd,
|
||||||
|
0x77, 0xfe, 0x6f, 0xc0, 0xf6, 0x9a, 0xde, 0xee, 0xbf, 0x02, 0xce, 0xae, 0x8d, 0x8f, 0x9a, 0xd4,
|
||||||
|
0xa8, 0x03, 0x6f, 0xab, 0xc4, 0x04, 0xf1, 0xfa, 0x01, 0xf5, 0x9d, 0xaf, 0x31, 0xf6, 0x55, 0x60,
|
||||||
|
0x67, 0x7d, 0x0c, 0x07, 0x55, 0xcd, 0x58, 0xc9, 0x4f, 0x42, 0x87, 0xd7, 0x89, 0x89, 0x12, 0x43,
|
||||||
|
0x1a, 0xd6, 0x47, 0x55, 0x81, 0x8b, 0x31, 0x9a, 0x73, 0x7c, 0x10, 0x1c, 0x49, 0x73, 0x9d, 0xce,
|
||||||
|
0xe3, 0x3f, 0x2a, 0x6d, 0xa7, 0x7f, 0x08, 0x83, 0x2a, 0xfd, 0x51, 0x44, 0x98, 0x07, 0x6f, 0xae,
|
||||||
|
0x07, 0xdf, 0x68, 0x65, 0x90, 0x9b, 0x31, 0x0b, 0x02, 0xd2, 0xb2, 0xa3, 0xae, 0xd2, 0xd6, 0x07,
|
||||||
|
0x77, 0x4f, 0xa4, 0xbd, 0xbe, 0xeb, 0x62, 0x3e, 0x63, 0x1f, 0xf9, 0x9c, 0x74, 0xec, 0xe8, 0xaa,
|
||||||
|
0x82, 0x33, 0xcf, 0xd3, 0x18, 0x5b, 0x2b, 0x1c, 0xc0, 0xde, 0x4a, 0xd1, 0xe4, 0xf7, 0x40, 0xf0,
|
||||||
|
0xf7, 0xb8, 0x20, 0x5d, 0x7a, 0x02, 0xc7, 0x55, 0xf2, 0x4a, 0x62, 0xa8, 0xa4, 0xe0, 0xf6, 0x3c,
|
||||||
|
0x63, 0x95, 0x48, 0x43, 0x7a, 0xeb, 0xd5, 0x0b, 0xd1, 0xa5, 0xb4, 0x3d, 0xdb, 0xa2, 0x43, 0x38,
|
||||||
|
0x5c, 0x29, 0xc1, 0xe2, 0x38, 0xf2, 0x35, 0x8b, 0xd3, 0xbb, 0x49, 0xde, 0xd0, 0x1f, 0xe0, 0xa4,
|
||||||
|
0xaa, 0xf8, 0x20, 0xe7, 0x52, 0x3d, 0xca, 0x73, 0xd4, 0xe2, 0x81, 0xd9, 0xcb, 0x75, 0xc3, 0x8c,
|
||||||
|
0x4f, 0xbe, 0x71, 0xba, 0xd0, 0xc9, 0x84, 0x67, 0x7c, 0xee, 0xfc, 0x5b, 0x03, 0x62, 0x2d, 0xca,
|
||||||
|
0x8c, 0x16, 0x4f, 0x85, 0xf1, 0xee, 0xa0, 0x69, 0x16, 0x51, 0x61, 0xbc, 0x5f, 0x5f, 0x31, 0xde,
|
||||||
|
0x6a, 0xe8, 0x1a, 0x90, 0xd9, 0xcf, 0x66, 0x73, 0xfe, 0x84, 0xfe, 0x4b, 0xac, 0x3d, 0xda, 0x4b,
|
||||||
|
0xf8, 0x6c, 0x9c, 0x68, 0x8d, 0xd2, 0x90, 0x1a, 0xfd, 0x1e, 0x8e, 0x5e, 0x54, 0x4c, 0xf1, 0x71,
|
||||||
|
0x22, 0x74, 0x6c, 0x48, 0xdd, 0x1a, 0xf3, 0x6b, 0x92, 0x5b, 0xe4, 0x4a, 0x7a, 0xa4, 0xe1, 0x0c,
|
||||||
|
0xa1, 0xf7, 0xac, 0x39, 0xe3, 0x73, 0x4a, 0xa0, 0x11, 0x09, 0x39, 0xa8, 0x0d, 0xeb, 0xa7, 0x1d,
|
||||||
|
0xd7, 0xfe, 0x3a, 0x3f, 0xc1, 0xf6, 0xb2, 0xaf, 0x45, 0x37, 0x0e, 0xa0, 0xa3, 0xe4, 0xcc, 0x4b,
|
||||||
|
0x1d, 0x96, 0xb6, 0xa4, 0xed, 0xb6, 0x95, 0xcc, 0x1c, 0xe7, 0x5c, 0xc0, 0xd6, 0x32, 0xc2, 0x26,
|
||||||
|
0x7d, 0x0b, 0x10, 0x3d, 0x03, 0xf9, 0xdb, 0x5d, 0x42, 0x68, 0x1f, 0x36, 0x62, 0xc3, 0x4c, 0xf6,
|
||||||
|
0xd8, 0xf6, 0xdc, 0x6c, 0xe1, 0x8c, 0x60, 0x77, 0x99, 0xe6, 0xd6, 0x42, 0x45, 0xf5, 0x67, 0x7d,
|
||||||
|
0xad, 0xac, 0xef, 0x03, 0x5d, 0xd1, 0xdb, 0x61, 0xfe, 0x55, 0x03, 0xf8, 0xed, 0x7c, 0xaa, 0xbc,
|
||||||
|
0xec, 0xbd, 0xee, 0xc3, 0x86, 0x87, 0x91, 0xf1, 0xd3, 0x13, 0x6e, 0xb9, 0xd9, 0x82, 0x0e, 0xa1,
|
||||||
|
0xfb, 0x49, 0xc8, 0x7b, 0xd4, 0x91, 0x16, 0xd2, 0x0c, 0xea, 0x29, 0x57, 0x86, 0xec, 0x81, 0xb9,
|
||||||
|
0x2f, 0x02, 0x6f, 0x26, 0x93, 0x70, 0xd0, 0x48, 0xf9, 0x76, 0x0a, 0x4c, 0x93, 0x90, 0x1e, 0x01,
|
||||||
|
0x70, 0x9f, 0x09, 0x39, 0x4b, 0x9f, 0xa6, 0xe6, 0xb0, 0x7e, 0xda, 0x73, 0x3b, 0x29, 0x32, 0xb6,
|
||||||
|
0x6f, 0xcc, 0x31, 0x74, 0xa3, 0xd4, 0x6f, 0x38, 0x9b, 0xe3, 0x62, 0xb0, 0x91, 0x6e, 0x1a, 0x72,
|
||||||
|
0xe8, 0x3d, 0x2e, 0x6c, 0x7c, 0x94, 0xde, 0x8e, 0x94, 0xdf, 0x4c, 0xf9, 0x4e, 0x54, 0xdc, 0x97,
|
||||||
|
0x2f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x7d, 0x20, 0xa6, 0x35, 0x07, 0x00, 0x00,
|
||||||
|
}
|
||||||
147
accounts/usbwallet/trezor/messages-common.proto
Normal file
147
accounts/usbwallet/trezor/messages-common.proto
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
// This file originates from the SatoshiLabs Trezor `common` repository at:
|
||||||
|
// https://github.com/trezor/trezor-common/blob/master/protob/messages-common.proto
|
||||||
|
// dated 28.05.2019, commit 893fd219d4a01bcffa0cd9cfa631856371ec5aa9.
|
||||||
|
|
||||||
|
syntax = "proto2";
|
||||||
|
package hw.trezor.messages.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Success of the previous request
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message Success {
|
||||||
|
optional string message = 1; // human readable description of action or request-specific payload
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Failure of the previous request
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message Failure {
|
||||||
|
optional FailureType code = 1; // computer-readable definition of the error state
|
||||||
|
optional string message = 2; // human-readable message of the error state
|
||||||
|
enum FailureType {
|
||||||
|
Failure_UnexpectedMessage = 1;
|
||||||
|
Failure_ButtonExpected = 2;
|
||||||
|
Failure_DataError = 3;
|
||||||
|
Failure_ActionCancelled = 4;
|
||||||
|
Failure_PinExpected = 5;
|
||||||
|
Failure_PinCancelled = 6;
|
||||||
|
Failure_PinInvalid = 7;
|
||||||
|
Failure_InvalidSignature = 8;
|
||||||
|
Failure_ProcessError = 9;
|
||||||
|
Failure_NotEnoughFunds = 10;
|
||||||
|
Failure_NotInitialized = 11;
|
||||||
|
Failure_PinMismatch = 12;
|
||||||
|
Failure_FirmwareError = 99;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Device is waiting for HW button press.
|
||||||
|
* @auxstart
|
||||||
|
* @next ButtonAck
|
||||||
|
*/
|
||||||
|
message ButtonRequest {
|
||||||
|
optional ButtonRequestType code = 1;
|
||||||
|
optional string data = 2;
|
||||||
|
/**
|
||||||
|
* Type of button request
|
||||||
|
*/
|
||||||
|
enum ButtonRequestType {
|
||||||
|
ButtonRequest_Other = 1;
|
||||||
|
ButtonRequest_FeeOverThreshold = 2;
|
||||||
|
ButtonRequest_ConfirmOutput = 3;
|
||||||
|
ButtonRequest_ResetDevice = 4;
|
||||||
|
ButtonRequest_ConfirmWord = 5;
|
||||||
|
ButtonRequest_WipeDevice = 6;
|
||||||
|
ButtonRequest_ProtectCall = 7;
|
||||||
|
ButtonRequest_SignTx = 8;
|
||||||
|
ButtonRequest_FirmwareCheck = 9;
|
||||||
|
ButtonRequest_Address = 10;
|
||||||
|
ButtonRequest_PublicKey = 11;
|
||||||
|
ButtonRequest_MnemonicWordCount = 12;
|
||||||
|
ButtonRequest_MnemonicInput = 13;
|
||||||
|
ButtonRequest_PassphraseType = 14;
|
||||||
|
ButtonRequest_UnknownDerivationPath = 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Computer agrees to wait for HW button press
|
||||||
|
* @auxend
|
||||||
|
*/
|
||||||
|
message ButtonAck {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Device is asking computer to show PIN matrix and awaits PIN encoded using this matrix scheme
|
||||||
|
* @auxstart
|
||||||
|
* @next PinMatrixAck
|
||||||
|
*/
|
||||||
|
message PinMatrixRequest {
|
||||||
|
optional PinMatrixRequestType type = 1;
|
||||||
|
/**
|
||||||
|
* Type of PIN request
|
||||||
|
*/
|
||||||
|
enum PinMatrixRequestType {
|
||||||
|
PinMatrixRequestType_Current = 1;
|
||||||
|
PinMatrixRequestType_NewFirst = 2;
|
||||||
|
PinMatrixRequestType_NewSecond = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Computer responds with encoded PIN
|
||||||
|
* @auxend
|
||||||
|
*/
|
||||||
|
message PinMatrixAck {
|
||||||
|
required string pin = 1; // matrix encoded PIN entered by user
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Device awaits encryption passphrase
|
||||||
|
* @auxstart
|
||||||
|
* @next PassphraseAck
|
||||||
|
*/
|
||||||
|
message PassphraseRequest {
|
||||||
|
optional bool on_device = 1; // passphrase is being entered on the device
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Send passphrase back
|
||||||
|
* @next PassphraseStateRequest
|
||||||
|
*/
|
||||||
|
message PassphraseAck {
|
||||||
|
optional string passphrase = 1;
|
||||||
|
optional bytes state = 2; // expected device state
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Device awaits passphrase state
|
||||||
|
* @next PassphraseStateAck
|
||||||
|
*/
|
||||||
|
message PassphraseStateRequest {
|
||||||
|
optional bytes state = 1; // actual device state
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Send passphrase state back
|
||||||
|
* @auxend
|
||||||
|
*/
|
||||||
|
message PassphraseStateAck {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure representing BIP32 (hierarchical deterministic) node
|
||||||
|
* Used for imports of private key into the device and exporting public key out of device
|
||||||
|
* @embed
|
||||||
|
*/
|
||||||
|
message HDNodeType {
|
||||||
|
required uint32 depth = 1;
|
||||||
|
required uint32 fingerprint = 2;
|
||||||
|
required uint32 child_num = 3;
|
||||||
|
required bytes chain_code = 4;
|
||||||
|
optional bytes private_key = 5;
|
||||||
|
optional bytes public_key = 6;
|
||||||
|
}
|
||||||
698
accounts/usbwallet/trezor/messages-ethereum.pb.go
Normal file
698
accounts/usbwallet/trezor/messages-ethereum.pb.go
Normal file
@@ -0,0 +1,698 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// source: messages-ethereum.proto
|
||||||
|
|
||||||
|
package trezor
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
math "math"
|
||||||
|
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Ask device for public key corresponding to address_n path
|
||||||
|
// @start
|
||||||
|
// @next EthereumPublicKey
|
||||||
|
// @next Failure
|
||||||
|
type EthereumGetPublicKey struct {
|
||||||
|
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
|
||||||
|
ShowDisplay *bool `protobuf:"varint,2,opt,name=show_display,json=showDisplay" json:"show_display,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumGetPublicKey) Reset() { *m = EthereumGetPublicKey{} }
|
||||||
|
func (m *EthereumGetPublicKey) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumGetPublicKey) ProtoMessage() {}
|
||||||
|
func (*EthereumGetPublicKey) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumGetPublicKey) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumGetPublicKey.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetPublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumGetPublicKey.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetPublicKey) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumGetPublicKey.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetPublicKey) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumGetPublicKey.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetPublicKey) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumGetPublicKey.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumGetPublicKey proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumGetPublicKey) GetAddressN() []uint32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressN
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumGetPublicKey) GetShowDisplay() bool {
|
||||||
|
if m != nil && m.ShowDisplay != nil {
|
||||||
|
return *m.ShowDisplay
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Contains public key derived from device private seed
|
||||||
|
// @end
|
||||||
|
type EthereumPublicKey struct {
|
||||||
|
Node *HDNodeType `protobuf:"bytes,1,opt,name=node" json:"node,omitempty"`
|
||||||
|
Xpub *string `protobuf:"bytes,2,opt,name=xpub" json:"xpub,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumPublicKey) Reset() { *m = EthereumPublicKey{} }
|
||||||
|
func (m *EthereumPublicKey) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumPublicKey) ProtoMessage() {}
|
||||||
|
func (*EthereumPublicKey) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumPublicKey) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumPublicKey.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumPublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumPublicKey.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumPublicKey) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumPublicKey.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumPublicKey) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumPublicKey.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumPublicKey) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumPublicKey.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumPublicKey proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumPublicKey) GetNode() *HDNodeType {
|
||||||
|
if m != nil {
|
||||||
|
return m.Node
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumPublicKey) GetXpub() string {
|
||||||
|
if m != nil && m.Xpub != nil {
|
||||||
|
return *m.Xpub
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Ask device for Ethereum address corresponding to address_n path
|
||||||
|
// @start
|
||||||
|
// @next EthereumAddress
|
||||||
|
// @next Failure
|
||||||
|
type EthereumGetAddress struct {
|
||||||
|
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
|
||||||
|
ShowDisplay *bool `protobuf:"varint,2,opt,name=show_display,json=showDisplay" json:"show_display,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumGetAddress) Reset() { *m = EthereumGetAddress{} }
|
||||||
|
func (m *EthereumGetAddress) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumGetAddress) ProtoMessage() {}
|
||||||
|
func (*EthereumGetAddress) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumGetAddress) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumGetAddress.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumGetAddress.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetAddress) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumGetAddress.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetAddress) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumGetAddress.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumGetAddress) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumGetAddress.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumGetAddress proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumGetAddress) GetAddressN() []uint32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressN
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumGetAddress) GetShowDisplay() bool {
|
||||||
|
if m != nil && m.ShowDisplay != nil {
|
||||||
|
return *m.ShowDisplay
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Contains an Ethereum address derived from device private seed
|
||||||
|
// @end
|
||||||
|
type EthereumAddress struct {
|
||||||
|
AddressBin []byte `protobuf:"bytes,1,opt,name=addressBin" json:"addressBin,omitempty"`
|
||||||
|
AddressHex *string `protobuf:"bytes,2,opt,name=addressHex" json:"addressHex,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumAddress) Reset() { *m = EthereumAddress{} }
|
||||||
|
func (m *EthereumAddress) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumAddress) ProtoMessage() {}
|
||||||
|
func (*EthereumAddress) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumAddress) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumAddress.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumAddress.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumAddress) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumAddress.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumAddress) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumAddress.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumAddress) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumAddress.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumAddress proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumAddress) GetAddressBin() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressBin
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumAddress) GetAddressHex() string {
|
||||||
|
if m != nil && m.AddressHex != nil {
|
||||||
|
return *m.AddressHex
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Ask device to sign transaction
|
||||||
|
// All fields are optional from the protocol's point of view. Each field defaults to value `0` if missing.
|
||||||
|
// Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
|
||||||
|
// @start
|
||||||
|
// @next EthereumTxRequest
|
||||||
|
// @next Failure
|
||||||
|
type EthereumSignTx struct {
|
||||||
|
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
|
||||||
|
Nonce []byte `protobuf:"bytes,2,opt,name=nonce" json:"nonce,omitempty"`
|
||||||
|
GasPrice []byte `protobuf:"bytes,3,opt,name=gas_price,json=gasPrice" json:"gas_price,omitempty"`
|
||||||
|
GasLimit []byte `protobuf:"bytes,4,opt,name=gas_limit,json=gasLimit" json:"gas_limit,omitempty"`
|
||||||
|
ToBin []byte `protobuf:"bytes,5,opt,name=toBin" json:"toBin,omitempty"`
|
||||||
|
ToHex *string `protobuf:"bytes,11,opt,name=toHex" json:"toHex,omitempty"`
|
||||||
|
Value []byte `protobuf:"bytes,6,opt,name=value" json:"value,omitempty"`
|
||||||
|
DataInitialChunk []byte `protobuf:"bytes,7,opt,name=data_initial_chunk,json=dataInitialChunk" json:"data_initial_chunk,omitempty"`
|
||||||
|
DataLength *uint32 `protobuf:"varint,8,opt,name=data_length,json=dataLength" json:"data_length,omitempty"`
|
||||||
|
ChainId *uint32 `protobuf:"varint,9,opt,name=chain_id,json=chainId" json:"chain_id,omitempty"`
|
||||||
|
TxType *uint32 `protobuf:"varint,10,opt,name=tx_type,json=txType" json:"tx_type,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) Reset() { *m = EthereumSignTx{} }
|
||||||
|
func (m *EthereumSignTx) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumSignTx) ProtoMessage() {}
|
||||||
|
func (*EthereumSignTx) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{4}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumSignTx.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumSignTx.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignTx) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumSignTx.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignTx) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumSignTx.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignTx) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumSignTx.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumSignTx proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetAddressN() []uint32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressN
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetNonce() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.Nonce
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetGasPrice() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.GasPrice
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetGasLimit() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.GasLimit
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetToBin() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.ToBin
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetToHex() string {
|
||||||
|
if m != nil && m.ToHex != nil {
|
||||||
|
return *m.ToHex
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetValue() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.Value
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetDataInitialChunk() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.DataInitialChunk
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetDataLength() uint32 {
|
||||||
|
if m != nil && m.DataLength != nil {
|
||||||
|
return *m.DataLength
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetChainId() uint32 {
|
||||||
|
if m != nil && m.ChainId != nil {
|
||||||
|
return *m.ChainId
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignTx) GetTxType() uint32 {
|
||||||
|
if m != nil && m.TxType != nil {
|
||||||
|
return *m.TxType
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Device asks for more data from transaction payload, or returns the signature.
|
||||||
|
// If data_length is set, device awaits that many more bytes of payload.
|
||||||
|
// Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
|
||||||
|
// @end
|
||||||
|
// @next EthereumTxAck
|
||||||
|
type EthereumTxRequest struct {
|
||||||
|
DataLength *uint32 `protobuf:"varint,1,opt,name=data_length,json=dataLength" json:"data_length,omitempty"`
|
||||||
|
SignatureV *uint32 `protobuf:"varint,2,opt,name=signature_v,json=signatureV" json:"signature_v,omitempty"`
|
||||||
|
SignatureR []byte `protobuf:"bytes,3,opt,name=signature_r,json=signatureR" json:"signature_r,omitempty"`
|
||||||
|
SignatureS []byte `protobuf:"bytes,4,opt,name=signature_s,json=signatureS" json:"signature_s,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxRequest) Reset() { *m = EthereumTxRequest{} }
|
||||||
|
func (m *EthereumTxRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumTxRequest) ProtoMessage() {}
|
||||||
|
func (*EthereumTxRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{5}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumTxRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumTxRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumTxRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumTxRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumTxRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumTxRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumTxRequest) GetDataLength() uint32 {
|
||||||
|
if m != nil && m.DataLength != nil {
|
||||||
|
return *m.DataLength
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxRequest) GetSignatureV() uint32 {
|
||||||
|
if m != nil && m.SignatureV != nil {
|
||||||
|
return *m.SignatureV
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxRequest) GetSignatureR() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.SignatureR
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxRequest) GetSignatureS() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.SignatureS
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Transaction payload data.
|
||||||
|
// @next EthereumTxRequest
|
||||||
|
type EthereumTxAck struct {
|
||||||
|
DataChunk []byte `protobuf:"bytes,1,opt,name=data_chunk,json=dataChunk" json:"data_chunk,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxAck) Reset() { *m = EthereumTxAck{} }
|
||||||
|
func (m *EthereumTxAck) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumTxAck) ProtoMessage() {}
|
||||||
|
func (*EthereumTxAck) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{6}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumTxAck) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumTxAck.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumTxAck.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxAck) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumTxAck.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxAck) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumTxAck.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumTxAck) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumTxAck.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumTxAck proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumTxAck) GetDataChunk() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.DataChunk
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Ask device to sign message
|
||||||
|
// @start
|
||||||
|
// @next EthereumMessageSignature
|
||||||
|
// @next Failure
|
||||||
|
type EthereumSignMessage struct {
|
||||||
|
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
|
||||||
|
Message []byte `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignMessage) Reset() { *m = EthereumSignMessage{} }
|
||||||
|
func (m *EthereumSignMessage) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumSignMessage) ProtoMessage() {}
|
||||||
|
func (*EthereumSignMessage) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignMessage) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumSignMessage.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumSignMessage.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignMessage) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumSignMessage.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignMessage) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumSignMessage.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumSignMessage) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumSignMessage.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumSignMessage proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumSignMessage) GetAddressN() []uint32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressN
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumSignMessage) GetMessage() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.Message
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Response: Signed message
|
||||||
|
// @end
|
||||||
|
type EthereumMessageSignature struct {
|
||||||
|
AddressBin []byte `protobuf:"bytes,1,opt,name=addressBin" json:"addressBin,omitempty"`
|
||||||
|
Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"`
|
||||||
|
AddressHex *string `protobuf:"bytes,3,opt,name=addressHex" json:"addressHex,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumMessageSignature) Reset() { *m = EthereumMessageSignature{} }
|
||||||
|
func (m *EthereumMessageSignature) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumMessageSignature) ProtoMessage() {}
|
||||||
|
func (*EthereumMessageSignature) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{8}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumMessageSignature) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumMessageSignature.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumMessageSignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumMessageSignature.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumMessageSignature) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumMessageSignature.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumMessageSignature) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumMessageSignature.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumMessageSignature) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumMessageSignature.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumMessageSignature proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumMessageSignature) GetAddressBin() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressBin
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumMessageSignature) GetSignature() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.Signature
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumMessageSignature) GetAddressHex() string {
|
||||||
|
if m != nil && m.AddressHex != nil {
|
||||||
|
return *m.AddressHex
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Request: Ask device to verify message
|
||||||
|
// @start
|
||||||
|
// @next Success
|
||||||
|
// @next Failure
|
||||||
|
type EthereumVerifyMessage struct {
|
||||||
|
AddressBin []byte `protobuf:"bytes,1,opt,name=addressBin" json:"addressBin,omitempty"`
|
||||||
|
Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"`
|
||||||
|
Message []byte `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"`
|
||||||
|
AddressHex *string `protobuf:"bytes,4,opt,name=addressHex" json:"addressHex,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumVerifyMessage) Reset() { *m = EthereumVerifyMessage{} }
|
||||||
|
func (m *EthereumVerifyMessage) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EthereumVerifyMessage) ProtoMessage() {}
|
||||||
|
func (*EthereumVerifyMessage) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cb33f46ba915f15c, []int{9}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumVerifyMessage) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_EthereumVerifyMessage.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *EthereumVerifyMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_EthereumVerifyMessage.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *EthereumVerifyMessage) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_EthereumVerifyMessage.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *EthereumVerifyMessage) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_EthereumVerifyMessage.Size(m)
|
||||||
|
}
|
||||||
|
func (m *EthereumVerifyMessage) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_EthereumVerifyMessage.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_EthereumVerifyMessage proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *EthereumVerifyMessage) GetAddressBin() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.AddressBin
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumVerifyMessage) GetSignature() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.Signature
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumVerifyMessage) GetMessage() []byte {
|
||||||
|
if m != nil {
|
||||||
|
return m.Message
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EthereumVerifyMessage) GetAddressHex() string {
|
||||||
|
if m != nil && m.AddressHex != nil {
|
||||||
|
return *m.AddressHex
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*EthereumGetPublicKey)(nil), "hw.trezor.messages.ethereum.EthereumGetPublicKey")
|
||||||
|
proto.RegisterType((*EthereumPublicKey)(nil), "hw.trezor.messages.ethereum.EthereumPublicKey")
|
||||||
|
proto.RegisterType((*EthereumGetAddress)(nil), "hw.trezor.messages.ethereum.EthereumGetAddress")
|
||||||
|
proto.RegisterType((*EthereumAddress)(nil), "hw.trezor.messages.ethereum.EthereumAddress")
|
||||||
|
proto.RegisterType((*EthereumSignTx)(nil), "hw.trezor.messages.ethereum.EthereumSignTx")
|
||||||
|
proto.RegisterType((*EthereumTxRequest)(nil), "hw.trezor.messages.ethereum.EthereumTxRequest")
|
||||||
|
proto.RegisterType((*EthereumTxAck)(nil), "hw.trezor.messages.ethereum.EthereumTxAck")
|
||||||
|
proto.RegisterType((*EthereumSignMessage)(nil), "hw.trezor.messages.ethereum.EthereumSignMessage")
|
||||||
|
proto.RegisterType((*EthereumMessageSignature)(nil), "hw.trezor.messages.ethereum.EthereumMessageSignature")
|
||||||
|
proto.RegisterType((*EthereumVerifyMessage)(nil), "hw.trezor.messages.ethereum.EthereumVerifyMessage")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("messages-ethereum.proto", fileDescriptor_cb33f46ba915f15c) }
|
||||||
|
|
||||||
|
var fileDescriptor_cb33f46ba915f15c = []byte{
|
||||||
|
// 593 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
|
||||||
|
0x10, 0x95, 0x9b, 0xb4, 0x49, 0x26, 0x0d, 0x1f, 0xa6, 0x55, 0x17, 0x0a, 0x34, 0x18, 0x21, 0xe5,
|
||||||
|
0x00, 0x3e, 0x70, 0x43, 0xe2, 0xd2, 0x52, 0x44, 0x2b, 0x4a, 0x55, 0xdc, 0xa8, 0x57, 0x6b, 0x63,
|
||||||
|
0x6f, 0xe3, 0x55, 0x9d, 0xdd, 0xe0, 0x5d, 0xb7, 0x0e, 0x7f, 0x82, 0x23, 0xff, 0x87, 0x5f, 0x86,
|
||||||
|
0xf6, 0x2b, 0x71, 0x52, 0x54, 0x0e, 0xbd, 0x65, 0xde, 0xbc, 0x7d, 0xf3, 0x66, 0xf4, 0x62, 0xd8,
|
||||||
|
0x99, 0x10, 0x21, 0xf0, 0x98, 0x88, 0x77, 0x44, 0x66, 0xa4, 0x20, 0xe5, 0x24, 0x9c, 0x16, 0x5c,
|
||||||
|
0x72, 0x7f, 0x37, 0xbb, 0x09, 0x65, 0x41, 0x7e, 0xf2, 0x22, 0x74, 0x94, 0xd0, 0x51, 0x9e, 0x6d,
|
||||||
|
0xcf, 0x5f, 0x25, 0x7c, 0x32, 0xe1, 0xcc, 0xbc, 0x09, 0x2e, 0x60, 0xeb, 0xb3, 0xa5, 0x7c, 0x21,
|
||||||
|
0xf2, 0xac, 0x1c, 0xe5, 0x34, 0xf9, 0x4a, 0x66, 0xfe, 0x2e, 0x74, 0x70, 0x9a, 0x16, 0x44, 0x88,
|
||||||
|
0x98, 0x21, 0xaf, 0xdf, 0x18, 0xf4, 0xa2, 0xb6, 0x05, 0x4e, 0xfd, 0x57, 0xb0, 0x29, 0x32, 0x7e,
|
||||||
|
0x13, 0xa7, 0x54, 0x4c, 0x73, 0x3c, 0x43, 0x6b, 0x7d, 0x6f, 0xd0, 0x8e, 0xba, 0x0a, 0x3b, 0x34,
|
||||||
|
0x50, 0x30, 0x82, 0xc7, 0x4e, 0x77, 0x21, 0xfa, 0x01, 0x9a, 0x8c, 0xa7, 0x04, 0x79, 0x7d, 0x6f,
|
||||||
|
0xd0, 0x7d, 0xff, 0x26, 0xfc, 0x87, 0x5f, 0x6b, 0xee, 0xe8, 0xf0, 0x94, 0xa7, 0x64, 0x38, 0x9b,
|
||||||
|
0x92, 0x48, 0x3f, 0xf1, 0x7d, 0x68, 0x56, 0xd3, 0x72, 0xa4, 0x47, 0x75, 0x22, 0xfd, 0x3b, 0x18,
|
||||||
|
0x82, 0x5f, 0xf3, 0xbe, 0x6f, 0xdc, 0xdd, 0xdb, 0xf9, 0x77, 0x78, 0xe8, 0x54, 0x9d, 0xe4, 0x4b,
|
||||||
|
0x00, 0xab, 0x70, 0x40, 0x99, 0x76, 0xbf, 0x19, 0xd5, 0x90, 0x5a, 0xff, 0x88, 0x54, 0xd6, 0x62,
|
||||||
|
0x0d, 0x09, 0xfe, 0xac, 0xc1, 0x03, 0xa7, 0x79, 0x4e, 0xc7, 0x6c, 0x58, 0xdd, 0xed, 0x72, 0x0b,
|
||||||
|
0xd6, 0x19, 0x67, 0x09, 0xd1, 0x52, 0x9b, 0x91, 0x29, 0xd4, 0x93, 0x31, 0x16, 0xf1, 0xb4, 0xa0,
|
||||||
|
0x09, 0x41, 0x0d, 0xdd, 0x69, 0x8f, 0xb1, 0x38, 0x53, 0xb5, 0x6b, 0xe6, 0x74, 0x42, 0x25, 0x6a,
|
||||||
|
0xce, 0x9b, 0x27, 0xaa, 0x56, 0x7a, 0x92, 0x2b, 0xeb, 0xeb, 0x46, 0x4f, 0x17, 0x06, 0x55, 0x86,
|
||||||
|
0xbb, 0xda, 0xb0, 0x29, 0x14, 0x7a, 0x8d, 0xf3, 0x92, 0xa0, 0x0d, 0xc3, 0xd5, 0x85, 0xff, 0x16,
|
||||||
|
0xfc, 0x14, 0x4b, 0x1c, 0x53, 0x46, 0x25, 0xc5, 0x79, 0x9c, 0x64, 0x25, 0xbb, 0x42, 0x2d, 0x4d,
|
||||||
|
0x79, 0xa4, 0x3a, 0xc7, 0xa6, 0xf1, 0x49, 0xe1, 0xfe, 0x1e, 0x74, 0x35, 0x3b, 0x27, 0x6c, 0x2c,
|
||||||
|
0x33, 0xd4, 0xee, 0x7b, 0x83, 0x5e, 0x04, 0x0a, 0x3a, 0xd1, 0x88, 0xff, 0x14, 0xda, 0x49, 0x86,
|
||||||
|
0x29, 0x8b, 0x69, 0x8a, 0x3a, 0xba, 0xdb, 0xd2, 0xf5, 0x71, 0xea, 0xef, 0x40, 0x4b, 0x56, 0xb1,
|
||||||
|
0x9c, 0x4d, 0x09, 0x02, 0xdd, 0xd9, 0x90, 0x95, 0xca, 0x41, 0xf0, 0xdb, 0x5b, 0x44, 0x6a, 0x58,
|
||||||
|
0x45, 0xe4, 0x47, 0x49, 0x84, 0x5c, 0x1d, 0xe5, 0xdd, 0x1a, 0xb5, 0x07, 0x5d, 0x41, 0xc7, 0x0c,
|
||||||
|
0xcb, 0xb2, 0x20, 0xf1, 0xb5, 0xbe, 0x68, 0x2f, 0x82, 0x39, 0x74, 0xb1, 0x4c, 0x28, 0xec, 0x61,
|
||||||
|
0x17, 0x84, 0x68, 0x99, 0x20, 0xec, 0x71, 0x17, 0x84, 0xf3, 0x20, 0x84, 0xde, 0xc2, 0xd8, 0x7e,
|
||||||
|
0x72, 0xe5, 0xbf, 0x00, 0xed, 0xc0, 0x5e, 0xc9, 0xe4, 0xa5, 0xa3, 0x10, 0x7d, 0x9e, 0xe0, 0x04,
|
||||||
|
0x9e, 0xd4, 0xd3, 0xf0, 0xcd, 0x64, 0xff, 0xee, 0x48, 0x20, 0x68, 0xd9, 0xff, 0x88, 0x0d, 0x85,
|
||||||
|
0x2b, 0x83, 0x0a, 0x90, 0x53, 0xb3, 0x4a, 0xe7, 0xce, 0xda, 0x7f, 0x83, 0xfb, 0x1c, 0x3a, 0xf3,
|
||||||
|
0x3d, 0xac, 0xee, 0x02, 0x58, 0x89, 0x75, 0xe3, 0x56, 0xac, 0x7f, 0x79, 0xb0, 0xed, 0x46, 0x5f,
|
||||||
|
0x90, 0x82, 0x5e, 0xce, 0xdc, 0x2a, 0xf7, 0x9b, 0x5b, 0xdb, 0xb5, 0xb1, 0xb4, 0xeb, 0x8a, 0xa3,
|
||||||
|
0xe6, 0xaa, 0xa3, 0x83, 0x8f, 0xf0, 0x3a, 0xe1, 0x93, 0x50, 0x60, 0xc9, 0x45, 0x46, 0x73, 0x3c,
|
||||||
|
0x12, 0xee, 0x03, 0x93, 0xd3, 0x91, 0xf9, 0xe2, 0x8d, 0xca, 0xcb, 0x83, 0xed, 0xa1, 0x06, 0xad,
|
||||||
|
0x5b, 0xb7, 0xc2, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8a, 0xce, 0x81, 0xc8, 0x59, 0x05, 0x00,
|
||||||
|
0x00,
|
||||||
|
}
|
||||||
131
accounts/usbwallet/trezor/messages-ethereum.proto
Normal file
131
accounts/usbwallet/trezor/messages-ethereum.proto
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
// This file originates from the SatoshiLabs Trezor `common` repository at:
|
||||||
|
// https://github.com/trezor/trezor-common/blob/master/protob/messages-ethereum.proto
|
||||||
|
// dated 28.05.2019, commit 893fd219d4a01bcffa0cd9cfa631856371ec5aa9.
|
||||||
|
|
||||||
|
syntax = "proto2";
|
||||||
|
package hw.trezor.messages.ethereum;
|
||||||
|
|
||||||
|
// Sugar for easier handling in Java
|
||||||
|
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
||||||
|
option java_outer_classname = "TrezorMessageEthereum";
|
||||||
|
|
||||||
|
import "messages-common.proto";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask device for public key corresponding to address_n path
|
||||||
|
* @start
|
||||||
|
* @next EthereumPublicKey
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message EthereumGetPublicKey {
|
||||||
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
|
optional bool show_display = 2; // optionally show on display before sending the result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Contains public key derived from device private seed
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message EthereumPublicKey {
|
||||||
|
optional hw.trezor.messages.common.HDNodeType node = 1; // BIP32 public node
|
||||||
|
optional string xpub = 2; // serialized form of public node
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask device for Ethereum address corresponding to address_n path
|
||||||
|
* @start
|
||||||
|
* @next EthereumAddress
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message EthereumGetAddress {
|
||||||
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
|
optional bool show_display = 2; // optionally show on display before sending the result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Contains an Ethereum address derived from device private seed
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message EthereumAddress {
|
||||||
|
optional bytes addressBin = 1; // Ethereum address as 20 bytes (legacy firmwares)
|
||||||
|
optional string addressHex = 2; // Ethereum address as hex string (newer firmwares)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask device to sign transaction
|
||||||
|
* All fields are optional from the protocol's point of view. Each field defaults to value `0` if missing.
|
||||||
|
* Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
|
||||||
|
* @start
|
||||||
|
* @next EthereumTxRequest
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message EthereumSignTx {
|
||||||
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
|
optional bytes nonce = 2; // <=256 bit unsigned big endian
|
||||||
|
optional bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
|
||||||
|
optional bytes gas_limit = 4; // <=256 bit unsigned big endian
|
||||||
|
optional bytes toBin = 5; // recipient address (20 bytes, legacy firmware)
|
||||||
|
optional string toHex = 11; // recipient address (hex string, newer firmware)
|
||||||
|
optional bytes value = 6; // <=256 bit unsigned big endian (in wei)
|
||||||
|
optional bytes data_initial_chunk = 7; // The initial data chunk (<= 1024 bytes)
|
||||||
|
optional uint32 data_length = 8; // Length of transaction payload
|
||||||
|
optional uint32 chain_id = 9; // Chain Id for EIP 155
|
||||||
|
optional uint32 tx_type = 10; // (only for Wanchain)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Device asks for more data from transaction payload, or returns the signature.
|
||||||
|
* If data_length is set, device awaits that many more bytes of payload.
|
||||||
|
* Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
|
||||||
|
* @end
|
||||||
|
* @next EthereumTxAck
|
||||||
|
*/
|
||||||
|
message EthereumTxRequest {
|
||||||
|
optional uint32 data_length = 1; // Number of bytes being requested (<= 1024)
|
||||||
|
optional uint32 signature_v = 2; // Computed signature (recovery parameter, limited to 27 or 28)
|
||||||
|
optional bytes signature_r = 3; // Computed signature R component (256 bit)
|
||||||
|
optional bytes signature_s = 4; // Computed signature S component (256 bit)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Transaction payload data.
|
||||||
|
* @next EthereumTxRequest
|
||||||
|
*/
|
||||||
|
message EthereumTxAck {
|
||||||
|
optional bytes data_chunk = 1; // Bytes from transaction payload (<= 1024 bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask device to sign message
|
||||||
|
* @start
|
||||||
|
* @next EthereumMessageSignature
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message EthereumSignMessage {
|
||||||
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
|
optional bytes message = 2; // message to be signed
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Signed message
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message EthereumMessageSignature {
|
||||||
|
optional bytes addressBin = 1; // address used to sign the message (20 bytes, legacy firmware)
|
||||||
|
optional bytes signature = 2; // signature of the message
|
||||||
|
optional string addressHex = 3; // address used to sign the message (hex string, newer firmware)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask device to verify message
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message EthereumVerifyMessage {
|
||||||
|
optional bytes addressBin = 1; // address to verify (20 bytes, legacy firmware)
|
||||||
|
optional bytes signature = 2; // signature to verify
|
||||||
|
optional bytes message = 3; // message to verify
|
||||||
|
optional string addressHex = 4; // address to verify (hex string, newer firmware)
|
||||||
|
}
|
||||||
1621
accounts/usbwallet/trezor/messages-management.pb.go
Normal file
1621
accounts/usbwallet/trezor/messages-management.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
289
accounts/usbwallet/trezor/messages-management.proto
Normal file
289
accounts/usbwallet/trezor/messages-management.proto
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
// This file originates from the SatoshiLabs Trezor `common` repository at:
|
||||||
|
// https://github.com/trezor/trezor-common/blob/master/protob/messages-management.proto
|
||||||
|
// dated 28.05.2019, commit 893fd219d4a01bcffa0cd9cfa631856371ec5aa9.
|
||||||
|
|
||||||
|
syntax = "proto2";
|
||||||
|
package hw.trezor.messages.management;
|
||||||
|
|
||||||
|
// Sugar for easier handling in Java
|
||||||
|
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
||||||
|
option java_outer_classname = "TrezorMessageManagement";
|
||||||
|
|
||||||
|
import "messages-common.proto";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Reset device to default state and ask for device details
|
||||||
|
* @start
|
||||||
|
* @next Features
|
||||||
|
*/
|
||||||
|
message Initialize {
|
||||||
|
optional bytes state = 1; // assumed device state, clear session if set and different
|
||||||
|
optional bool skip_passphrase = 2; // this session should always assume empty passphrase
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask for device details (no device reset)
|
||||||
|
* @start
|
||||||
|
* @next Features
|
||||||
|
*/
|
||||||
|
message GetFeatures {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Reports various information about the device
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message Features {
|
||||||
|
optional string vendor = 1; // name of the manufacturer, e.g. "trezor.io"
|
||||||
|
optional uint32 major_version = 2; // major version of the firmware/bootloader, e.g. 1
|
||||||
|
optional uint32 minor_version = 3; // minor version of the firmware/bootloader, e.g. 0
|
||||||
|
optional uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0
|
||||||
|
optional bool bootloader_mode = 5; // is device in bootloader mode?
|
||||||
|
optional string device_id = 6; // device's unique identifier
|
||||||
|
optional bool pin_protection = 7; // is device protected by PIN?
|
||||||
|
optional bool passphrase_protection = 8; // is node/mnemonic encrypted using passphrase?
|
||||||
|
optional string language = 9; // device language
|
||||||
|
optional string label = 10; // device description label
|
||||||
|
optional bool initialized = 12; // does device contain seed?
|
||||||
|
optional bytes revision = 13; // SCM revision of firmware
|
||||||
|
optional bytes bootloader_hash = 14; // hash of the bootloader
|
||||||
|
optional bool imported = 15; // was storage imported from an external source?
|
||||||
|
optional bool pin_cached = 16; // is PIN already cached in session?
|
||||||
|
optional bool passphrase_cached = 17; // is passphrase already cached in session?
|
||||||
|
optional bool firmware_present = 18; // is valid firmware loaded?
|
||||||
|
optional bool needs_backup = 19; // does storage need backup? (equals to Storage.needs_backup)
|
||||||
|
optional uint32 flags = 20; // device flags (equals to Storage.flags)
|
||||||
|
optional string model = 21; // device hardware model
|
||||||
|
optional uint32 fw_major = 22; // reported firmware version if in bootloader mode
|
||||||
|
optional uint32 fw_minor = 23; // reported firmware version if in bootloader mode
|
||||||
|
optional uint32 fw_patch = 24; // reported firmware version if in bootloader mode
|
||||||
|
optional string fw_vendor = 25; // reported firmware vendor if in bootloader mode
|
||||||
|
optional bytes fw_vendor_keys = 26; // reported firmware vendor keys (their hash)
|
||||||
|
optional bool unfinished_backup = 27; // report unfinished backup (equals to Storage.unfinished_backup)
|
||||||
|
optional bool no_backup = 28; // report no backup (equals to Storage.no_backup)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: clear session (removes cached PIN, passphrase, etc).
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
*/
|
||||||
|
message ClearSession {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: change language and/or label of the device
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message ApplySettings {
|
||||||
|
optional string language = 1;
|
||||||
|
optional string label = 2;
|
||||||
|
optional bool use_passphrase = 3;
|
||||||
|
optional bytes homescreen = 4;
|
||||||
|
optional PassphraseSourceType passphrase_source = 5;
|
||||||
|
optional uint32 auto_lock_delay_ms = 6;
|
||||||
|
optional uint32 display_rotation = 7; // in degrees from North
|
||||||
|
/**
|
||||||
|
* Structure representing passphrase source
|
||||||
|
*/
|
||||||
|
enum PassphraseSourceType {
|
||||||
|
ASK = 0;
|
||||||
|
DEVICE = 1;
|
||||||
|
HOST = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: set flags of the device
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message ApplyFlags {
|
||||||
|
optional uint32 flags = 1; // bitmask, can only set bits, not unset
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Starts workflow for setting/changing/removing the PIN
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message ChangePin {
|
||||||
|
optional bool remove = 1; // is PIN removal requested?
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Test if the device is alive, device sends back the message in Success response
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
*/
|
||||||
|
message Ping {
|
||||||
|
optional string message = 1; // message to send back in Success message
|
||||||
|
optional bool button_protection = 2; // ask for button press
|
||||||
|
optional bool pin_protection = 3; // ask for PIN if set in device
|
||||||
|
optional bool passphrase_protection = 4; // ask for passphrase if set in device
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Abort last operation that required user interaction
|
||||||
|
* @start
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message Cancel {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Request a sample of random data generated by hardware RNG. May be used for testing.
|
||||||
|
* @start
|
||||||
|
* @next Entropy
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message GetEntropy {
|
||||||
|
required uint32 size = 1; // size of requested entropy
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Reply with random data generated by internal RNG
|
||||||
|
* @end
|
||||||
|
*/
|
||||||
|
message Entropy {
|
||||||
|
required bytes entropy = 1; // chunk of random generated bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Request device to wipe all sensitive data and settings
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message WipeDevice {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Load seed and related internal settings from the computer
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message LoadDevice {
|
||||||
|
optional string mnemonic = 1; // seed encoded as BIP-39 mnemonic (12, 18 or 24 words)
|
||||||
|
optional hw.trezor.messages.common.HDNodeType node = 2; // BIP-32 node
|
||||||
|
optional string pin = 3; // set PIN protection
|
||||||
|
optional bool passphrase_protection = 4; // enable master node encryption using passphrase
|
||||||
|
optional string language = 5 [default='english']; // device language
|
||||||
|
optional string label = 6; // device label
|
||||||
|
optional bool skip_checksum = 7; // do not test mnemonic for valid BIP-39 checksum
|
||||||
|
optional uint32 u2f_counter = 8; // U2F counter
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Ask device to do initialization involving user interaction
|
||||||
|
* @start
|
||||||
|
* @next EntropyRequest
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message ResetDevice {
|
||||||
|
optional bool display_random = 1; // display entropy generated by the device before asking for additional entropy
|
||||||
|
optional uint32 strength = 2 [default=256]; // strength of seed in bits
|
||||||
|
optional bool passphrase_protection = 3; // enable master node encryption using passphrase
|
||||||
|
optional bool pin_protection = 4; // enable PIN protection
|
||||||
|
optional string language = 5 [default='english']; // device language
|
||||||
|
optional string label = 6; // device label
|
||||||
|
optional uint32 u2f_counter = 7; // U2F counter
|
||||||
|
optional bool skip_backup = 8; // postpone seed backup to BackupDevice workflow
|
||||||
|
optional bool no_backup = 9; // indicate that no backup is going to be made
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Perform backup of the device seed if not backed up using ResetDevice
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
*/
|
||||||
|
message BackupDevice {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Ask for additional entropy from host computer
|
||||||
|
* @next EntropyAck
|
||||||
|
*/
|
||||||
|
message EntropyRequest {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Provide additional entropy for seed generation function
|
||||||
|
* @next Success
|
||||||
|
*/
|
||||||
|
message EntropyAck {
|
||||||
|
optional bytes entropy = 1; // 256 bits (32 bytes) of random data
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Start recovery workflow asking user for specific words of mnemonic
|
||||||
|
* Used to recovery device safely even on untrusted computer.
|
||||||
|
* @start
|
||||||
|
* @next WordRequest
|
||||||
|
*/
|
||||||
|
message RecoveryDevice {
|
||||||
|
optional uint32 word_count = 1; // number of words in BIP-39 mnemonic
|
||||||
|
optional bool passphrase_protection = 2; // enable master node encryption using passphrase
|
||||||
|
optional bool pin_protection = 3; // enable PIN protection
|
||||||
|
optional string language = 4 [default='english']; // device language
|
||||||
|
optional string label = 5; // device label
|
||||||
|
optional bool enforce_wordlist = 6; // enforce BIP-39 wordlist during the process
|
||||||
|
// 7 reserved for unused recovery method
|
||||||
|
optional RecoveryDeviceType type = 8; // supported recovery type
|
||||||
|
optional uint32 u2f_counter = 9; // U2F counter
|
||||||
|
optional bool dry_run = 10; // perform dry-run recovery workflow (for safe mnemonic validation)
|
||||||
|
/**
|
||||||
|
* Type of recovery procedure. These should be used as bitmask, e.g.,
|
||||||
|
* `RecoveryDeviceType_ScrambledWords | RecoveryDeviceType_Matrix`
|
||||||
|
* listing every method supported by the host computer.
|
||||||
|
*
|
||||||
|
* Note that ScrambledWords must be supported by every implementation
|
||||||
|
* for backward compatibility; there is no way to not support it.
|
||||||
|
*/
|
||||||
|
enum RecoveryDeviceType {
|
||||||
|
// use powers of two when extending this field
|
||||||
|
RecoveryDeviceType_ScrambledWords = 0; // words in scrambled order
|
||||||
|
RecoveryDeviceType_Matrix = 1; // matrix recovery type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response: Device is waiting for user to enter word of the mnemonic
|
||||||
|
* Its position is shown only on device's internal display.
|
||||||
|
* @next WordAck
|
||||||
|
*/
|
||||||
|
message WordRequest {
|
||||||
|
optional WordRequestType type = 1;
|
||||||
|
/**
|
||||||
|
* Type of Recovery Word request
|
||||||
|
*/
|
||||||
|
enum WordRequestType {
|
||||||
|
WordRequestType_Plain = 0;
|
||||||
|
WordRequestType_Matrix9 = 1;
|
||||||
|
WordRequestType_Matrix6 = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Computer replies with word from the mnemonic
|
||||||
|
* @next WordRequest
|
||||||
|
* @next Success
|
||||||
|
* @next Failure
|
||||||
|
*/
|
||||||
|
message WordAck {
|
||||||
|
required string word = 1; // one word of mnemonic on asked position
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request: Set U2F counter
|
||||||
|
* @start
|
||||||
|
* @next Success
|
||||||
|
*/
|
||||||
|
message SetU2FCounter {
|
||||||
|
optional uint32 u2f_counter = 1; // counter
|
||||||
|
}
|
||||||
889
accounts/usbwallet/trezor/messages.pb.go
Normal file
889
accounts/usbwallet/trezor/messages.pb.go
Normal file
@@ -0,0 +1,889 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// source: messages.proto
|
||||||
|
|
||||||
|
package trezor
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
math "math"
|
||||||
|
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
//*
|
||||||
|
// Mapping between TREZOR wire identifier (uint) and a protobuf message
|
||||||
|
type MessageType int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Management
|
||||||
|
MessageType_MessageType_Initialize MessageType = 0
|
||||||
|
MessageType_MessageType_Ping MessageType = 1
|
||||||
|
MessageType_MessageType_Success MessageType = 2
|
||||||
|
MessageType_MessageType_Failure MessageType = 3
|
||||||
|
MessageType_MessageType_ChangePin MessageType = 4
|
||||||
|
MessageType_MessageType_WipeDevice MessageType = 5
|
||||||
|
MessageType_MessageType_GetEntropy MessageType = 9
|
||||||
|
MessageType_MessageType_Entropy MessageType = 10
|
||||||
|
MessageType_MessageType_LoadDevice MessageType = 13
|
||||||
|
MessageType_MessageType_ResetDevice MessageType = 14
|
||||||
|
MessageType_MessageType_Features MessageType = 17
|
||||||
|
MessageType_MessageType_PinMatrixRequest MessageType = 18
|
||||||
|
MessageType_MessageType_PinMatrixAck MessageType = 19
|
||||||
|
MessageType_MessageType_Cancel MessageType = 20
|
||||||
|
MessageType_MessageType_ClearSession MessageType = 24
|
||||||
|
MessageType_MessageType_ApplySettings MessageType = 25
|
||||||
|
MessageType_MessageType_ButtonRequest MessageType = 26
|
||||||
|
MessageType_MessageType_ButtonAck MessageType = 27
|
||||||
|
MessageType_MessageType_ApplyFlags MessageType = 28
|
||||||
|
MessageType_MessageType_BackupDevice MessageType = 34
|
||||||
|
MessageType_MessageType_EntropyRequest MessageType = 35
|
||||||
|
MessageType_MessageType_EntropyAck MessageType = 36
|
||||||
|
MessageType_MessageType_PassphraseRequest MessageType = 41
|
||||||
|
MessageType_MessageType_PassphraseAck MessageType = 42
|
||||||
|
MessageType_MessageType_PassphraseStateRequest MessageType = 77
|
||||||
|
MessageType_MessageType_PassphraseStateAck MessageType = 78
|
||||||
|
MessageType_MessageType_RecoveryDevice MessageType = 45
|
||||||
|
MessageType_MessageType_WordRequest MessageType = 46
|
||||||
|
MessageType_MessageType_WordAck MessageType = 47
|
||||||
|
MessageType_MessageType_GetFeatures MessageType = 55
|
||||||
|
MessageType_MessageType_SetU2FCounter MessageType = 63
|
||||||
|
// Bootloader
|
||||||
|
MessageType_MessageType_FirmwareErase MessageType = 6
|
||||||
|
MessageType_MessageType_FirmwareUpload MessageType = 7
|
||||||
|
MessageType_MessageType_FirmwareRequest MessageType = 8
|
||||||
|
MessageType_MessageType_SelfTest MessageType = 32
|
||||||
|
// Bitcoin
|
||||||
|
MessageType_MessageType_GetPublicKey MessageType = 11
|
||||||
|
MessageType_MessageType_PublicKey MessageType = 12
|
||||||
|
MessageType_MessageType_SignTx MessageType = 15
|
||||||
|
MessageType_MessageType_TxRequest MessageType = 21
|
||||||
|
MessageType_MessageType_TxAck MessageType = 22
|
||||||
|
MessageType_MessageType_GetAddress MessageType = 29
|
||||||
|
MessageType_MessageType_Address MessageType = 30
|
||||||
|
MessageType_MessageType_SignMessage MessageType = 38
|
||||||
|
MessageType_MessageType_VerifyMessage MessageType = 39
|
||||||
|
MessageType_MessageType_MessageSignature MessageType = 40
|
||||||
|
// Crypto
|
||||||
|
MessageType_MessageType_CipherKeyValue MessageType = 23
|
||||||
|
MessageType_MessageType_CipheredKeyValue MessageType = 48
|
||||||
|
MessageType_MessageType_SignIdentity MessageType = 53
|
||||||
|
MessageType_MessageType_SignedIdentity MessageType = 54
|
||||||
|
MessageType_MessageType_GetECDHSessionKey MessageType = 61
|
||||||
|
MessageType_MessageType_ECDHSessionKey MessageType = 62
|
||||||
|
MessageType_MessageType_CosiCommit MessageType = 71
|
||||||
|
MessageType_MessageType_CosiCommitment MessageType = 72
|
||||||
|
MessageType_MessageType_CosiSign MessageType = 73
|
||||||
|
MessageType_MessageType_CosiSignature MessageType = 74
|
||||||
|
// Debug
|
||||||
|
MessageType_MessageType_DebugLinkDecision MessageType = 100
|
||||||
|
MessageType_MessageType_DebugLinkGetState MessageType = 101
|
||||||
|
MessageType_MessageType_DebugLinkState MessageType = 102
|
||||||
|
MessageType_MessageType_DebugLinkStop MessageType = 103
|
||||||
|
MessageType_MessageType_DebugLinkLog MessageType = 104
|
||||||
|
MessageType_MessageType_DebugLinkMemoryRead MessageType = 110
|
||||||
|
MessageType_MessageType_DebugLinkMemory MessageType = 111
|
||||||
|
MessageType_MessageType_DebugLinkMemoryWrite MessageType = 112
|
||||||
|
MessageType_MessageType_DebugLinkFlashErase MessageType = 113
|
||||||
|
// Ethereum
|
||||||
|
MessageType_MessageType_EthereumGetPublicKey MessageType = 450
|
||||||
|
MessageType_MessageType_EthereumPublicKey MessageType = 451
|
||||||
|
MessageType_MessageType_EthereumGetAddress MessageType = 56
|
||||||
|
MessageType_MessageType_EthereumAddress MessageType = 57
|
||||||
|
MessageType_MessageType_EthereumSignTx MessageType = 58
|
||||||
|
MessageType_MessageType_EthereumTxRequest MessageType = 59
|
||||||
|
MessageType_MessageType_EthereumTxAck MessageType = 60
|
||||||
|
MessageType_MessageType_EthereumSignMessage MessageType = 64
|
||||||
|
MessageType_MessageType_EthereumVerifyMessage MessageType = 65
|
||||||
|
MessageType_MessageType_EthereumMessageSignature MessageType = 66
|
||||||
|
// NEM
|
||||||
|
MessageType_MessageType_NEMGetAddress MessageType = 67
|
||||||
|
MessageType_MessageType_NEMAddress MessageType = 68
|
||||||
|
MessageType_MessageType_NEMSignTx MessageType = 69
|
||||||
|
MessageType_MessageType_NEMSignedTx MessageType = 70
|
||||||
|
MessageType_MessageType_NEMDecryptMessage MessageType = 75
|
||||||
|
MessageType_MessageType_NEMDecryptedMessage MessageType = 76
|
||||||
|
// Lisk
|
||||||
|
MessageType_MessageType_LiskGetAddress MessageType = 114
|
||||||
|
MessageType_MessageType_LiskAddress MessageType = 115
|
||||||
|
MessageType_MessageType_LiskSignTx MessageType = 116
|
||||||
|
MessageType_MessageType_LiskSignedTx MessageType = 117
|
||||||
|
MessageType_MessageType_LiskSignMessage MessageType = 118
|
||||||
|
MessageType_MessageType_LiskMessageSignature MessageType = 119
|
||||||
|
MessageType_MessageType_LiskVerifyMessage MessageType = 120
|
||||||
|
MessageType_MessageType_LiskGetPublicKey MessageType = 121
|
||||||
|
MessageType_MessageType_LiskPublicKey MessageType = 122
|
||||||
|
// Tezos
|
||||||
|
MessageType_MessageType_TezosGetAddress MessageType = 150
|
||||||
|
MessageType_MessageType_TezosAddress MessageType = 151
|
||||||
|
MessageType_MessageType_TezosSignTx MessageType = 152
|
||||||
|
MessageType_MessageType_TezosSignedTx MessageType = 153
|
||||||
|
MessageType_MessageType_TezosGetPublicKey MessageType = 154
|
||||||
|
MessageType_MessageType_TezosPublicKey MessageType = 155
|
||||||
|
// Stellar
|
||||||
|
MessageType_MessageType_StellarSignTx MessageType = 202
|
||||||
|
MessageType_MessageType_StellarTxOpRequest MessageType = 203
|
||||||
|
MessageType_MessageType_StellarGetAddress MessageType = 207
|
||||||
|
MessageType_MessageType_StellarAddress MessageType = 208
|
||||||
|
MessageType_MessageType_StellarCreateAccountOp MessageType = 210
|
||||||
|
MessageType_MessageType_StellarPaymentOp MessageType = 211
|
||||||
|
MessageType_MessageType_StellarPathPaymentOp MessageType = 212
|
||||||
|
MessageType_MessageType_StellarManageOfferOp MessageType = 213
|
||||||
|
MessageType_MessageType_StellarCreatePassiveOfferOp MessageType = 214
|
||||||
|
MessageType_MessageType_StellarSetOptionsOp MessageType = 215
|
||||||
|
MessageType_MessageType_StellarChangeTrustOp MessageType = 216
|
||||||
|
MessageType_MessageType_StellarAllowTrustOp MessageType = 217
|
||||||
|
MessageType_MessageType_StellarAccountMergeOp MessageType = 218
|
||||||
|
// omitted: StellarInflationOp is not a supported operation, would be 219
|
||||||
|
MessageType_MessageType_StellarManageDataOp MessageType = 220
|
||||||
|
MessageType_MessageType_StellarBumpSequenceOp MessageType = 221
|
||||||
|
MessageType_MessageType_StellarSignedTx MessageType = 230
|
||||||
|
// TRON
|
||||||
|
MessageType_MessageType_TronGetAddress MessageType = 250
|
||||||
|
MessageType_MessageType_TronAddress MessageType = 251
|
||||||
|
MessageType_MessageType_TronSignTx MessageType = 252
|
||||||
|
MessageType_MessageType_TronSignedTx MessageType = 253
|
||||||
|
// Cardano
|
||||||
|
// dropped Sign/VerifyMessage ids 300-302
|
||||||
|
MessageType_MessageType_CardanoSignTx MessageType = 303
|
||||||
|
MessageType_MessageType_CardanoTxRequest MessageType = 304
|
||||||
|
MessageType_MessageType_CardanoGetPublicKey MessageType = 305
|
||||||
|
MessageType_MessageType_CardanoPublicKey MessageType = 306
|
||||||
|
MessageType_MessageType_CardanoGetAddress MessageType = 307
|
||||||
|
MessageType_MessageType_CardanoAddress MessageType = 308
|
||||||
|
MessageType_MessageType_CardanoTxAck MessageType = 309
|
||||||
|
MessageType_MessageType_CardanoSignedTx MessageType = 310
|
||||||
|
// Ontology
|
||||||
|
MessageType_MessageType_OntologyGetAddress MessageType = 350
|
||||||
|
MessageType_MessageType_OntologyAddress MessageType = 351
|
||||||
|
MessageType_MessageType_OntologyGetPublicKey MessageType = 352
|
||||||
|
MessageType_MessageType_OntologyPublicKey MessageType = 353
|
||||||
|
MessageType_MessageType_OntologySignTransfer MessageType = 354
|
||||||
|
MessageType_MessageType_OntologySignedTransfer MessageType = 355
|
||||||
|
MessageType_MessageType_OntologySignWithdrawOng MessageType = 356
|
||||||
|
MessageType_MessageType_OntologySignedWithdrawOng MessageType = 357
|
||||||
|
MessageType_MessageType_OntologySignOntIdRegister MessageType = 358
|
||||||
|
MessageType_MessageType_OntologySignedOntIdRegister MessageType = 359
|
||||||
|
MessageType_MessageType_OntologySignOntIdAddAttributes MessageType = 360
|
||||||
|
MessageType_MessageType_OntologySignedOntIdAddAttributes MessageType = 361
|
||||||
|
// Ripple
|
||||||
|
MessageType_MessageType_RippleGetAddress MessageType = 400
|
||||||
|
MessageType_MessageType_RippleAddress MessageType = 401
|
||||||
|
MessageType_MessageType_RippleSignTx MessageType = 402
|
||||||
|
MessageType_MessageType_RippleSignedTx MessageType = 403
|
||||||
|
// Monero
|
||||||
|
MessageType_MessageType_MoneroTransactionInitRequest MessageType = 501
|
||||||
|
MessageType_MessageType_MoneroTransactionInitAck MessageType = 502
|
||||||
|
MessageType_MessageType_MoneroTransactionSetInputRequest MessageType = 503
|
||||||
|
MessageType_MessageType_MoneroTransactionSetInputAck MessageType = 504
|
||||||
|
MessageType_MessageType_MoneroTransactionInputsPermutationRequest MessageType = 505
|
||||||
|
MessageType_MessageType_MoneroTransactionInputsPermutationAck MessageType = 506
|
||||||
|
MessageType_MessageType_MoneroTransactionInputViniRequest MessageType = 507
|
||||||
|
MessageType_MessageType_MoneroTransactionInputViniAck MessageType = 508
|
||||||
|
MessageType_MessageType_MoneroTransactionAllInputsSetRequest MessageType = 509
|
||||||
|
MessageType_MessageType_MoneroTransactionAllInputsSetAck MessageType = 510
|
||||||
|
MessageType_MessageType_MoneroTransactionSetOutputRequest MessageType = 511
|
||||||
|
MessageType_MessageType_MoneroTransactionSetOutputAck MessageType = 512
|
||||||
|
MessageType_MessageType_MoneroTransactionAllOutSetRequest MessageType = 513
|
||||||
|
MessageType_MessageType_MoneroTransactionAllOutSetAck MessageType = 514
|
||||||
|
MessageType_MessageType_MoneroTransactionSignInputRequest MessageType = 515
|
||||||
|
MessageType_MessageType_MoneroTransactionSignInputAck MessageType = 516
|
||||||
|
MessageType_MessageType_MoneroTransactionFinalRequest MessageType = 517
|
||||||
|
MessageType_MessageType_MoneroTransactionFinalAck MessageType = 518
|
||||||
|
MessageType_MessageType_MoneroKeyImageExportInitRequest MessageType = 530
|
||||||
|
MessageType_MessageType_MoneroKeyImageExportInitAck MessageType = 531
|
||||||
|
MessageType_MessageType_MoneroKeyImageSyncStepRequest MessageType = 532
|
||||||
|
MessageType_MessageType_MoneroKeyImageSyncStepAck MessageType = 533
|
||||||
|
MessageType_MessageType_MoneroKeyImageSyncFinalRequest MessageType = 534
|
||||||
|
MessageType_MessageType_MoneroKeyImageSyncFinalAck MessageType = 535
|
||||||
|
MessageType_MessageType_MoneroGetAddress MessageType = 540
|
||||||
|
MessageType_MessageType_MoneroAddress MessageType = 541
|
||||||
|
MessageType_MessageType_MoneroGetWatchKey MessageType = 542
|
||||||
|
MessageType_MessageType_MoneroWatchKey MessageType = 543
|
||||||
|
MessageType_MessageType_DebugMoneroDiagRequest MessageType = 546
|
||||||
|
MessageType_MessageType_DebugMoneroDiagAck MessageType = 547
|
||||||
|
MessageType_MessageType_MoneroGetTxKeyRequest MessageType = 550
|
||||||
|
MessageType_MessageType_MoneroGetTxKeyAck MessageType = 551
|
||||||
|
MessageType_MessageType_MoneroLiveRefreshStartRequest MessageType = 552
|
||||||
|
MessageType_MessageType_MoneroLiveRefreshStartAck MessageType = 553
|
||||||
|
MessageType_MessageType_MoneroLiveRefreshStepRequest MessageType = 554
|
||||||
|
MessageType_MessageType_MoneroLiveRefreshStepAck MessageType = 555
|
||||||
|
MessageType_MessageType_MoneroLiveRefreshFinalRequest MessageType = 556
|
||||||
|
MessageType_MessageType_MoneroLiveRefreshFinalAck MessageType = 557
|
||||||
|
// EOS
|
||||||
|
MessageType_MessageType_EosGetPublicKey MessageType = 600
|
||||||
|
MessageType_MessageType_EosPublicKey MessageType = 601
|
||||||
|
MessageType_MessageType_EosSignTx MessageType = 602
|
||||||
|
MessageType_MessageType_EosTxActionRequest MessageType = 603
|
||||||
|
MessageType_MessageType_EosTxActionAck MessageType = 604
|
||||||
|
MessageType_MessageType_EosSignedTx MessageType = 605
|
||||||
|
// Binance
|
||||||
|
MessageType_MessageType_BinanceGetAddress MessageType = 700
|
||||||
|
MessageType_MessageType_BinanceAddress MessageType = 701
|
||||||
|
MessageType_MessageType_BinanceGetPublicKey MessageType = 702
|
||||||
|
MessageType_MessageType_BinancePublicKey MessageType = 703
|
||||||
|
MessageType_MessageType_BinanceSignTx MessageType = 704
|
||||||
|
MessageType_MessageType_BinanceTxRequest MessageType = 705
|
||||||
|
MessageType_MessageType_BinanceTransferMsg MessageType = 706
|
||||||
|
MessageType_MessageType_BinanceOrderMsg MessageType = 707
|
||||||
|
MessageType_MessageType_BinanceCancelMsg MessageType = 708
|
||||||
|
MessageType_MessageType_BinanceSignedTx MessageType = 709
|
||||||
|
)
|
||||||
|
|
||||||
|
var MessageType_name = map[int32]string{
|
||||||
|
0: "MessageType_Initialize",
|
||||||
|
1: "MessageType_Ping",
|
||||||
|
2: "MessageType_Success",
|
||||||
|
3: "MessageType_Failure",
|
||||||
|
4: "MessageType_ChangePin",
|
||||||
|
5: "MessageType_WipeDevice",
|
||||||
|
9: "MessageType_GetEntropy",
|
||||||
|
10: "MessageType_Entropy",
|
||||||
|
13: "MessageType_LoadDevice",
|
||||||
|
14: "MessageType_ResetDevice",
|
||||||
|
17: "MessageType_Features",
|
||||||
|
18: "MessageType_PinMatrixRequest",
|
||||||
|
19: "MessageType_PinMatrixAck",
|
||||||
|
20: "MessageType_Cancel",
|
||||||
|
24: "MessageType_ClearSession",
|
||||||
|
25: "MessageType_ApplySettings",
|
||||||
|
26: "MessageType_ButtonRequest",
|
||||||
|
27: "MessageType_ButtonAck",
|
||||||
|
28: "MessageType_ApplyFlags",
|
||||||
|
34: "MessageType_BackupDevice",
|
||||||
|
35: "MessageType_EntropyRequest",
|
||||||
|
36: "MessageType_EntropyAck",
|
||||||
|
41: "MessageType_PassphraseRequest",
|
||||||
|
42: "MessageType_PassphraseAck",
|
||||||
|
77: "MessageType_PassphraseStateRequest",
|
||||||
|
78: "MessageType_PassphraseStateAck",
|
||||||
|
45: "MessageType_RecoveryDevice",
|
||||||
|
46: "MessageType_WordRequest",
|
||||||
|
47: "MessageType_WordAck",
|
||||||
|
55: "MessageType_GetFeatures",
|
||||||
|
63: "MessageType_SetU2FCounter",
|
||||||
|
6: "MessageType_FirmwareErase",
|
||||||
|
7: "MessageType_FirmwareUpload",
|
||||||
|
8: "MessageType_FirmwareRequest",
|
||||||
|
32: "MessageType_SelfTest",
|
||||||
|
11: "MessageType_GetPublicKey",
|
||||||
|
12: "MessageType_PublicKey",
|
||||||
|
15: "MessageType_SignTx",
|
||||||
|
21: "MessageType_TxRequest",
|
||||||
|
22: "MessageType_TxAck",
|
||||||
|
29: "MessageType_GetAddress",
|
||||||
|
30: "MessageType_Address",
|
||||||
|
38: "MessageType_SignMessage",
|
||||||
|
39: "MessageType_VerifyMessage",
|
||||||
|
40: "MessageType_MessageSignature",
|
||||||
|
23: "MessageType_CipherKeyValue",
|
||||||
|
48: "MessageType_CipheredKeyValue",
|
||||||
|
53: "MessageType_SignIdentity",
|
||||||
|
54: "MessageType_SignedIdentity",
|
||||||
|
61: "MessageType_GetECDHSessionKey",
|
||||||
|
62: "MessageType_ECDHSessionKey",
|
||||||
|
71: "MessageType_CosiCommit",
|
||||||
|
72: "MessageType_CosiCommitment",
|
||||||
|
73: "MessageType_CosiSign",
|
||||||
|
74: "MessageType_CosiSignature",
|
||||||
|
100: "MessageType_DebugLinkDecision",
|
||||||
|
101: "MessageType_DebugLinkGetState",
|
||||||
|
102: "MessageType_DebugLinkState",
|
||||||
|
103: "MessageType_DebugLinkStop",
|
||||||
|
104: "MessageType_DebugLinkLog",
|
||||||
|
110: "MessageType_DebugLinkMemoryRead",
|
||||||
|
111: "MessageType_DebugLinkMemory",
|
||||||
|
112: "MessageType_DebugLinkMemoryWrite",
|
||||||
|
113: "MessageType_DebugLinkFlashErase",
|
||||||
|
450: "MessageType_EthereumGetPublicKey",
|
||||||
|
451: "MessageType_EthereumPublicKey",
|
||||||
|
56: "MessageType_EthereumGetAddress",
|
||||||
|
57: "MessageType_EthereumAddress",
|
||||||
|
58: "MessageType_EthereumSignTx",
|
||||||
|
59: "MessageType_EthereumTxRequest",
|
||||||
|
60: "MessageType_EthereumTxAck",
|
||||||
|
64: "MessageType_EthereumSignMessage",
|
||||||
|
65: "MessageType_EthereumVerifyMessage",
|
||||||
|
66: "MessageType_EthereumMessageSignature",
|
||||||
|
67: "MessageType_NEMGetAddress",
|
||||||
|
68: "MessageType_NEMAddress",
|
||||||
|
69: "MessageType_NEMSignTx",
|
||||||
|
70: "MessageType_NEMSignedTx",
|
||||||
|
75: "MessageType_NEMDecryptMessage",
|
||||||
|
76: "MessageType_NEMDecryptedMessage",
|
||||||
|
114: "MessageType_LiskGetAddress",
|
||||||
|
115: "MessageType_LiskAddress",
|
||||||
|
116: "MessageType_LiskSignTx",
|
||||||
|
117: "MessageType_LiskSignedTx",
|
||||||
|
118: "MessageType_LiskSignMessage",
|
||||||
|
119: "MessageType_LiskMessageSignature",
|
||||||
|
120: "MessageType_LiskVerifyMessage",
|
||||||
|
121: "MessageType_LiskGetPublicKey",
|
||||||
|
122: "MessageType_LiskPublicKey",
|
||||||
|
150: "MessageType_TezosGetAddress",
|
||||||
|
151: "MessageType_TezosAddress",
|
||||||
|
152: "MessageType_TezosSignTx",
|
||||||
|
153: "MessageType_TezosSignedTx",
|
||||||
|
154: "MessageType_TezosGetPublicKey",
|
||||||
|
155: "MessageType_TezosPublicKey",
|
||||||
|
202: "MessageType_StellarSignTx",
|
||||||
|
203: "MessageType_StellarTxOpRequest",
|
||||||
|
207: "MessageType_StellarGetAddress",
|
||||||
|
208: "MessageType_StellarAddress",
|
||||||
|
210: "MessageType_StellarCreateAccountOp",
|
||||||
|
211: "MessageType_StellarPaymentOp",
|
||||||
|
212: "MessageType_StellarPathPaymentOp",
|
||||||
|
213: "MessageType_StellarManageOfferOp",
|
||||||
|
214: "MessageType_StellarCreatePassiveOfferOp",
|
||||||
|
215: "MessageType_StellarSetOptionsOp",
|
||||||
|
216: "MessageType_StellarChangeTrustOp",
|
||||||
|
217: "MessageType_StellarAllowTrustOp",
|
||||||
|
218: "MessageType_StellarAccountMergeOp",
|
||||||
|
220: "MessageType_StellarManageDataOp",
|
||||||
|
221: "MessageType_StellarBumpSequenceOp",
|
||||||
|
230: "MessageType_StellarSignedTx",
|
||||||
|
250: "MessageType_TronGetAddress",
|
||||||
|
251: "MessageType_TronAddress",
|
||||||
|
252: "MessageType_TronSignTx",
|
||||||
|
253: "MessageType_TronSignedTx",
|
||||||
|
303: "MessageType_CardanoSignTx",
|
||||||
|
304: "MessageType_CardanoTxRequest",
|
||||||
|
305: "MessageType_CardanoGetPublicKey",
|
||||||
|
306: "MessageType_CardanoPublicKey",
|
||||||
|
307: "MessageType_CardanoGetAddress",
|
||||||
|
308: "MessageType_CardanoAddress",
|
||||||
|
309: "MessageType_CardanoTxAck",
|
||||||
|
310: "MessageType_CardanoSignedTx",
|
||||||
|
350: "MessageType_OntologyGetAddress",
|
||||||
|
351: "MessageType_OntologyAddress",
|
||||||
|
352: "MessageType_OntologyGetPublicKey",
|
||||||
|
353: "MessageType_OntologyPublicKey",
|
||||||
|
354: "MessageType_OntologySignTransfer",
|
||||||
|
355: "MessageType_OntologySignedTransfer",
|
||||||
|
356: "MessageType_OntologySignWithdrawOng",
|
||||||
|
357: "MessageType_OntologySignedWithdrawOng",
|
||||||
|
358: "MessageType_OntologySignOntIdRegister",
|
||||||
|
359: "MessageType_OntologySignedOntIdRegister",
|
||||||
|
360: "MessageType_OntologySignOntIdAddAttributes",
|
||||||
|
361: "MessageType_OntologySignedOntIdAddAttributes",
|
||||||
|
400: "MessageType_RippleGetAddress",
|
||||||
|
401: "MessageType_RippleAddress",
|
||||||
|
402: "MessageType_RippleSignTx",
|
||||||
|
403: "MessageType_RippleSignedTx",
|
||||||
|
501: "MessageType_MoneroTransactionInitRequest",
|
||||||
|
502: "MessageType_MoneroTransactionInitAck",
|
||||||
|
503: "MessageType_MoneroTransactionSetInputRequest",
|
||||||
|
504: "MessageType_MoneroTransactionSetInputAck",
|
||||||
|
505: "MessageType_MoneroTransactionInputsPermutationRequest",
|
||||||
|
506: "MessageType_MoneroTransactionInputsPermutationAck",
|
||||||
|
507: "MessageType_MoneroTransactionInputViniRequest",
|
||||||
|
508: "MessageType_MoneroTransactionInputViniAck",
|
||||||
|
509: "MessageType_MoneroTransactionAllInputsSetRequest",
|
||||||
|
510: "MessageType_MoneroTransactionAllInputsSetAck",
|
||||||
|
511: "MessageType_MoneroTransactionSetOutputRequest",
|
||||||
|
512: "MessageType_MoneroTransactionSetOutputAck",
|
||||||
|
513: "MessageType_MoneroTransactionAllOutSetRequest",
|
||||||
|
514: "MessageType_MoneroTransactionAllOutSetAck",
|
||||||
|
515: "MessageType_MoneroTransactionSignInputRequest",
|
||||||
|
516: "MessageType_MoneroTransactionSignInputAck",
|
||||||
|
517: "MessageType_MoneroTransactionFinalRequest",
|
||||||
|
518: "MessageType_MoneroTransactionFinalAck",
|
||||||
|
530: "MessageType_MoneroKeyImageExportInitRequest",
|
||||||
|
531: "MessageType_MoneroKeyImageExportInitAck",
|
||||||
|
532: "MessageType_MoneroKeyImageSyncStepRequest",
|
||||||
|
533: "MessageType_MoneroKeyImageSyncStepAck",
|
||||||
|
534: "MessageType_MoneroKeyImageSyncFinalRequest",
|
||||||
|
535: "MessageType_MoneroKeyImageSyncFinalAck",
|
||||||
|
540: "MessageType_MoneroGetAddress",
|
||||||
|
541: "MessageType_MoneroAddress",
|
||||||
|
542: "MessageType_MoneroGetWatchKey",
|
||||||
|
543: "MessageType_MoneroWatchKey",
|
||||||
|
546: "MessageType_DebugMoneroDiagRequest",
|
||||||
|
547: "MessageType_DebugMoneroDiagAck",
|
||||||
|
550: "MessageType_MoneroGetTxKeyRequest",
|
||||||
|
551: "MessageType_MoneroGetTxKeyAck",
|
||||||
|
552: "MessageType_MoneroLiveRefreshStartRequest",
|
||||||
|
553: "MessageType_MoneroLiveRefreshStartAck",
|
||||||
|
554: "MessageType_MoneroLiveRefreshStepRequest",
|
||||||
|
555: "MessageType_MoneroLiveRefreshStepAck",
|
||||||
|
556: "MessageType_MoneroLiveRefreshFinalRequest",
|
||||||
|
557: "MessageType_MoneroLiveRefreshFinalAck",
|
||||||
|
600: "MessageType_EosGetPublicKey",
|
||||||
|
601: "MessageType_EosPublicKey",
|
||||||
|
602: "MessageType_EosSignTx",
|
||||||
|
603: "MessageType_EosTxActionRequest",
|
||||||
|
604: "MessageType_EosTxActionAck",
|
||||||
|
605: "MessageType_EosSignedTx",
|
||||||
|
700: "MessageType_BinanceGetAddress",
|
||||||
|
701: "MessageType_BinanceAddress",
|
||||||
|
702: "MessageType_BinanceGetPublicKey",
|
||||||
|
703: "MessageType_BinancePublicKey",
|
||||||
|
704: "MessageType_BinanceSignTx",
|
||||||
|
705: "MessageType_BinanceTxRequest",
|
||||||
|
706: "MessageType_BinanceTransferMsg",
|
||||||
|
707: "MessageType_BinanceOrderMsg",
|
||||||
|
708: "MessageType_BinanceCancelMsg",
|
||||||
|
709: "MessageType_BinanceSignedTx",
|
||||||
|
}
|
||||||
|
|
||||||
|
var MessageType_value = map[string]int32{
|
||||||
|
"MessageType_Initialize": 0,
|
||||||
|
"MessageType_Ping": 1,
|
||||||
|
"MessageType_Success": 2,
|
||||||
|
"MessageType_Failure": 3,
|
||||||
|
"MessageType_ChangePin": 4,
|
||||||
|
"MessageType_WipeDevice": 5,
|
||||||
|
"MessageType_GetEntropy": 9,
|
||||||
|
"MessageType_Entropy": 10,
|
||||||
|
"MessageType_LoadDevice": 13,
|
||||||
|
"MessageType_ResetDevice": 14,
|
||||||
|
"MessageType_Features": 17,
|
||||||
|
"MessageType_PinMatrixRequest": 18,
|
||||||
|
"MessageType_PinMatrixAck": 19,
|
||||||
|
"MessageType_Cancel": 20,
|
||||||
|
"MessageType_ClearSession": 24,
|
||||||
|
"MessageType_ApplySettings": 25,
|
||||||
|
"MessageType_ButtonRequest": 26,
|
||||||
|
"MessageType_ButtonAck": 27,
|
||||||
|
"MessageType_ApplyFlags": 28,
|
||||||
|
"MessageType_BackupDevice": 34,
|
||||||
|
"MessageType_EntropyRequest": 35,
|
||||||
|
"MessageType_EntropyAck": 36,
|
||||||
|
"MessageType_PassphraseRequest": 41,
|
||||||
|
"MessageType_PassphraseAck": 42,
|
||||||
|
"MessageType_PassphraseStateRequest": 77,
|
||||||
|
"MessageType_PassphraseStateAck": 78,
|
||||||
|
"MessageType_RecoveryDevice": 45,
|
||||||
|
"MessageType_WordRequest": 46,
|
||||||
|
"MessageType_WordAck": 47,
|
||||||
|
"MessageType_GetFeatures": 55,
|
||||||
|
"MessageType_SetU2FCounter": 63,
|
||||||
|
"MessageType_FirmwareErase": 6,
|
||||||
|
"MessageType_FirmwareUpload": 7,
|
||||||
|
"MessageType_FirmwareRequest": 8,
|
||||||
|
"MessageType_SelfTest": 32,
|
||||||
|
"MessageType_GetPublicKey": 11,
|
||||||
|
"MessageType_PublicKey": 12,
|
||||||
|
"MessageType_SignTx": 15,
|
||||||
|
"MessageType_TxRequest": 21,
|
||||||
|
"MessageType_TxAck": 22,
|
||||||
|
"MessageType_GetAddress": 29,
|
||||||
|
"MessageType_Address": 30,
|
||||||
|
"MessageType_SignMessage": 38,
|
||||||
|
"MessageType_VerifyMessage": 39,
|
||||||
|
"MessageType_MessageSignature": 40,
|
||||||
|
"MessageType_CipherKeyValue": 23,
|
||||||
|
"MessageType_CipheredKeyValue": 48,
|
||||||
|
"MessageType_SignIdentity": 53,
|
||||||
|
"MessageType_SignedIdentity": 54,
|
||||||
|
"MessageType_GetECDHSessionKey": 61,
|
||||||
|
"MessageType_ECDHSessionKey": 62,
|
||||||
|
"MessageType_CosiCommit": 71,
|
||||||
|
"MessageType_CosiCommitment": 72,
|
||||||
|
"MessageType_CosiSign": 73,
|
||||||
|
"MessageType_CosiSignature": 74,
|
||||||
|
"MessageType_DebugLinkDecision": 100,
|
||||||
|
"MessageType_DebugLinkGetState": 101,
|
||||||
|
"MessageType_DebugLinkState": 102,
|
||||||
|
"MessageType_DebugLinkStop": 103,
|
||||||
|
"MessageType_DebugLinkLog": 104,
|
||||||
|
"MessageType_DebugLinkMemoryRead": 110,
|
||||||
|
"MessageType_DebugLinkMemory": 111,
|
||||||
|
"MessageType_DebugLinkMemoryWrite": 112,
|
||||||
|
"MessageType_DebugLinkFlashErase": 113,
|
||||||
|
"MessageType_EthereumGetPublicKey": 450,
|
||||||
|
"MessageType_EthereumPublicKey": 451,
|
||||||
|
"MessageType_EthereumGetAddress": 56,
|
||||||
|
"MessageType_EthereumAddress": 57,
|
||||||
|
"MessageType_EthereumSignTx": 58,
|
||||||
|
"MessageType_EthereumTxRequest": 59,
|
||||||
|
"MessageType_EthereumTxAck": 60,
|
||||||
|
"MessageType_EthereumSignMessage": 64,
|
||||||
|
"MessageType_EthereumVerifyMessage": 65,
|
||||||
|
"MessageType_EthereumMessageSignature": 66,
|
||||||
|
"MessageType_NEMGetAddress": 67,
|
||||||
|
"MessageType_NEMAddress": 68,
|
||||||
|
"MessageType_NEMSignTx": 69,
|
||||||
|
"MessageType_NEMSignedTx": 70,
|
||||||
|
"MessageType_NEMDecryptMessage": 75,
|
||||||
|
"MessageType_NEMDecryptedMessage": 76,
|
||||||
|
"MessageType_LiskGetAddress": 114,
|
||||||
|
"MessageType_LiskAddress": 115,
|
||||||
|
"MessageType_LiskSignTx": 116,
|
||||||
|
"MessageType_LiskSignedTx": 117,
|
||||||
|
"MessageType_LiskSignMessage": 118,
|
||||||
|
"MessageType_LiskMessageSignature": 119,
|
||||||
|
"MessageType_LiskVerifyMessage": 120,
|
||||||
|
"MessageType_LiskGetPublicKey": 121,
|
||||||
|
"MessageType_LiskPublicKey": 122,
|
||||||
|
"MessageType_TezosGetAddress": 150,
|
||||||
|
"MessageType_TezosAddress": 151,
|
||||||
|
"MessageType_TezosSignTx": 152,
|
||||||
|
"MessageType_TezosSignedTx": 153,
|
||||||
|
"MessageType_TezosGetPublicKey": 154,
|
||||||
|
"MessageType_TezosPublicKey": 155,
|
||||||
|
"MessageType_StellarSignTx": 202,
|
||||||
|
"MessageType_StellarTxOpRequest": 203,
|
||||||
|
"MessageType_StellarGetAddress": 207,
|
||||||
|
"MessageType_StellarAddress": 208,
|
||||||
|
"MessageType_StellarCreateAccountOp": 210,
|
||||||
|
"MessageType_StellarPaymentOp": 211,
|
||||||
|
"MessageType_StellarPathPaymentOp": 212,
|
||||||
|
"MessageType_StellarManageOfferOp": 213,
|
||||||
|
"MessageType_StellarCreatePassiveOfferOp": 214,
|
||||||
|
"MessageType_StellarSetOptionsOp": 215,
|
||||||
|
"MessageType_StellarChangeTrustOp": 216,
|
||||||
|
"MessageType_StellarAllowTrustOp": 217,
|
||||||
|
"MessageType_StellarAccountMergeOp": 218,
|
||||||
|
"MessageType_StellarManageDataOp": 220,
|
||||||
|
"MessageType_StellarBumpSequenceOp": 221,
|
||||||
|
"MessageType_StellarSignedTx": 230,
|
||||||
|
"MessageType_TronGetAddress": 250,
|
||||||
|
"MessageType_TronAddress": 251,
|
||||||
|
"MessageType_TronSignTx": 252,
|
||||||
|
"MessageType_TronSignedTx": 253,
|
||||||
|
"MessageType_CardanoSignTx": 303,
|
||||||
|
"MessageType_CardanoTxRequest": 304,
|
||||||
|
"MessageType_CardanoGetPublicKey": 305,
|
||||||
|
"MessageType_CardanoPublicKey": 306,
|
||||||
|
"MessageType_CardanoGetAddress": 307,
|
||||||
|
"MessageType_CardanoAddress": 308,
|
||||||
|
"MessageType_CardanoTxAck": 309,
|
||||||
|
"MessageType_CardanoSignedTx": 310,
|
||||||
|
"MessageType_OntologyGetAddress": 350,
|
||||||
|
"MessageType_OntologyAddress": 351,
|
||||||
|
"MessageType_OntologyGetPublicKey": 352,
|
||||||
|
"MessageType_OntologyPublicKey": 353,
|
||||||
|
"MessageType_OntologySignTransfer": 354,
|
||||||
|
"MessageType_OntologySignedTransfer": 355,
|
||||||
|
"MessageType_OntologySignWithdrawOng": 356,
|
||||||
|
"MessageType_OntologySignedWithdrawOng": 357,
|
||||||
|
"MessageType_OntologySignOntIdRegister": 358,
|
||||||
|
"MessageType_OntologySignedOntIdRegister": 359,
|
||||||
|
"MessageType_OntologySignOntIdAddAttributes": 360,
|
||||||
|
"MessageType_OntologySignedOntIdAddAttributes": 361,
|
||||||
|
"MessageType_RippleGetAddress": 400,
|
||||||
|
"MessageType_RippleAddress": 401,
|
||||||
|
"MessageType_RippleSignTx": 402,
|
||||||
|
"MessageType_RippleSignedTx": 403,
|
||||||
|
"MessageType_MoneroTransactionInitRequest": 501,
|
||||||
|
"MessageType_MoneroTransactionInitAck": 502,
|
||||||
|
"MessageType_MoneroTransactionSetInputRequest": 503,
|
||||||
|
"MessageType_MoneroTransactionSetInputAck": 504,
|
||||||
|
"MessageType_MoneroTransactionInputsPermutationRequest": 505,
|
||||||
|
"MessageType_MoneroTransactionInputsPermutationAck": 506,
|
||||||
|
"MessageType_MoneroTransactionInputViniRequest": 507,
|
||||||
|
"MessageType_MoneroTransactionInputViniAck": 508,
|
||||||
|
"MessageType_MoneroTransactionAllInputsSetRequest": 509,
|
||||||
|
"MessageType_MoneroTransactionAllInputsSetAck": 510,
|
||||||
|
"MessageType_MoneroTransactionSetOutputRequest": 511,
|
||||||
|
"MessageType_MoneroTransactionSetOutputAck": 512,
|
||||||
|
"MessageType_MoneroTransactionAllOutSetRequest": 513,
|
||||||
|
"MessageType_MoneroTransactionAllOutSetAck": 514,
|
||||||
|
"MessageType_MoneroTransactionSignInputRequest": 515,
|
||||||
|
"MessageType_MoneroTransactionSignInputAck": 516,
|
||||||
|
"MessageType_MoneroTransactionFinalRequest": 517,
|
||||||
|
"MessageType_MoneroTransactionFinalAck": 518,
|
||||||
|
"MessageType_MoneroKeyImageExportInitRequest": 530,
|
||||||
|
"MessageType_MoneroKeyImageExportInitAck": 531,
|
||||||
|
"MessageType_MoneroKeyImageSyncStepRequest": 532,
|
||||||
|
"MessageType_MoneroKeyImageSyncStepAck": 533,
|
||||||
|
"MessageType_MoneroKeyImageSyncFinalRequest": 534,
|
||||||
|
"MessageType_MoneroKeyImageSyncFinalAck": 535,
|
||||||
|
"MessageType_MoneroGetAddress": 540,
|
||||||
|
"MessageType_MoneroAddress": 541,
|
||||||
|
"MessageType_MoneroGetWatchKey": 542,
|
||||||
|
"MessageType_MoneroWatchKey": 543,
|
||||||
|
"MessageType_DebugMoneroDiagRequest": 546,
|
||||||
|
"MessageType_DebugMoneroDiagAck": 547,
|
||||||
|
"MessageType_MoneroGetTxKeyRequest": 550,
|
||||||
|
"MessageType_MoneroGetTxKeyAck": 551,
|
||||||
|
"MessageType_MoneroLiveRefreshStartRequest": 552,
|
||||||
|
"MessageType_MoneroLiveRefreshStartAck": 553,
|
||||||
|
"MessageType_MoneroLiveRefreshStepRequest": 554,
|
||||||
|
"MessageType_MoneroLiveRefreshStepAck": 555,
|
||||||
|
"MessageType_MoneroLiveRefreshFinalRequest": 556,
|
||||||
|
"MessageType_MoneroLiveRefreshFinalAck": 557,
|
||||||
|
"MessageType_EosGetPublicKey": 600,
|
||||||
|
"MessageType_EosPublicKey": 601,
|
||||||
|
"MessageType_EosSignTx": 602,
|
||||||
|
"MessageType_EosTxActionRequest": 603,
|
||||||
|
"MessageType_EosTxActionAck": 604,
|
||||||
|
"MessageType_EosSignedTx": 605,
|
||||||
|
"MessageType_BinanceGetAddress": 700,
|
||||||
|
"MessageType_BinanceAddress": 701,
|
||||||
|
"MessageType_BinanceGetPublicKey": 702,
|
||||||
|
"MessageType_BinancePublicKey": 703,
|
||||||
|
"MessageType_BinanceSignTx": 704,
|
||||||
|
"MessageType_BinanceTxRequest": 705,
|
||||||
|
"MessageType_BinanceTransferMsg": 706,
|
||||||
|
"MessageType_BinanceOrderMsg": 707,
|
||||||
|
"MessageType_BinanceCancelMsg": 708,
|
||||||
|
"MessageType_BinanceSignedTx": 709,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x MessageType) Enum() *MessageType {
|
||||||
|
p := new(MessageType)
|
||||||
|
*p = x
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x MessageType) String() string {
|
||||||
|
return proto.EnumName(MessageType_name, int32(x))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MessageType) UnmarshalJSON(data []byte) error {
|
||||||
|
value, err := proto.UnmarshalJSONEnum(MessageType_value, data, "MessageType")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*x = MessageType(value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (MessageType) EnumDescriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_4dc296cbfe5ffcd5, []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireIn = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50002,
|
||||||
|
Name: "hw.trezor.messages.wire_in",
|
||||||
|
Tag: "varint,50002,opt,name=wire_in",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireOut = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50003,
|
||||||
|
Name: "hw.trezor.messages.wire_out",
|
||||||
|
Tag: "varint,50003,opt,name=wire_out",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireDebugIn = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50004,
|
||||||
|
Name: "hw.trezor.messages.wire_debug_in",
|
||||||
|
Tag: "varint,50004,opt,name=wire_debug_in",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireDebugOut = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50005,
|
||||||
|
Name: "hw.trezor.messages.wire_debug_out",
|
||||||
|
Tag: "varint,50005,opt,name=wire_debug_out",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireTiny = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50006,
|
||||||
|
Name: "hw.trezor.messages.wire_tiny",
|
||||||
|
Tag: "varint,50006,opt,name=wire_tiny",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireBootloader = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50007,
|
||||||
|
Name: "hw.trezor.messages.wire_bootloader",
|
||||||
|
Tag: "varint,50007,opt,name=wire_bootloader",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
var E_WireNoFsm = &proto.ExtensionDesc{
|
||||||
|
ExtendedType: (*descriptor.EnumValueOptions)(nil),
|
||||||
|
ExtensionType: (*bool)(nil),
|
||||||
|
Field: 50008,
|
||||||
|
Name: "hw.trezor.messages.wire_no_fsm",
|
||||||
|
Tag: "varint,50008,opt,name=wire_no_fsm",
|
||||||
|
Filename: "messages.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterEnum("hw.trezor.messages.MessageType", MessageType_name, MessageType_value)
|
||||||
|
proto.RegisterExtension(E_WireIn)
|
||||||
|
proto.RegisterExtension(E_WireOut)
|
||||||
|
proto.RegisterExtension(E_WireDebugIn)
|
||||||
|
proto.RegisterExtension(E_WireDebugOut)
|
||||||
|
proto.RegisterExtension(E_WireTiny)
|
||||||
|
proto.RegisterExtension(E_WireBootloader)
|
||||||
|
proto.RegisterExtension(E_WireNoFsm)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("messages.proto", fileDescriptor_4dc296cbfe5ffcd5) }
|
||||||
|
|
||||||
|
var fileDescriptor_4dc296cbfe5ffcd5 = []byte{
|
||||||
|
// 2430 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x9a, 0xd9, 0x73, 0x1c, 0xc5,
|
||||||
|
0x1d, 0xc7, 0xb3, 0xab, 0x11, 0x88, 0xf6, 0x41, 0x23, 0xb0, 0x2d, 0xaf, 0x2f, 0xf9, 0xc0, 0x96,
|
||||||
|
0x2f, 0xd9, 0x10, 0x0c, 0x44, 0x38, 0x60, 0x69, 0xb5, 0x12, 0x8a, 0xb5, 0x5a, 0x97, 0x76, 0xb1,
|
||||||
|
0x1f, 0x5d, 0xa3, 0x9d, 0xd6, 0x6e, 0x97, 0x67, 0x67, 0x86, 0x9e, 0x1e, 0x49, 0xeb, 0xa7, 0x9c,
|
||||||
|
0x3c, 0x13, 0x48, 0xc0, 0xb9, 0xa9, 0xa4, 0x2a, 0x21, 0x57, 0x85, 0x1c, 0x4e, 0x25, 0x55, 0x39,
|
||||||
|
0x08, 0x24, 0x2f, 0xc9, 0x43, 0x52, 0x9c, 0x86, 0x40, 0xee, 0x90, 0xe4, 0x0f, 0xc8, 0xc5, 0x91,
|
||||||
|
0xa4, 0x7a, 0xa6, 0xbb, 0xe7, 0xd8, 0xdf, 0xae, 0x36, 0x6f, 0x58, 0xf3, 0xf9, 0x7d, 0x7f, 0x47,
|
||||||
|
0xff, 0xfa, 0x37, 0xdd, 0xb3, 0xa0, 0xcd, 0x2d, 0xe2, 0xfb, 0x66, 0x83, 0xf8, 0xe3, 0x1e, 0x73,
|
||||||
|
0xb9, 0x3b, 0x3c, 0xdc, 0x5c, 0x1d, 0xe7, 0x8c, 0x5c, 0x76, 0xd9, 0xb8, 0x7a, 0x52, 0x18, 0x6d,
|
||||||
|
0xb8, 0x6e, 0xc3, 0x26, 0x27, 0x42, 0x62, 0x29, 0x58, 0x3e, 0x61, 0x11, 0xbf, 0xce, 0xa8, 0xc7,
|
||||||
|
0x5d, 0x16, 0x59, 0x1d, 0xf9, 0xfe, 0x7d, 0x68, 0x43, 0x39, 0xc2, 0x6b, 0x6d, 0x8f, 0x0c, 0x1f,
|
||||||
|
0x40, 0x5b, 0x13, 0xff, 0xbc, 0x38, 0xe7, 0x50, 0x4e, 0x4d, 0x9b, 0x5e, 0x26, 0xf8, 0x5d, 0x85,
|
||||||
|
0xa1, 0x87, 0xaf, 0x8e, 0xe4, 0x9e, 0xba, 0x3a, 0x92, 0x1b, 0x2e, 0x20, 0x9c, 0xa4, 0xce, 0x51,
|
||||||
|
0xa7, 0x81, 0x73, 0x05, 0x43, 0x3c, 0x1f, 0xde, 0x85, 0x6e, 0x4e, 0x3e, 0xab, 0x06, 0xf5, 0x3a,
|
||||||
|
0xf1, 0x7d, 0x9c, 0x2f, 0x18, 0x57, 0x80, 0xc7, 0x33, 0x26, 0xb5, 0x03, 0x46, 0xf0, 0x80, 0x7c,
|
||||||
|
0xbc, 0x07, 0x6d, 0x49, 0x3e, 0x2e, 0x36, 0x4d, 0xa7, 0x41, 0xce, 0x51, 0x07, 0x1b, 0x52, 0x7e,
|
||||||
|
0x34, 0x1d, 0xe0, 0x05, 0xea, 0x91, 0x69, 0xb2, 0x42, 0xeb, 0x04, 0x0f, 0xc2, 0xc4, 0x2c, 0xe1,
|
||||||
|
0x25, 0x87, 0x33, 0xd7, 0x6b, 0xe3, 0x1b, 0xe0, 0x10, 0xd5, 0x63, 0x24, 0x63, 0xc8, 0x08, 0xcc,
|
||||||
|
0xbb, 0xa6, 0x25, 0x5d, 0x6c, 0x92, 0x02, 0x7b, 0xd1, 0xb6, 0x24, 0xb1, 0x48, 0x7c, 0xc2, 0x25,
|
||||||
|
0xb2, 0x59, 0x22, 0xbb, 0xd1, 0x2d, 0xa9, 0x3c, 0x89, 0xc9, 0x03, 0x46, 0x7c, 0x7c, 0x93, 0x74,
|
||||||
|
0x72, 0x10, 0xed, 0xcc, 0x94, 0xb0, 0x6c, 0x72, 0x46, 0xd7, 0x16, 0xc9, 0x83, 0x01, 0xf1, 0x39,
|
||||||
|
0x1e, 0x96, 0xdc, 0x11, 0x34, 0x02, 0x72, 0x93, 0xf5, 0x4b, 0xf8, 0xe6, 0xc2, 0x46, 0xb5, 0x24,
|
||||||
|
0x4f, 0x47, 0x81, 0x0f, 0xa7, 0x8a, 0x67, 0x3a, 0x75, 0x62, 0xe3, 0x5b, 0x12, 0x0b, 0xb7, 0x2f,
|
||||||
|
0xad, 0x56, 0xb4, 0x89, 0xc9, 0xaa, 0xc4, 0xf7, 0xa9, 0xeb, 0xe0, 0x11, 0x19, 0xf9, 0x7e, 0xb4,
|
||||||
|
0x3d, 0xc9, 0x4c, 0x7a, 0x9e, 0xdd, 0xae, 0x12, 0xce, 0xa9, 0xd3, 0xf0, 0xf1, 0x76, 0x18, 0x9a,
|
||||||
|
0x0a, 0x38, 0x77, 0x1d, 0x15, 0x7b, 0x41, 0xc6, 0x7e, 0x28, 0xbd, 0x98, 0x11, 0x24, 0x02, 0xdf,
|
||||||
|
0xd1, 0x11, 0xf8, 0xd6, 0x0e, 0x97, 0x33, 0xb6, 0xd9, 0xf0, 0xf1, 0x4e, 0xe9, 0x2f, 0x13, 0xf8,
|
||||||
|
0x94, 0x59, 0xbf, 0x14, 0x78, 0xb2, 0xe4, 0xfb, 0x24, 0x73, 0x00, 0x15, 0x80, 0x65, 0x55, 0x41,
|
||||||
|
0xed, 0x87, 0x57, 0x57, 0x52, 0x22, 0xaa, 0x03, 0x52, 0xe7, 0x10, 0xda, 0x95, 0x2a, 0xb9, 0xe9,
|
||||||
|
0xfb, 0x5e, 0x93, 0x99, 0x3e, 0x51, 0x52, 0x87, 0xa5, 0xd4, 0xd1, 0x74, 0x11, 0x62, 0x50, 0xa8,
|
||||||
|
0x1d, 0xc9, 0xe4, 0x78, 0x0c, 0xed, 0x83, 0xe1, 0x2a, 0x37, 0xb9, 0x96, 0x2e, 0x4b, 0xe9, 0x93,
|
||||||
|
0x68, 0x77, 0x0f, 0x5a, 0xe8, 0x2f, 0x64, 0xf4, 0x33, 0xd9, 0x2f, 0x92, 0xba, 0xbb, 0x42, 0x58,
|
||||||
|
0x5b, 0xd6, 0xe8, 0x38, 0xdc, 0xb9, 0x17, 0x5c, 0x66, 0x29, 0xd7, 0xe3, 0xf0, 0x0e, 0x15, 0x88,
|
||||||
|
0xf0, 0x77, 0x02, 0x56, 0x98, 0x25, 0x5c, 0xf7, 0xf6, 0x5d, 0x70, 0x73, 0x54, 0x09, 0x7f, 0xe0,
|
||||||
|
0xf6, 0x99, 0xa2, 0x1b, 0x38, 0x9c, 0x30, 0x7c, 0x9f, 0xae, 0x72, 0x0a, 0x9a, 0xa1, 0xac, 0xb5,
|
||||||
|
0x6a, 0x32, 0x52, 0x12, 0x49, 0xe2, 0xeb, 0xa2, 0x9e, 0xfd, 0x9e, 0x00, 0xc7, 0xd2, 0x89, 0x29,
|
||||||
|
0xf0, 0x01, 0xcf, 0x76, 0x4d, 0x0b, 0x5f, 0x9f, 0x20, 0x0f, 0xa3, 0x1d, 0x10, 0xa9, 0x12, 0x1c,
|
||||||
|
0x2a, 0x0c, 0x5d, 0x51, 0xe8, 0xbe, 0xf4, 0xf6, 0xac, 0x12, 0x7b, 0xb9, 0x26, 0x98, 0xd1, 0x84,
|
||||||
|
0x5c, 0xa6, 0xe7, 0x66, 0x09, 0x3f, 0x17, 0x2c, 0xd9, 0xb4, 0x7e, 0x96, 0xb4, 0xf1, 0x06, 0x99,
|
||||||
|
0x45, 0x66, 0x5e, 0xc5, 0xc0, 0x46, 0x59, 0xcd, 0x9d, 0xe9, 0x3d, 0x59, 0xa5, 0x0d, 0xa7, 0xb6,
|
||||||
|
0x86, 0x6f, 0x84, 0xcd, 0x6b, 0x7a, 0xfb, 0x6f, 0x91, 0xe6, 0x3b, 0xd0, 0x4d, 0x69, 0x40, 0x2c,
|
||||||
|
0xc5, 0xd6, 0xae, 0x93, 0x6e, 0xd2, 0xb2, 0x98, 0x98, 0xb6, 0xbb, 0xe0, 0x49, 0xa7, 0x1e, 0xef,
|
||||||
|
0x96, 0xea, 0x99, 0xb5, 0x14, 0xc1, 0xc9, 0x7f, 0xe3, 0x83, 0xf0, 0x5a, 0x9e, 0x27, 0x8c, 0x2e,
|
||||||
|
0xb7, 0x15, 0x74, 0x48, 0x42, 0x99, 0x61, 0x26, 0xff, 0x5b, 0xc8, 0x85, 0x9d, 0x81, 0xc7, 0xa4,
|
||||||
|
0xbf, 0x4c, 0x8f, 0x16, 0xa9, 0xd7, 0x24, 0xec, 0x2c, 0x69, 0x9f, 0x37, 0xed, 0x80, 0xe0, 0x6d,
|
||||||
|
0xb0, 0x5a, 0x44, 0x11, 0x4b, 0x73, 0x27, 0xa5, 0x5a, 0x66, 0x7d, 0x84, 0xbb, 0x39, 0x8b, 0x38,
|
||||||
|
0x9c, 0xf2, 0x36, 0x3e, 0x05, 0xcf, 0x04, 0xc1, 0x10, 0x4b, 0x53, 0x77, 0xea, 0x41, 0xb5, 0x2b,
|
||||||
|
0xfb, 0xca, 0x28, 0x4e, 0xdf, 0x2f, 0x07, 0xa3, 0x58, 0xcd, 0xf7, 0x76, 0x19, 0x31, 0x69, 0xea,
|
||||||
|
0x5e, 0x78, 0xc4, 0x14, 0x5d, 0x9f, 0x16, 0xdd, 0x56, 0x8b, 0x72, 0x3c, 0x0b, 0xeb, 0xc4, 0x44,
|
||||||
|
0x8b, 0x38, 0x1c, 0xdf, 0x2f, 0x75, 0x32, 0xef, 0x10, 0x41, 0x89, 0x04, 0xf0, 0x1c, 0xbc, 0x36,
|
||||||
|
0xea, 0x79, 0x54, 0xf3, 0xf7, 0x49, 0x91, 0x13, 0xe9, 0xdc, 0xa6, 0xc9, 0x52, 0xd0, 0x98, 0xa7,
|
||||||
|
0xce, 0xa5, 0x69, 0x52, 0xa7, 0xe1, 0xdc, 0xb7, 0x0a, 0x1b, 0x9f, 0x48, 0x0e, 0x92, 0xa3, 0x5d,
|
||||||
|
0x0c, 0x66, 0x09, 0x0f, 0x87, 0x0f, 0x26, 0x85, 0x21, 0x65, 0x90, 0x4d, 0x44, 0xc3, 0x11, 0xb9,
|
||||||
|
0x5c, 0x30, 0x9e, 0x04, 0x02, 0x4d, 0x50, 0xae, 0x87, 0x1b, 0x05, 0xe3, 0x09, 0x60, 0x39, 0x35,
|
||||||
|
0x34, 0xef, 0x36, 0x70, 0x53, 0x0a, 0x1d, 0x46, 0x7b, 0x40, 0xa6, 0x4c, 0x5a, 0x2e, 0x6b, 0x2f,
|
||||||
|
0x12, 0xd3, 0xc2, 0x8e, 0x94, 0xbb, 0x35, 0x3d, 0x0c, 0x32, 0x28, 0x76, 0xa5, 0xe2, 0x11, 0x34,
|
||||||
|
0xda, 0x03, 0xbb, 0xc0, 0x28, 0x27, 0xd8, 0x93, 0x92, 0xdd, 0xbc, 0xcf, 0xd8, 0xa6, 0xdf, 0x8c,
|
||||||
|
0x06, 0xd7, 0x83, 0x12, 0x3d, 0x9a, 0x96, 0x2d, 0x71, 0xd1, 0xc2, 0x41, 0x2b, 0x35, 0x43, 0x9e,
|
||||||
|
0x19, 0x90, 0xeb, 0x38, 0x96, 0xae, 0xb8, 0x82, 0x63, 0xf2, 0x59, 0x75, 0x3c, 0x1a, 0x4b, 0xbf,
|
||||||
|
0x16, 0x12, 0xb2, 0x6a, 0x6b, 0xdf, 0x2d, 0x35, 0x33, 0xe9, 0x2b, 0x52, 0x61, 0xef, 0x81, 0x77,
|
||||||
|
0xa4, 0xc2, 0xe4, 0x98, 0x9a, 0x80, 0xdf, 0x88, 0x8a, 0x8a, 0xc7, 0xd5, 0x3d, 0x52, 0x2e, 0xb3,
|
||||||
|
0xd0, 0x31, 0x28, 0xc6, 0xd6, 0x69, 0xa9, 0x96, 0x29, 0x63, 0xd2, 0xa7, 0x1a, 0x2c, 0x67, 0x24,
|
||||||
|
0x7a, 0x14, 0xed, 0x85, 0xd0, 0xf4, 0x14, 0x9a, 0x94, 0xf0, 0x38, 0x3a, 0x00, 0xc1, 0x1d, 0xd3,
|
||||||
|
0x68, 0x0a, 0x0e, 0x76, 0xa1, 0x54, 0x4e, 0xd4, 0xb1, 0x08, 0xcf, 0xd8, 0x85, 0x52, 0x59, 0x11,
|
||||||
|
0xd3, 0xf0, 0x91, 0x75, 0xa1, 0x54, 0x96, 0xd5, 0x2b, 0xc1, 0x6f, 0x4c, 0x09, 0x10, 0xab, 0xb6,
|
||||||
|
0x86, 0x67, 0xe0, 0x01, 0xb4, 0x50, 0x2a, 0x4f, 0x93, 0x3a, 0x6b, 0x7b, 0x5c, 0xe5, 0x78, 0x16,
|
||||||
|
0xae, 0x5d, 0x0c, 0x12, 0x4b, 0xa1, 0xf3, 0xf0, 0xd2, 0xce, 0x53, 0xff, 0x52, 0x22, 0x3f, 0x06,
|
||||||
|
0x07, 0x27, 0x28, 0x85, 0xf8, 0x5d, 0xce, 0xc3, 0xd4, 0xbf, 0x24, 0x33, 0xe4, 0xf0, 0xe9, 0x4c,
|
||||||
|
0x11, 0x61, 0x8a, 0x81, 0x54, 0xc9, 0x34, 0xa4, 0x62, 0x54, 0xd4, 0x2b, 0x52, 0x2a, 0xb3, 0x1f,
|
||||||
|
0x05, 0xd6, 0xb1, 0x80, 0xab, 0x70, 0xd5, 0x04, 0x9b, 0xee, 0x8c, 0x35, 0xf8, 0x8d, 0x22, 0x4b,
|
||||||
|
0x11, 0xef, 0xaf, 0x36, 0x3c, 0x50, 0x05, 0x17, 0x43, 0x97, 0xf5, 0xc9, 0x3d, 0x95, 0x48, 0x8d,
|
||||||
|
0x5c, 0x76, 0xfd, 0x44, 0x61, 0x1f, 0xcb, 0x69, 0xb1, 0x91, 0x0e, 0x4e, 0x41, 0x8f, 0xe7, 0xf4,
|
||||||
|
0x3b, 0x6c, 0x5b, 0x07, 0x24, 0x8b, 0x7b, 0x25, 0xa7, 0x5f, 0x16, 0xdb, 0x41, 0x26, 0x2c, 0xef,
|
||||||
|
0x27, 0x72, 0x7a, 0x34, 0xec, 0x82, 0xc2, 0x8a, 0xe3, 0xff, 0x64, 0x4e, 0x8f, 0x86, 0x42, 0x07,
|
||||||
|
0x19, 0x63, 0x9f, 0xca, 0xe9, 0xfe, 0x49, 0x9f, 0xe2, 0x38, 0xb1, 0x6d, 0x93, 0xc9, 0xe0, 0x7e,
|
||||||
|
0x9e, 0xd3, 0x0d, 0xb9, 0x1b, 0xa0, 0x6a, 0x6b, 0x15, 0x4f, 0xcd, 0x86, 0x5f, 0x74, 0x89, 0x50,
|
||||||
|
0xa2, 0x89, 0xd2, 0xfd, 0xb2, 0x4b, 0x84, 0x92, 0x54, 0xd8, 0xaf, 0x94, 0xe0, 0xf1, 0xf4, 0x91,
|
||||||
|
0x5a, 0x62, 0x45, 0x46, 0xc2, 0x23, 0x72, 0x5d, 0x1c, 0x38, 0x2b, 0x1e, 0x7e, 0x2e, 0xa7, 0xa7,
|
||||||
|
0xd8, 0x4e, 0x00, 0x3f, 0x67, 0xb6, 0xc5, 0x4b, 0xb7, 0xe2, 0xe1, 0xe7, 0x73, 0x7a, 0xea, 0x8c,
|
||||||
|
0x82, 0x20, 0x6f, 0xc6, 0xf0, 0x0b, 0xbd, 0xe1, 0xb2, 0xe9, 0x98, 0x0d, 0x52, 0x59, 0x5e, 0x26,
|
||||||
|
0xac, 0xe2, 0xe1, 0x17, 0x15, 0x7c, 0x3b, 0x3a, 0xd4, 0x35, 0x62, 0x71, 0xc6, 0xa7, 0x2b, 0xda,
|
||||||
|
0xe6, 0xa5, 0x9c, 0xde, 0x11, 0x7b, 0xa0, 0x75, 0x20, 0xbc, 0xe2, 0x71, 0xea, 0x3a, 0x7e, 0xc5,
|
||||||
|
0xc3, 0x2f, 0xf7, 0x0e, 0x26, 0xba, 0x45, 0xd7, 0x58, 0xe0, 0x8b, 0xc8, 0xaf, 0xf5, 0x16, 0x9e,
|
||||||
|
0xb4, 0x6d, 0x77, 0x55, 0xb1, 0xaf, 0x28, 0xf6, 0x58, 0x7a, 0x10, 0x2b, 0x36, 0x2a, 0x72, 0x99,
|
||||||
|
0xb0, 0x06, 0xa9, 0x78, 0xf8, 0xd5, 0xde, 0xca, 0x51, 0x4d, 0xa6, 0x4d, 0x6e, 0x56, 0x3c, 0xfc,
|
||||||
|
0x5a, 0x6f, 0xe5, 0xa9, 0xa0, 0xe5, 0x55, 0x45, 0x03, 0x39, 0x75, 0xa1, 0xfc, 0x7a, 0x4e, 0xef,
|
||||||
|
0xe4, 0x1d, 0x5d, 0x9a, 0x32, 0xdc, 0x0d, 0x6f, 0xe4, 0xf4, 0xb4, 0x49, 0xf7, 0x38, 0x73, 0x9d,
|
||||||
|
0x44, 0xa3, 0xbd, 0x99, 0xd3, 0x83, 0x6b, 0x5b, 0x16, 0x53, 0xcc, 0x5b, 0x39, 0x7d, 0x48, 0xde,
|
||||||
|
0x9a, 0x65, 0xe4, 0x26, 0x78, 0xbb, 0xdb, 0x56, 0x97, 0x48, 0x18, 0xd2, 0x3b, 0x5d, 0xf6, 0x53,
|
||||||
|
0xd1, 0x64, 0x96, 0xe9, 0xb8, 0x52, 0xea, 0x1b, 0x79, 0xb8, 0x49, 0x25, 0x15, 0xbf, 0x69, 0x9f,
|
||||||
|
0xca, 0xeb, 0x0f, 0x03, 0x7b, 0x00, 0x30, 0xb5, 0xe3, 0xbf, 0xd9, 0x5b, 0x34, 0x06, 0xbf, 0x95,
|
||||||
|
0x87, 0xb7, 0x68, 0x2c, 0xaa, 0xaa, 0xf2, 0xed, 0x3c, 0xbc, 0x45, 0x25, 0xa9, 0xb0, 0xef, 0xe4,
|
||||||
|
0xf5, 0x3b, 0x76, 0x04, 0x4c, 0x47, 0x9c, 0x07, 0xae, 0xe6, 0xe1, 0x45, 0x4d, 0x54, 0x26, 0xac,
|
||||||
|
0xe0, 0x77, 0x95, 0x58, 0x66, 0xd6, 0x54, 0x1c, 0xee, 0xda, 0x6e, 0xa3, 0x9d, 0x08, 0xef, 0x37,
|
||||||
|
0x5d, 0x24, 0x15, 0xaa, 0xb8, 0xdf, 0xe6, 0xf5, 0x15, 0x7e, 0xb4, 0x8b, 0x64, 0x5c, 0x9d, 0xdf,
|
||||||
|
0xe5, 0xe1, 0x73, 0x9a, 0x82, 0x63, 0xf2, 0xf7, 0xeb, 0xc8, 0x86, 0x8b, 0xcd, 0x4c, 0xc7, 0x5f,
|
||||||
|
0x26, 0x0c, 0xff, 0x41, 0xc9, 0x66, 0xc6, 0x58, 0x12, 0x26, 0x96, 0xc6, 0xff, 0xa8, 0xb4, 0xc7,
|
||||||
|
0xd1, 0xfe, 0x6e, 0xf8, 0x05, 0xca, 0x9b, 0x16, 0x33, 0x57, 0x2b, 0x4e, 0x03, 0xff, 0x49, 0xc9,
|
||||||
|
0x9f, 0x44, 0xb7, 0x76, 0x97, 0x4f, 0x5a, 0xfc, 0x39, 0xaf, 0x3f, 0x3e, 0x74, 0xb5, 0xa8, 0x38,
|
||||||
|
0x7c, 0xce, 0x5a, 0x24, 0x0d, 0xea, 0x8b, 0xbb, 0xfc, 0x1b, 0x79, 0x78, 0xae, 0xa5, 0x7d, 0xa4,
|
||||||
|
0x6d, 0xfe, 0xa2, 0xbc, 0x9c, 0x42, 0x47, 0x7a, 0x7a, 0x99, 0xb4, 0xac, 0x49, 0xce, 0x19, 0x5d,
|
||||||
|
0x0a, 0x38, 0xf1, 0xf1, 0x5f, 0x95, 0xab, 0xbb, 0xd0, 0xb1, 0x75, 0x5c, 0xa5, 0x0d, 0xff, 0x96,
|
||||||
|
0xd7, 0xa7, 0x85, 0xd4, 0x26, 0x58, 0xa4, 0x9e, 0x67, 0x93, 0x44, 0xef, 0x3c, 0x3c, 0x00, 0xbf,
|
||||||
|
0x6f, 0x23, 0x50, 0x51, 0x1f, 0x1d, 0x80, 0x3b, 0x3b, 0xa2, 0xe4, 0x6e, 0x7e, 0x64, 0x00, 0xde,
|
||||||
|
0x25, 0x31, 0x14, 0x36, 0xf6, 0xa3, 0x0a, 0x7b, 0x37, 0x1a, 0x4b, 0xdd, 0x9f, 0x5d, 0x87, 0x30,
|
||||||
|
0x37, 0x5c, 0x79, 0xb3, 0x2e, 0x66, 0xfc, 0x9c, 0x43, 0xb9, 0x1a, 0x00, 0x7f, 0x1f, 0xd0, 0x17,
|
||||||
|
0xbb, 0x03, 0xeb, 0x1a, 0x89, 0x6d, 0xf6, 0x0f, 0x65, 0x90, 0xa9, 0x5c, 0x87, 0x41, 0x95, 0xf0,
|
||||||
|
0x39, 0xc7, 0x0b, 0xb4, 0xa7, 0x7f, 0x2a, 0xc3, 0xf5, 0xc2, 0x53, 0x86, 0xc2, 0xdb, 0xbf, 0x94,
|
||||||
|
0xd1, 0x19, 0x74, 0x6a, 0x9d, 0xf0, 0xbc, 0x80, 0xfb, 0xe7, 0x08, 0x6b, 0x05, 0xdc, 0x14, 0x7f,
|
||||||
|
0x50, 0x6e, 0xff, 0xad, 0x14, 0x4e, 0xa3, 0xdb, 0xfe, 0x3f, 0x05, 0xe1, 0xff, 0x4d, 0x65, 0x7d,
|
||||||
|
0x37, 0x3a, 0xbe, 0xbe, 0xf5, 0x79, 0xea, 0x50, 0xe5, 0xf7, 0x2d, 0x65, 0x79, 0x07, 0x3a, 0xdc,
|
||||||
|
0x9f, 0xa5, 0xf0, 0xf7, 0xb6, 0xb2, 0xba, 0x07, 0x9d, 0xec, 0x69, 0x35, 0x69, 0xdb, 0x51, 0xc0,
|
||||||
|
0x55, 0xa2, 0x2b, 0xfc, 0x4e, 0xbf, 0x4b, 0x93, 0x34, 0x16, 0x5e, 0xff, 0xd3, 0x6f, 0x96, 0xe2,
|
||||||
|
0x98, 0x10, 0xf0, 0xc4, 0xa2, 0xfe, 0xb7, 0xdf, 0x2c, 0xb5, 0xa5, 0xf0, 0xf7, 0x7e, 0xa3, 0x4f,
|
||||||
|
0x7f, 0x93, 0xb6, 0x5d, 0x09, 0x78, 0x22, 0xc5, 0x0f, 0x18, 0x7d, 0xfa, 0xd3, 0x96, 0xc2, 0xdf,
|
||||||
|
0x07, 0xfb, 0xf5, 0x17, 0x7e, 0xf4, 0x49, 0x36, 0xed, 0x87, 0xfa, 0xf5, 0xa7, 0x2d, 0x85, 0xbf,
|
||||||
|
0x0f, 0xf7, 0x6b, 0x35, 0x43, 0x1d, 0xd3, 0x56, 0xbe, 0x3e, 0x62, 0xc0, 0x03, 0x13, 0xb6, 0x12,
|
||||||
|
0x7e, 0x1e, 0x52, 0x16, 0x77, 0xa2, 0xa3, 0x9d, 0x16, 0x67, 0x49, 0x7b, 0xae, 0x65, 0x36, 0x48,
|
||||||
|
0x69, 0xcd, 0x73, 0x19, 0x4f, 0x6e, 0xfa, 0x47, 0x94, 0x5d, 0x66, 0xd0, 0x76, 0xb3, 0x13, 0xbe,
|
||||||
|
0x1e, 0xed, 0x99, 0x93, 0xb2, 0xa9, 0xb6, 0x9d, 0x7a, 0x95, 0x13, 0x7d, 0x5a, 0xff, 0x58, 0xcf,
|
||||||
|
0x9c, 0xb2, 0x56, 0xc2, 0xcf, 0xc7, 0x0d, 0x78, 0xa0, 0x77, 0x5a, 0xa4, 0x8a, 0xf7, 0x98, 0x32,
|
||||||
|
0xbb, 0x0d, 0x1d, 0xec, 0xc3, 0x4c, 0x78, 0x7a, 0xdc, 0x80, 0x47, 0x79, 0x64, 0x92, 0x18, 0xe5,
|
||||||
|
0x9f, 0x36, 0xe0, 0x51, 0x1e, 0x81, 0x8a, 0xfa, 0x8c, 0x01, 0x9f, 0x7a, 0xb4, 0xdc, 0x05, 0x93,
|
||||||
|
0xd7, 0x9b, 0xe2, 0xbd, 0xfe, 0x59, 0x03, 0x9e, 0xe7, 0x11, 0xa9, 0xb1, 0xcf, 0x19, 0xf0, 0xc5,
|
||||||
|
0x24, 0xfc, 0x50, 0x14, 0xb1, 0xd3, 0xd4, 0x6c, 0xa8, 0x0a, 0x7c, 0xde, 0x80, 0xef, 0x50, 0x19,
|
||||||
|
0x5c, 0x64, 0xfe, 0x05, 0xa5, 0x9c, 0x39, 0x2d, 0xeb, 0x50, 0x6b, 0x6b, 0x67, 0x89, 0xfe, 0xa9,
|
||||||
|
0xe3, 0x8b, 0x06, 0x7c, 0x60, 0x49, 0xd3, 0x42, 0xf7, 0x4b, 0x3d, 0x7b, 0x64, 0x9e, 0xae, 0x90,
|
||||||
|
0x45, 0xb2, 0xcc, 0x88, 0xdf, 0xac, 0x72, 0x93, 0xe9, 0x6e, 0x7c, 0xd2, 0x80, 0x8f, 0x16, 0xb0,
|
||||||
|
0x95, 0xf0, 0xf3, 0x65, 0xa3, 0xd7, 0xab, 0x24, 0x65, 0x11, 0xb7, 0xe2, 0x57, 0x94, 0x1b, 0xf0,
|
||||||
|
0x4d, 0x97, 0x31, 0x12, 0x5e, 0xbe, 0xda, 0x6f, 0x36, 0xa9, 0x46, 0xfc, 0x5a, 0xbf, 0xd9, 0xe8,
|
||||||
|
0x3e, 0xfc, 0xba, 0x01, 0x7f, 0x0a, 0x28, 0x65, 0x6e, 0xdc, 0xd7, 0x0c, 0xf8, 0x7e, 0x50, 0x4a,
|
||||||
|
0xde, 0xb7, 0x5f, 0x31, 0xf4, 0x67, 0x96, 0x2d, 0x19, 0x48, 0x9e, 0x26, 0x5e, 0xed, 0xd2, 0x27,
|
||||||
|
0x25, 0xd7, 0x17, 0x07, 0xe9, 0xe4, 0xbb, 0xf3, 0xd7, 0x06, 0x7c, 0xff, 0x49, 0xa0, 0x22, 0x81,
|
||||||
|
0xd7, 0x0c, 0xf8, 0xfe, 0x53, 0x4a, 0x7c, 0x58, 0x78, 0xbd, 0xcb, 0xee, 0x98, 0xa2, 0x8e, 0xe9,
|
||||||
|
0xd4, 0x93, 0x07, 0xa7, 0x1f, 0x0c, 0xc2, 0xbb, 0x43, 0x92, 0x0a, 0xfb, 0xe1, 0x20, 0x7c, 0x73,
|
||||||
|
0x89, 0x05, 0xe3, 0xa2, 0xfc, 0x68, 0x10, 0xbe, 0xb9, 0x48, 0x36, 0x06, 0x7f, 0x3c, 0x08, 0xdf,
|
||||||
|
0xae, 0x24, 0x28, 0x2b, 0xf8, 0x74, 0x6f, 0xb9, 0xf8, 0x76, 0xf5, 0x93, 0x41, 0xf8, 0xaa, 0xa1,
|
||||||
|
0x40, 0x79, 0x18, 0x2f, 0xfb, 0x0d, 0xfc, 0xcc, 0x20, 0x7c, 0xd5, 0x90, 0x68, 0x85, 0x59, 0x11,
|
||||||
|
0xf7, 0x6c, 0x6f, 0xdf, 0xd1, 0x8f, 0xb4, 0x02, 0xfc, 0x69, 0x6f, 0x41, 0xbd, 0x30, 0x3f, 0x93,
|
||||||
|
0x31, 0x4e, 0x9c, 0x46, 0xd7, 0xaf, 0x52, 0x46, 0x2e, 0x52, 0x67, 0x78, 0xef, 0x78, 0xf4, 0x4b,
|
||||||
|
0xff, 0xb8, 0xfa, 0xa5, 0x7f, 0xbc, 0xe4, 0x04, 0xad, 0xf0, 0xe7, 0x12, 0xf9, 0x95, 0x60, 0xe4,
|
||||||
|
0xb9, 0x87, 0x06, 0x46, 0x73, 0x63, 0x43, 0x8b, 0xd7, 0x09, 0x9b, 0x39, 0x67, 0xe2, 0x5e, 0x34,
|
||||||
|
0x14, 0x5a, 0xbb, 0x01, 0xef, 0xc7, 0xfc, 0x79, 0x69, 0x1e, 0xba, 0xac, 0x04, 0x7c, 0x62, 0x16,
|
||||||
|
0x6d, 0x0a, 0xed, 0x2d, 0x31, 0xad, 0xfa, 0x8c, 0xe1, 0x05, 0x29, 0xb2, 0x41, 0x58, 0x86, 0x63,
|
||||||
|
0x6e, 0xce, 0x99, 0x98, 0x43, 0x9b, 0x13, 0x42, 0x7d, 0x86, 0xf3, 0xa2, 0x54, 0xda, 0xa8, 0x95,
|
||||||
|
0x44, 0x4c, 0x67, 0xd0, 0x0d, 0xa1, 0x14, 0xa7, 0x4e, 0xbb, 0x1f, 0x95, 0x97, 0xa4, 0x4a, 0x58,
|
||||||
|
0x89, 0x1a, 0x75, 0xda, 0x13, 0xf3, 0xe8, 0xc6, 0x50, 0x61, 0xc9, 0x75, 0xb9, 0xed, 0x9a, 0x16,
|
||||||
|
0x61, 0xfd, 0xe8, 0xbc, 0x2c, 0x75, 0xc2, 0x44, 0xa6, 0xb4, 0xe9, 0x44, 0x11, 0x85, 0x99, 0x5e,
|
||||||
|
0x74, 0xdc, 0x8b, 0xcb, 0x7e, 0xab, 0x1f, 0xa5, 0x6b, 0x52, 0x29, 0xcc, 0x63, 0xc1, 0x9d, 0xf1,
|
||||||
|
0x5b, 0x53, 0x77, 0xa0, 0xfd, 0x75, 0xb7, 0x35, 0xee, 0x9b, 0xdc, 0xf5, 0x9b, 0xd4, 0x36, 0x97,
|
||||||
|
0x7c, 0xf5, 0xff, 0x79, 0xd8, 0x74, 0x49, 0x4b, 0x4d, 0x6d, 0xaa, 0x85, 0x7f, 0x94, 0x9d, 0xf3,
|
||||||
|
0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x69, 0x67, 0x5d, 0x1f, 0x22, 0x00, 0x00,
|
||||||
|
}
|
||||||
264
accounts/usbwallet/trezor/messages.proto
Normal file
264
accounts/usbwallet/trezor/messages.proto
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
// This file originates from the SatoshiLabs Trezor `common` repository at:
|
||||||
|
// https://github.com/trezor/trezor-common/blob/master/protob/messages.proto
|
||||||
|
// dated 28.05.2019, commit 893fd219d4a01bcffa0cd9cfa631856371ec5aa9.
|
||||||
|
|
||||||
|
syntax = "proto2";
|
||||||
|
package hw.trezor.messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messages for TREZOR communication
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Sugar for easier handling in Java
|
||||||
|
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
||||||
|
option java_outer_classname = "TrezorMessage";
|
||||||
|
|
||||||
|
import "google/protobuf/descriptor.proto";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for specifying message direction and type of wire (normal/debug)
|
||||||
|
*/
|
||||||
|
extend google.protobuf.EnumValueOptions {
|
||||||
|
optional bool wire_in = 50002; // message can be transmitted via wire from PC to TREZOR
|
||||||
|
optional bool wire_out = 50003; // message can be transmitted via wire from TREZOR to PC
|
||||||
|
optional bool wire_debug_in = 50004; // message can be transmitted via debug wire from PC to TREZOR
|
||||||
|
optional bool wire_debug_out = 50005; // message can be transmitted via debug wire from TREZOR to PC
|
||||||
|
optional bool wire_tiny = 50006; // message is handled by TREZOR when the USB stack is in tiny mode
|
||||||
|
optional bool wire_bootloader = 50007; // message is only handled by TREZOR Bootloader
|
||||||
|
optional bool wire_no_fsm = 50008; // message is not handled by TREZOR unless the USB stack is in tiny mode
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping between TREZOR wire identifier (uint) and a protobuf message
|
||||||
|
*/
|
||||||
|
enum MessageType {
|
||||||
|
|
||||||
|
// Management
|
||||||
|
MessageType_Initialize = 0 [(wire_in) = true, (wire_tiny) = true];
|
||||||
|
MessageType_Ping = 1 [(wire_in) = true];
|
||||||
|
MessageType_Success = 2 [(wire_out) = true];
|
||||||
|
MessageType_Failure = 3 [(wire_out) = true];
|
||||||
|
MessageType_ChangePin = 4 [(wire_in) = true];
|
||||||
|
MessageType_WipeDevice = 5 [(wire_in) = true];
|
||||||
|
MessageType_GetEntropy = 9 [(wire_in) = true];
|
||||||
|
MessageType_Entropy = 10 [(wire_out) = true];
|
||||||
|
MessageType_LoadDevice = 13 [(wire_in) = true];
|
||||||
|
MessageType_ResetDevice = 14 [(wire_in) = true];
|
||||||
|
MessageType_Features = 17 [(wire_out) = true];
|
||||||
|
MessageType_PinMatrixRequest = 18 [(wire_out) = true];
|
||||||
|
MessageType_PinMatrixAck = 19 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
|
||||||
|
MessageType_Cancel = 20 [(wire_in) = true, (wire_tiny) = true];
|
||||||
|
MessageType_ClearSession = 24 [(wire_in) = true];
|
||||||
|
MessageType_ApplySettings = 25 [(wire_in) = true];
|
||||||
|
MessageType_ButtonRequest = 26 [(wire_out) = true];
|
||||||
|
MessageType_ButtonAck = 27 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
|
||||||
|
MessageType_ApplyFlags = 28 [(wire_in) = true];
|
||||||
|
MessageType_BackupDevice = 34 [(wire_in) = true];
|
||||||
|
MessageType_EntropyRequest = 35 [(wire_out) = true];
|
||||||
|
MessageType_EntropyAck = 36 [(wire_in) = true];
|
||||||
|
MessageType_PassphraseRequest = 41 [(wire_out) = true];
|
||||||
|
MessageType_PassphraseAck = 42 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
|
||||||
|
MessageType_PassphraseStateRequest = 77 [(wire_out) = true];
|
||||||
|
MessageType_PassphraseStateAck = 78 [(wire_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
|
||||||
|
MessageType_RecoveryDevice = 45 [(wire_in) = true];
|
||||||
|
MessageType_WordRequest = 46 [(wire_out) = true];
|
||||||
|
MessageType_WordAck = 47 [(wire_in) = true];
|
||||||
|
MessageType_GetFeatures = 55 [(wire_in) = true];
|
||||||
|
MessageType_SetU2FCounter = 63 [(wire_in) = true];
|
||||||
|
|
||||||
|
// Bootloader
|
||||||
|
MessageType_FirmwareErase = 6 [(wire_in) = true, (wire_bootloader) = true];
|
||||||
|
MessageType_FirmwareUpload = 7 [(wire_in) = true, (wire_bootloader) = true];
|
||||||
|
MessageType_FirmwareRequest = 8 [(wire_out) = true, (wire_bootloader) = true];
|
||||||
|
MessageType_SelfTest = 32 [(wire_in) = true, (wire_bootloader) = true];
|
||||||
|
|
||||||
|
// Bitcoin
|
||||||
|
MessageType_GetPublicKey = 11 [(wire_in) = true];
|
||||||
|
MessageType_PublicKey = 12 [(wire_out) = true];
|
||||||
|
MessageType_SignTx = 15 [(wire_in) = true];
|
||||||
|
MessageType_TxRequest = 21 [(wire_out) = true];
|
||||||
|
MessageType_TxAck = 22 [(wire_in) = true];
|
||||||
|
MessageType_GetAddress = 29 [(wire_in) = true];
|
||||||
|
MessageType_Address = 30 [(wire_out) = true];
|
||||||
|
MessageType_SignMessage = 38 [(wire_in) = true];
|
||||||
|
MessageType_VerifyMessage = 39 [(wire_in) = true];
|
||||||
|
MessageType_MessageSignature = 40 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Crypto
|
||||||
|
MessageType_CipherKeyValue = 23 [(wire_in) = true];
|
||||||
|
MessageType_CipheredKeyValue = 48 [(wire_out) = true];
|
||||||
|
MessageType_SignIdentity = 53 [(wire_in) = true];
|
||||||
|
MessageType_SignedIdentity = 54 [(wire_out) = true];
|
||||||
|
MessageType_GetECDHSessionKey = 61 [(wire_in) = true];
|
||||||
|
MessageType_ECDHSessionKey = 62 [(wire_out) = true];
|
||||||
|
MessageType_CosiCommit = 71 [(wire_in) = true];
|
||||||
|
MessageType_CosiCommitment = 72 [(wire_out) = true];
|
||||||
|
MessageType_CosiSign = 73 [(wire_in) = true];
|
||||||
|
MessageType_CosiSignature = 74 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
MessageType_DebugLinkDecision = 100 [(wire_debug_in) = true, (wire_tiny) = true, (wire_no_fsm) = true];
|
||||||
|
MessageType_DebugLinkGetState = 101 [(wire_debug_in) = true, (wire_tiny) = true];
|
||||||
|
MessageType_DebugLinkState = 102 [(wire_debug_out) = true];
|
||||||
|
MessageType_DebugLinkStop = 103 [(wire_debug_in) = true];
|
||||||
|
MessageType_DebugLinkLog = 104 [(wire_debug_out) = true];
|
||||||
|
MessageType_DebugLinkMemoryRead = 110 [(wire_debug_in) = true];
|
||||||
|
MessageType_DebugLinkMemory = 111 [(wire_debug_out) = true];
|
||||||
|
MessageType_DebugLinkMemoryWrite = 112 [(wire_debug_in) = true];
|
||||||
|
MessageType_DebugLinkFlashErase = 113 [(wire_debug_in) = true];
|
||||||
|
|
||||||
|
// Ethereum
|
||||||
|
MessageType_EthereumGetPublicKey = 450 [(wire_in) = true];
|
||||||
|
MessageType_EthereumPublicKey = 451 [(wire_out) = true];
|
||||||
|
MessageType_EthereumGetAddress = 56 [(wire_in) = true];
|
||||||
|
MessageType_EthereumAddress = 57 [(wire_out) = true];
|
||||||
|
MessageType_EthereumSignTx = 58 [(wire_in) = true];
|
||||||
|
MessageType_EthereumTxRequest = 59 [(wire_out) = true];
|
||||||
|
MessageType_EthereumTxAck = 60 [(wire_in) = true];
|
||||||
|
MessageType_EthereumSignMessage = 64 [(wire_in) = true];
|
||||||
|
MessageType_EthereumVerifyMessage = 65 [(wire_in) = true];
|
||||||
|
MessageType_EthereumMessageSignature = 66 [(wire_out) = true];
|
||||||
|
|
||||||
|
// NEM
|
||||||
|
MessageType_NEMGetAddress = 67 [(wire_in) = true];
|
||||||
|
MessageType_NEMAddress = 68 [(wire_out) = true];
|
||||||
|
MessageType_NEMSignTx = 69 [(wire_in) = true];
|
||||||
|
MessageType_NEMSignedTx = 70 [(wire_out) = true];
|
||||||
|
MessageType_NEMDecryptMessage = 75 [(wire_in) = true];
|
||||||
|
MessageType_NEMDecryptedMessage = 76 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Lisk
|
||||||
|
MessageType_LiskGetAddress = 114 [(wire_in) = true];
|
||||||
|
MessageType_LiskAddress = 115 [(wire_out) = true];
|
||||||
|
MessageType_LiskSignTx = 116 [(wire_in) = true];
|
||||||
|
MessageType_LiskSignedTx = 117 [(wire_out) = true];
|
||||||
|
MessageType_LiskSignMessage = 118 [(wire_in) = true];
|
||||||
|
MessageType_LiskMessageSignature = 119 [(wire_out) = true];
|
||||||
|
MessageType_LiskVerifyMessage = 120 [(wire_in) = true];
|
||||||
|
MessageType_LiskGetPublicKey = 121 [(wire_in) = true];
|
||||||
|
MessageType_LiskPublicKey = 122 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Tezos
|
||||||
|
MessageType_TezosGetAddress = 150 [(wire_in) = true];
|
||||||
|
MessageType_TezosAddress = 151 [(wire_out) = true];
|
||||||
|
MessageType_TezosSignTx = 152 [(wire_in) = true];
|
||||||
|
MessageType_TezosSignedTx = 153 [(wire_out) = true];
|
||||||
|
MessageType_TezosGetPublicKey = 154 [(wire_in) = true];
|
||||||
|
MessageType_TezosPublicKey = 155 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Stellar
|
||||||
|
MessageType_StellarSignTx = 202 [(wire_in) = true];
|
||||||
|
MessageType_StellarTxOpRequest = 203 [(wire_out) = true];
|
||||||
|
MessageType_StellarGetAddress = 207 [(wire_in) = true];
|
||||||
|
MessageType_StellarAddress = 208 [(wire_out) = true];
|
||||||
|
MessageType_StellarCreateAccountOp = 210 [(wire_in) = true];
|
||||||
|
MessageType_StellarPaymentOp = 211 [(wire_in) = true];
|
||||||
|
MessageType_StellarPathPaymentOp = 212 [(wire_in) = true];
|
||||||
|
MessageType_StellarManageOfferOp = 213 [(wire_in) = true];
|
||||||
|
MessageType_StellarCreatePassiveOfferOp = 214 [(wire_in) = true];
|
||||||
|
MessageType_StellarSetOptionsOp = 215 [(wire_in) = true];
|
||||||
|
MessageType_StellarChangeTrustOp = 216 [(wire_in) = true];
|
||||||
|
MessageType_StellarAllowTrustOp = 217 [(wire_in) = true];
|
||||||
|
MessageType_StellarAccountMergeOp = 218 [(wire_in) = true];
|
||||||
|
// omitted: StellarInflationOp is not a supported operation, would be 219
|
||||||
|
MessageType_StellarManageDataOp = 220 [(wire_in) = true];
|
||||||
|
MessageType_StellarBumpSequenceOp = 221 [(wire_in) = true];
|
||||||
|
MessageType_StellarSignedTx = 230 [(wire_out) = true];
|
||||||
|
|
||||||
|
// TRON
|
||||||
|
MessageType_TronGetAddress = 250 [(wire_in) = true];
|
||||||
|
MessageType_TronAddress = 251 [(wire_out) = true];
|
||||||
|
MessageType_TronSignTx = 252 [(wire_in) = true];
|
||||||
|
MessageType_TronSignedTx = 253 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Cardano
|
||||||
|
// dropped Sign/VerifyMessage ids 300-302
|
||||||
|
MessageType_CardanoSignTx = 303 [(wire_in) = true];
|
||||||
|
MessageType_CardanoTxRequest = 304 [(wire_out) = true];
|
||||||
|
MessageType_CardanoGetPublicKey = 305 [(wire_in) = true];
|
||||||
|
MessageType_CardanoPublicKey = 306 [(wire_out) = true];
|
||||||
|
MessageType_CardanoGetAddress = 307 [(wire_in) = true];
|
||||||
|
MessageType_CardanoAddress = 308 [(wire_out) = true];
|
||||||
|
MessageType_CardanoTxAck = 309 [(wire_in) = true];
|
||||||
|
MessageType_CardanoSignedTx = 310 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Ontology
|
||||||
|
MessageType_OntologyGetAddress = 350 [(wire_in) = true];
|
||||||
|
MessageType_OntologyAddress = 351 [(wire_out) = true];
|
||||||
|
MessageType_OntologyGetPublicKey = 352 [(wire_in) = true];
|
||||||
|
MessageType_OntologyPublicKey = 353 [(wire_out) = true];
|
||||||
|
MessageType_OntologySignTransfer = 354 [(wire_in) = true];
|
||||||
|
MessageType_OntologySignedTransfer = 355 [(wire_out) = true];
|
||||||
|
MessageType_OntologySignWithdrawOng = 356 [(wire_in) = true];
|
||||||
|
MessageType_OntologySignedWithdrawOng = 357 [(wire_out) = true];
|
||||||
|
MessageType_OntologySignOntIdRegister = 358 [(wire_in) = true];
|
||||||
|
MessageType_OntologySignedOntIdRegister = 359 [(wire_out) = true];
|
||||||
|
MessageType_OntologySignOntIdAddAttributes = 360 [(wire_in) = true];
|
||||||
|
MessageType_OntologySignedOntIdAddAttributes = 361 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Ripple
|
||||||
|
MessageType_RippleGetAddress = 400 [(wire_in) = true];
|
||||||
|
MessageType_RippleAddress = 401 [(wire_out) = true];
|
||||||
|
MessageType_RippleSignTx = 402 [(wire_in) = true];
|
||||||
|
MessageType_RippleSignedTx = 403 [(wire_in) = true];
|
||||||
|
|
||||||
|
// Monero
|
||||||
|
MessageType_MoneroTransactionInitRequest = 501 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionInitAck = 502 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionSetInputRequest = 503 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionSetInputAck = 504 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionInputsPermutationRequest = 505 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionInputsPermutationAck = 506 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionInputViniRequest = 507 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionInputViniAck = 508 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionAllInputsSetRequest = 509 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionAllInputsSetAck = 510 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionSetOutputRequest = 511 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionSetOutputAck = 512 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionAllOutSetRequest = 513 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionAllOutSetAck = 514 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionSignInputRequest = 515 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionSignInputAck = 516 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionFinalRequest = 517 [(wire_out) = true];
|
||||||
|
MessageType_MoneroTransactionFinalAck = 518 [(wire_out) = true];
|
||||||
|
MessageType_MoneroKeyImageExportInitRequest = 530 [(wire_out) = true];
|
||||||
|
MessageType_MoneroKeyImageExportInitAck = 531 [(wire_out) = true];
|
||||||
|
MessageType_MoneroKeyImageSyncStepRequest = 532 [(wire_out) = true];
|
||||||
|
MessageType_MoneroKeyImageSyncStepAck = 533 [(wire_out) = true];
|
||||||
|
MessageType_MoneroKeyImageSyncFinalRequest = 534 [(wire_out) = true];
|
||||||
|
MessageType_MoneroKeyImageSyncFinalAck = 535 [(wire_out) = true];
|
||||||
|
MessageType_MoneroGetAddress = 540 [(wire_in) = true];
|
||||||
|
MessageType_MoneroAddress = 541 [(wire_out) = true];
|
||||||
|
MessageType_MoneroGetWatchKey = 542 [(wire_in) = true];
|
||||||
|
MessageType_MoneroWatchKey = 543 [(wire_out) = true];
|
||||||
|
MessageType_DebugMoneroDiagRequest = 546 [(wire_in) = true];
|
||||||
|
MessageType_DebugMoneroDiagAck = 547 [(wire_out) = true];
|
||||||
|
MessageType_MoneroGetTxKeyRequest = 550 [(wire_in) = true];
|
||||||
|
MessageType_MoneroGetTxKeyAck = 551 [(wire_out) = true];
|
||||||
|
MessageType_MoneroLiveRefreshStartRequest = 552 [(wire_in) = true];
|
||||||
|
MessageType_MoneroLiveRefreshStartAck = 553 [(wire_out) = true];
|
||||||
|
MessageType_MoneroLiveRefreshStepRequest = 554 [(wire_in) = true];
|
||||||
|
MessageType_MoneroLiveRefreshStepAck = 555 [(wire_out) = true];
|
||||||
|
MessageType_MoneroLiveRefreshFinalRequest = 556 [(wire_in) = true];
|
||||||
|
MessageType_MoneroLiveRefreshFinalAck = 557 [(wire_out) = true];
|
||||||
|
|
||||||
|
// EOS
|
||||||
|
MessageType_EosGetPublicKey = 600 [(wire_in) = true];
|
||||||
|
MessageType_EosPublicKey = 601 [(wire_out) = true];
|
||||||
|
MessageType_EosSignTx = 602 [(wire_in) = true];
|
||||||
|
MessageType_EosTxActionRequest = 603 [(wire_out) = true];
|
||||||
|
MessageType_EosTxActionAck = 604 [(wire_in) = true];
|
||||||
|
MessageType_EosSignedTx = 605 [(wire_out) = true];
|
||||||
|
|
||||||
|
// Binance
|
||||||
|
MessageType_BinanceGetAddress = 700 [(wire_in) = true];
|
||||||
|
MessageType_BinanceAddress = 701 [(wire_out) = true];
|
||||||
|
MessageType_BinanceGetPublicKey = 702 [(wire_in) = true];
|
||||||
|
MessageType_BinancePublicKey = 703 [(wire_out) = true];
|
||||||
|
MessageType_BinanceSignTx = 704 [(wire_in) = true];
|
||||||
|
MessageType_BinanceTxRequest = 705 [(wire_out) = true];
|
||||||
|
MessageType_BinanceTransferMsg = 706 [(wire_in) = true];
|
||||||
|
MessageType_BinanceOrderMsg = 707 [(wire_in) = true];
|
||||||
|
MessageType_BinanceCancelMsg = 708 [(wire_in) = true];
|
||||||
|
MessageType_BinanceSignedTx = 709 [(wire_out) = true];
|
||||||
|
}
|
||||||
70
accounts/usbwallet/trezor/trezor.go
Normal file
70
accounts/usbwallet/trezor/trezor.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// This file contains the implementation for interacting with the Trezor hardware
|
||||||
|
// wallets. The wire protocol spec can be found on the SatoshiLabs website:
|
||||||
|
// https://wiki.trezor.io/Developers_guide-Message_Workflows
|
||||||
|
|
||||||
|
// !!! STAHP !!!
|
||||||
|
//
|
||||||
|
// Before you touch the protocol files, you need to be aware of a breaking change
|
||||||
|
// that occurred between firmware versions 1.7.3->1.8.0 (Model One) and 2.0.10->
|
||||||
|
// 2.1.0 (Model T). The Ethereum address representation was changed from the 20
|
||||||
|
// byte binary blob to a 42 byte hex string. The upstream protocol buffer files
|
||||||
|
// only support the new format, so blindly pulling in a new spec will break old
|
||||||
|
// devices!
|
||||||
|
//
|
||||||
|
// The Trezor devs had the foresight to add the string version as a new message
|
||||||
|
// code instead of replacing the binary one. This means that the proto file can
|
||||||
|
// actually define both the old and the new versions as optional. Please ensure
|
||||||
|
// that you add back the old addresses everywhere (to avoid name clash. use the
|
||||||
|
// addressBin and addressHex names).
|
||||||
|
//
|
||||||
|
// If in doubt, reach out to @karalabe.
|
||||||
|
|
||||||
|
// To regenerate the protocol files in this package:
|
||||||
|
// - Download the latest protoc https://github.com/protocolbuffers/protobuf/releases
|
||||||
|
// - Build with the usual `./configure && make` and ensure it's on your $PATH
|
||||||
|
// - Delete all the .proto and .pb.go files, pull in fresh ones from Trezor
|
||||||
|
// - Grab the latest Go plugin `go get -u github.com/golang/protobuf/protoc-gen-go`
|
||||||
|
// - Vendor in the latest Go plugin `govendor fetch github.com/golang/protobuf/...`
|
||||||
|
|
||||||
|
//go:generate protoc -I/usr/local/include:. --go_out=import_path=trezor:. messages.proto messages-common.proto messages-management.proto messages-ethereum.proto
|
||||||
|
|
||||||
|
// Package trezor contains the wire protocol.
|
||||||
|
package trezor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Type returns the protocol buffer type number of a specific message. If the
|
||||||
|
// message is nil, this method panics!
|
||||||
|
func Type(msg proto.Message) uint16 {
|
||||||
|
return uint16(MessageType_value["MessageType_"+reflect.TypeOf(msg).Elem().Name()])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the friendly message type name of a specific protocol buffer
|
||||||
|
// type number.
|
||||||
|
func Name(kind uint16) string {
|
||||||
|
name := MessageType_name[int32(kind)]
|
||||||
|
if len(name) < 12 {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
return name[12:]
|
||||||
|
}
|
||||||
@@ -29,8 +29,9 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/karalabe/hid"
|
"github.com/karalabe/usb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Maximum time between wallet health checks to detect USB unplugs.
|
// Maximum time between wallet health checks to detect USB unplugs.
|
||||||
@@ -76,17 +77,17 @@ type wallet struct {
|
|||||||
driver driver // Hardware implementation of the low level device operations
|
driver driver // Hardware implementation of the low level device operations
|
||||||
url *accounts.URL // Textual URL uniquely identifying this wallet
|
url *accounts.URL // Textual URL uniquely identifying this wallet
|
||||||
|
|
||||||
info hid.DeviceInfo // Known USB device infos about the wallet
|
info usb.DeviceInfo // Known USB device infos about the wallet
|
||||||
device *hid.Device // USB device advertising itself as a hardware wallet
|
device usb.Device // USB device advertising itself as a hardware wallet
|
||||||
|
|
||||||
accounts []accounts.Account // List of derive accounts pinned on the hardware wallet
|
accounts []accounts.Account // List of derive accounts pinned on the hardware wallet
|
||||||
paths map[common.Address]accounts.DerivationPath // Known derivation paths for signing operations
|
paths map[common.Address]accounts.DerivationPath // Known derivation paths for signing operations
|
||||||
|
|
||||||
deriveNextPath accounts.DerivationPath // Next derivation path for account auto-discovery
|
deriveNextPaths []accounts.DerivationPath // Next derivation paths for account auto-discovery (multiple bases supported)
|
||||||
deriveNextAddr common.Address // Next derived account address for auto-discovery
|
deriveNextAddrs []common.Address // Next derived account addresses for auto-discovery (multiple bases supported)
|
||||||
deriveChain ethereum.ChainStateReader // Blockchain state reader to discover used account with
|
deriveChain ethereum.ChainStateReader // Blockchain state reader to discover used account with
|
||||||
deriveReq chan chan struct{} // Channel to request a self-derivation on
|
deriveReq chan chan struct{} // Channel to request a self-derivation on
|
||||||
deriveQuit chan chan error // Channel to terminate the self-deriver with
|
deriveQuit chan chan error // Channel to terminate the self-deriver with
|
||||||
|
|
||||||
healthQuit chan chan error
|
healthQuit chan chan error
|
||||||
|
|
||||||
@@ -273,9 +274,7 @@ func (w *wallet) close() error {
|
|||||||
w.device = nil
|
w.device = nil
|
||||||
|
|
||||||
w.accounts, w.paths = nil, nil
|
w.accounts, w.paths = nil, nil
|
||||||
w.driver.Close()
|
return w.driver.Close()
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accounts implements accounts.Wallet, returning the list of accounts pinned to
|
// Accounts implements accounts.Wallet, returning the list of accounts pinned to
|
||||||
@@ -340,57 +339,62 @@ func (w *wallet) selfDerive() {
|
|||||||
accs []accounts.Account
|
accs []accounts.Account
|
||||||
paths []accounts.DerivationPath
|
paths []accounts.DerivationPath
|
||||||
|
|
||||||
nextAddr = w.deriveNextAddr
|
nextPaths = append([]accounts.DerivationPath{}, w.deriveNextPaths...)
|
||||||
nextPath = w.deriveNextPath
|
nextAddrs = append([]common.Address{}, w.deriveNextAddrs...)
|
||||||
|
|
||||||
context = context.Background()
|
context = context.Background()
|
||||||
)
|
)
|
||||||
for empty := false; !empty; {
|
for i := 0; i < len(nextAddrs); i++ {
|
||||||
// Retrieve the next derived Ethereum account
|
for empty := false; !empty; {
|
||||||
if nextAddr == (common.Address{}) {
|
// Retrieve the next derived Ethereum account
|
||||||
if nextAddr, err = w.driver.Derive(nextPath); err != nil {
|
if nextAddrs[i] == (common.Address{}) {
|
||||||
w.log.Warn("USB wallet account derivation failed", "err", err)
|
if nextAddrs[i], err = w.driver.Derive(nextPaths[i]); err != nil {
|
||||||
|
w.log.Warn("USB wallet account derivation failed", "err", err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check the account's status against the current chain state
|
||||||
|
var (
|
||||||
|
balance *big.Int
|
||||||
|
nonce uint64
|
||||||
|
)
|
||||||
|
balance, err = w.deriveChain.BalanceAt(context, nextAddrs[i], nil)
|
||||||
|
if err != nil {
|
||||||
|
w.log.Warn("USB wallet balance retrieval failed", "err", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
nonce, err = w.deriveChain.NonceAt(context, nextAddrs[i], nil)
|
||||||
// Check the account's status against the current chain state
|
if err != nil {
|
||||||
var (
|
w.log.Warn("USB wallet nonce retrieval failed", "err", err)
|
||||||
balance *big.Int
|
break
|
||||||
nonce uint64
|
}
|
||||||
)
|
// If the next account is empty, stop self-derivation, but add for the last base path
|
||||||
balance, err = w.deriveChain.BalanceAt(context, nextAddr, nil)
|
if balance.Sign() == 0 && nonce == 0 {
|
||||||
if err != nil {
|
empty = true
|
||||||
w.log.Warn("USB wallet balance retrieval failed", "err", err)
|
if i < len(nextAddrs)-1 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
nonce, err = w.deriveChain.NonceAt(context, nextAddr, nil)
|
}
|
||||||
if err != nil {
|
// We've just self-derived a new account, start tracking it locally
|
||||||
w.log.Warn("USB wallet nonce retrieval failed", "err", err)
|
path := make(accounts.DerivationPath, len(nextPaths[i]))
|
||||||
break
|
copy(path[:], nextPaths[i][:])
|
||||||
}
|
paths = append(paths, path)
|
||||||
// If the next account is empty, stop self-derivation, but add it nonetheless
|
|
||||||
if balance.Sign() == 0 && nonce == 0 {
|
|
||||||
empty = true
|
|
||||||
}
|
|
||||||
// We've just self-derived a new account, start tracking it locally
|
|
||||||
path := make(accounts.DerivationPath, len(nextPath))
|
|
||||||
copy(path[:], nextPath[:])
|
|
||||||
paths = append(paths, path)
|
|
||||||
|
|
||||||
account := accounts.Account{
|
account := accounts.Account{
|
||||||
Address: nextAddr,
|
Address: nextAddrs[i],
|
||||||
URL: accounts.URL{Scheme: w.url.Scheme, Path: fmt.Sprintf("%s/%s", w.url.Path, path)},
|
URL: accounts.URL{Scheme: w.url.Scheme, Path: fmt.Sprintf("%s/%s", w.url.Path, path)},
|
||||||
}
|
}
|
||||||
accs = append(accs, account)
|
accs = append(accs, account)
|
||||||
|
|
||||||
// Display a log message to the user for new (or previously empty accounts)
|
// Display a log message to the user for new (or previously empty accounts)
|
||||||
if _, known := w.paths[nextAddr]; !known || (!empty && nextAddr == w.deriveNextAddr) {
|
if _, known := w.paths[nextAddrs[i]]; !known || (!empty && nextAddrs[i] == w.deriveNextAddrs[i]) {
|
||||||
w.log.Info("USB wallet discovered new account", "address", nextAddr, "path", path, "balance", balance, "nonce", nonce)
|
w.log.Info("USB wallet discovered new account", "address", nextAddrs[i], "path", path, "balance", balance, "nonce", nonce)
|
||||||
}
|
}
|
||||||
// Fetch the next potential account
|
// Fetch the next potential account
|
||||||
if !empty {
|
if !empty {
|
||||||
nextAddr = common.Address{}
|
nextAddrs[i] = common.Address{}
|
||||||
nextPath[len(nextPath)-1]++
|
nextPaths[i][len(nextPaths[i])-1]++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Self derivation complete, release device lock
|
// Self derivation complete, release device lock
|
||||||
@@ -407,8 +411,8 @@ func (w *wallet) selfDerive() {
|
|||||||
}
|
}
|
||||||
// Shift the self-derivation forward
|
// Shift the self-derivation forward
|
||||||
// TODO(karalabe): don't overwrite changes from wallet.SelfDerive
|
// TODO(karalabe): don't overwrite changes from wallet.SelfDerive
|
||||||
w.deriveNextAddr = nextAddr
|
w.deriveNextAddrs = nextAddrs
|
||||||
w.deriveNextPath = nextPath
|
w.deriveNextPaths = nextPaths
|
||||||
w.stateLock.Unlock()
|
w.stateLock.Unlock()
|
||||||
|
|
||||||
// Notify the user of termination and loop after a bit of time (to avoid trashing)
|
// Notify the user of termination and loop after a bit of time (to avoid trashing)
|
||||||
@@ -475,32 +479,61 @@ func (w *wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
|
|||||||
|
|
||||||
if _, ok := w.paths[address]; !ok {
|
if _, ok := w.paths[address]; !ok {
|
||||||
w.accounts = append(w.accounts, account)
|
w.accounts = append(w.accounts, account)
|
||||||
w.paths[address] = path
|
w.paths[address] = make(accounts.DerivationPath, len(path))
|
||||||
|
copy(w.paths[address], path)
|
||||||
}
|
}
|
||||||
return account, nil
|
return account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelfDerive implements accounts.Wallet, trying to discover accounts that the
|
// SelfDerive sets a base account derivation path from which the wallet attempts
|
||||||
// user used previously (based on the chain state), but ones that he/she did not
|
// to discover non zero accounts and automatically add them to list of tracked
|
||||||
// explicitly pin to the wallet manually. To avoid chain head monitoring, self
|
// accounts.
|
||||||
// derivation only runs during account listing (and even then throttled).
|
//
|
||||||
func (w *wallet) SelfDerive(base accounts.DerivationPath, chain ethereum.ChainStateReader) {
|
// Note, self derivaton will increment the last component of the specified path
|
||||||
|
// opposed to decending into a child path to allow discovering accounts starting
|
||||||
|
// from non zero components.
|
||||||
|
//
|
||||||
|
// Some hardware wallets switched derivation paths through their evolution, so
|
||||||
|
// this method supports providing multiple bases to discover old user accounts
|
||||||
|
// too. Only the last base will be used to derive the next empty account.
|
||||||
|
//
|
||||||
|
// You can disable automatic account discovery by calling SelfDerive with a nil
|
||||||
|
// chain state reader.
|
||||||
|
func (w *wallet) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader) {
|
||||||
w.stateLock.Lock()
|
w.stateLock.Lock()
|
||||||
defer w.stateLock.Unlock()
|
defer w.stateLock.Unlock()
|
||||||
|
|
||||||
w.deriveNextPath = make(accounts.DerivationPath, len(base))
|
w.deriveNextPaths = make([]accounts.DerivationPath, len(bases))
|
||||||
copy(w.deriveNextPath[:], base[:])
|
for i, base := range bases {
|
||||||
|
w.deriveNextPaths[i] = make(accounts.DerivationPath, len(base))
|
||||||
w.deriveNextAddr = common.Address{}
|
copy(w.deriveNextPaths[i][:], base[:])
|
||||||
|
}
|
||||||
|
w.deriveNextAddrs = make([]common.Address, len(bases))
|
||||||
w.deriveChain = chain
|
w.deriveChain = chain
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignHash implements accounts.Wallet, however signing arbitrary data is not
|
// signHash implements accounts.Wallet, however signing arbitrary data is not
|
||||||
// supported for hardware wallets, so this method will always return an error.
|
// supported for hardware wallets, so this method will always return an error.
|
||||||
func (w *wallet) SignHash(account accounts.Account, hash []byte) ([]byte, error) {
|
func (w *wallet) signHash(account accounts.Account, hash []byte) ([]byte, error) {
|
||||||
return nil, accounts.ErrNotSupported
|
return nil, accounts.ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
|
||||||
|
func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
|
||||||
|
return w.signHash(account, crypto.Keccak256(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SignDataWithPassphrase implements accounts.Wallet, attempting to sign the given
|
||||||
|
// data with the given account using passphrase as extra authentication.
|
||||||
|
// Since USB wallets don't rely on passphrases, these are silently ignored.
|
||||||
|
func (w *wallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
|
||||||
|
return w.SignData(account, mimeType, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *wallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
|
||||||
|
return w.signHash(account, accounts.TextHash(text))
|
||||||
|
}
|
||||||
|
|
||||||
// SignTx implements accounts.Wallet. It sends the transaction over to the Ledger
|
// SignTx implements accounts.Wallet. It sends the transaction over to the Ledger
|
||||||
// wallet to request a confirmation from the user. It returns either the signed
|
// wallet to request a confirmation from the user. It returns either the signed
|
||||||
// transaction or a failure if the user denied the transaction.
|
// transaction or a failure if the user denied the transaction.
|
||||||
@@ -550,8 +583,8 @@ func (w *wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID
|
|||||||
// SignHashWithPassphrase implements accounts.Wallet, however signing arbitrary
|
// SignHashWithPassphrase implements accounts.Wallet, however signing arbitrary
|
||||||
// data is not supported for Ledger wallets, so this method will always return
|
// data is not supported for Ledger wallets, so this method will always return
|
||||||
// an error.
|
// an error.
|
||||||
func (w *wallet) SignHashWithPassphrase(account accounts.Account, passphrase string, hash []byte) ([]byte, error) {
|
func (w *wallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
|
||||||
return w.SignHash(account, hash)
|
return w.SignText(account, accounts.TextHash(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given
|
// SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ environment:
|
|||||||
install:
|
install:
|
||||||
- git submodule update --init
|
- git submodule update --init
|
||||||
- rmdir C:\go /s /q
|
- rmdir C:\go /s /q
|
||||||
- appveyor DownloadFile https://storage.googleapis.com/golang/go1.11.5.windows-%GETH_ARCH%.zip
|
- appveyor DownloadFile https://dl.google.com/go/go1.13.windows-%GETH_ARCH%.zip
|
||||||
- 7z x go1.11.5.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
|
- 7z x go1.13.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
|
||||||
- go version
|
- go version
|
||||||
- gcc --version
|
- gcc --version
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,18 @@ variables `PPA_SIGNING_KEY` and `PPA_SSH_KEY` on Travis.
|
|||||||
We want to build go-ethereum with the most recent version of Go, irrespective of the Go
|
We want to build go-ethereum with the most recent version of Go, irrespective of the Go
|
||||||
version that is available in the main Ubuntu repository. In order to make this possible,
|
version that is available in the main Ubuntu repository. In order to make this possible,
|
||||||
our PPA depends on the ~gophers/ubuntu/archive PPA. Our source package build-depends on
|
our PPA depends on the ~gophers/ubuntu/archive PPA. Our source package build-depends on
|
||||||
golang-1.10, which is co-installable alongside the regular golang package. PPA dependencies
|
golang-1.11, which is co-installable alongside the regular golang package. PPA dependencies
|
||||||
can be edited at https://launchpad.net/%7Eethereum/+archive/ubuntu/ethereum/+edit-dependencies
|
can be edited at https://launchpad.net/%7Eethereum/+archive/ubuntu/ethereum/+edit-dependencies
|
||||||
|
|
||||||
## Building Packages Locally (for testing)
|
## Building Packages Locally (for testing)
|
||||||
|
|
||||||
You need to run Ubuntu to do test packaging.
|
You need to run Ubuntu to do test packaging.
|
||||||
|
|
||||||
Add the gophers PPA and install Go 1.10 and Debian packaging tools:
|
Add the gophers PPA and install Go 1.11 and Debian packaging tools:
|
||||||
|
|
||||||
$ sudo apt-add-repository ppa:gophers/ubuntu/archive
|
$ sudo apt-add-repository ppa:gophers/ubuntu/archive
|
||||||
$ sudo apt-get update
|
$ sudo apt-get update
|
||||||
$ sudo apt-get install build-essential golang-1.10 devscripts debhelper python-bzrlib python-paramiko
|
$ sudo apt-get install build-essential golang-1.11 devscripts debhelper python-bzrlib python-paramiko
|
||||||
|
|
||||||
Create the source packages:
|
Create the source packages:
|
||||||
|
|
||||||
|
|||||||
65
build/ci.go
65
build/ci.go
@@ -60,7 +60,6 @@ import (
|
|||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/build"
|
"github.com/ethereum/go-ethereum/internal/build"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
sv "github.com/ethereum/go-ethereum/swarm/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -80,12 +79,7 @@ var (
|
|||||||
executablePath("puppeth"),
|
executablePath("puppeth"),
|
||||||
executablePath("rlpdump"),
|
executablePath("rlpdump"),
|
||||||
executablePath("wnode"),
|
executablePath("wnode"),
|
||||||
}
|
executablePath("clef"),
|
||||||
|
|
||||||
// Files that end up in the swarm*.zip archive.
|
|
||||||
swarmArchiveFiles = []string{
|
|
||||||
"COPYING",
|
|
||||||
executablePath("swarm"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A debian package is created for all executables listed here.
|
// A debian package is created for all executables listed here.
|
||||||
@@ -118,16 +112,13 @@ var (
|
|||||||
BinaryName: "wnode",
|
BinaryName: "wnode",
|
||||||
Description: "Ethereum Whisper diagnostic tool",
|
Description: "Ethereum Whisper diagnostic tool",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
BinaryName: "clef",
|
||||||
|
Description: "Ethereum account management tool.",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// A debian package is created for all executables listed here.
|
// A debian package is created for all executables listed here.
|
||||||
debSwarmExecutables = []debExecutable{
|
|
||||||
{
|
|
||||||
BinaryName: "swarm",
|
|
||||||
PackageName: "ethereum-swarm",
|
|
||||||
Description: "Ethereum Swarm daemon and tools",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
debEthereum = debPackage{
|
debEthereum = debPackage{
|
||||||
Name: "ethereum",
|
Name: "ethereum",
|
||||||
@@ -135,28 +126,19 @@ var (
|
|||||||
Executables: debExecutables,
|
Executables: debExecutables,
|
||||||
}
|
}
|
||||||
|
|
||||||
debSwarm = debPackage{
|
|
||||||
Name: "ethereum-swarm",
|
|
||||||
Version: sv.Version,
|
|
||||||
Executables: debSwarmExecutables,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debian meta packages to build and push to Ubuntu PPA
|
// Debian meta packages to build and push to Ubuntu PPA
|
||||||
debPackages = []debPackage{
|
debPackages = []debPackage{
|
||||||
debSwarm,
|
|
||||||
debEthereum,
|
debEthereum,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packages to be cross-compiled by the xgo command
|
|
||||||
allCrossCompiledArchiveFiles = append(allToolsArchiveFiles, swarmArchiveFiles...)
|
|
||||||
|
|
||||||
// Distros for which packages are created.
|
// Distros for which packages are created.
|
||||||
// Note: vivid is unsupported because there is no golang-1.6 package for it.
|
// Note: vivid is unsupported because there is no golang-1.6 package for it.
|
||||||
// Note: wily is unsupported because it was officially deprecated on lanchpad.
|
// Note: wily is unsupported because it was officially deprecated on Launchpad.
|
||||||
// Note: yakkety is unsupported because it was officially deprecated on lanchpad.
|
// Note: yakkety is unsupported because it was officially deprecated on Launchpad.
|
||||||
// Note: zesty is unsupported because it was officially deprecated on lanchpad.
|
// Note: zesty is unsupported because it was officially deprecated on Launchpad.
|
||||||
// Note: artful is unsupported because it was officially deprecated on lanchpad.
|
// Note: artful is unsupported because it was officially deprecated on Launchpad.
|
||||||
debDistros = []string{"trusty", "xenial", "bionic", "cosmic"}
|
// Note: cosmic is unsupported because it was officially deprecated on Launchpad.
|
||||||
|
debDistros = []string{"trusty", "xenial", "bionic", "disco", "eoan"}
|
||||||
)
|
)
|
||||||
|
|
||||||
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
|
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
|
||||||
@@ -232,7 +214,6 @@ func doInstall(cmdline []string) {
|
|||||||
if flag.NArg() > 0 {
|
if flag.NArg() > 0 {
|
||||||
packages = flag.Args()
|
packages = flag.Args()
|
||||||
}
|
}
|
||||||
packages = build.ExpandPackagesNoVendor(packages)
|
|
||||||
|
|
||||||
if *arch == "" || *arch == runtime.GOARCH {
|
if *arch == "" || *arch == runtime.GOARCH {
|
||||||
goinstall := goTool("install", buildFlags(env)...)
|
goinstall := goTool("install", buildFlags(env)...)
|
||||||
@@ -279,6 +260,7 @@ func buildFlags(env build.Environment) (flags []string) {
|
|||||||
var ld []string
|
var ld []string
|
||||||
if env.Commit != "" {
|
if env.Commit != "" {
|
||||||
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
|
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
|
||||||
|
ld = append(ld, "-X", "main.gitDate="+env.Date)
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
ld = append(ld, "-s")
|
ld = append(ld, "-s")
|
||||||
@@ -328,13 +310,12 @@ func doTest(cmdline []string) {
|
|||||||
if len(flag.CommandLine.Args()) > 0 {
|
if len(flag.CommandLine.Args()) > 0 {
|
||||||
packages = flag.CommandLine.Args()
|
packages = flag.CommandLine.Args()
|
||||||
}
|
}
|
||||||
packages = build.ExpandPackagesNoVendor(packages)
|
|
||||||
|
|
||||||
// Run the actual tests.
|
// Run the actual tests.
|
||||||
// Test a single package at a time. CI builders are slow
|
// Test a single package at a time. CI builders are slow
|
||||||
// and some tests run into timeouts under load.
|
// and some tests run into timeouts under load.
|
||||||
gotest := goTool("test", buildFlags(env)...)
|
gotest := goTool("test", buildFlags(env)...)
|
||||||
gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m")
|
gotest.Args = append(gotest.Args, "-p", "1", "-timeout", "5m", "--short")
|
||||||
if *coverage {
|
if *coverage {
|
||||||
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
|
||||||
}
|
}
|
||||||
@@ -403,9 +384,6 @@ func doArchive(cmdline []string) {
|
|||||||
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
|
basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit))
|
||||||
geth = "geth-" + basegeth + ext
|
geth = "geth-" + basegeth + ext
|
||||||
alltools = "geth-alltools-" + basegeth + ext
|
alltools = "geth-alltools-" + basegeth + ext
|
||||||
|
|
||||||
baseswarm = archiveBasename(*arch, sv.ArchiveVersion(env.Commit))
|
|
||||||
swarm = "swarm-" + baseswarm + ext
|
|
||||||
)
|
)
|
||||||
maybeSkipArchive(env)
|
maybeSkipArchive(env)
|
||||||
if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
|
if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
|
||||||
@@ -414,10 +392,7 @@ func doArchive(cmdline []string) {
|
|||||||
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
|
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := build.WriteArchive(swarm, swarmArchiveFiles); err != nil {
|
for _, archive := range []string{geth, alltools} {
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
for _, archive := range []string{geth, alltools, swarm} {
|
|
||||||
if err := archiveUpload(archive, *upload, *signer); err != nil {
|
if err := archiveUpload(archive, *upload, *signer); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -580,8 +555,8 @@ func isUnstableBuild(env build.Environment) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type debPackage struct {
|
type debPackage struct {
|
||||||
Name string // the name of the Debian package to produce, e.g. "ethereum", or "ethereum-swarm"
|
Name string // the name of the Debian package to produce, e.g. "ethereum"
|
||||||
Version string // the clean version of the debPackage, e.g. 1.8.12 or 0.3.0, without any metadata
|
Version string // the clean version of the debPackage, e.g. 1.8.12, without any metadata
|
||||||
Executables []debExecutable // executables to be included in the package
|
Executables []debExecutable // executables to be included in the package
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -800,12 +775,8 @@ func doAndroidArchive(cmdline []string) {
|
|||||||
if os.Getenv("ANDROID_HOME") == "" {
|
if os.Getenv("ANDROID_HOME") == "" {
|
||||||
log.Fatal("Please ensure ANDROID_HOME points to your Android SDK")
|
log.Fatal("Please ensure ANDROID_HOME points to your Android SDK")
|
||||||
}
|
}
|
||||||
if os.Getenv("ANDROID_NDK") == "" {
|
|
||||||
log.Fatal("Please ensure ANDROID_NDK points to your Android NDK")
|
|
||||||
}
|
|
||||||
// Build the Android archive and Maven resources
|
// Build the Android archive and Maven resources
|
||||||
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
||||||
build.MustRun(gomobileTool("init", "--ndk", os.Getenv("ANDROID_NDK")))
|
|
||||||
build.MustRun(gomobileTool("bind", "-ldflags", "-s -w", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile"))
|
build.MustRun(gomobileTool("bind", "-ldflags", "-s -w", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile"))
|
||||||
|
|
||||||
if *local {
|
if *local {
|
||||||
@@ -927,7 +898,7 @@ func doXCodeFramework(cmdline []string) {
|
|||||||
// Build the iOS XCode framework
|
// Build the iOS XCode framework
|
||||||
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
|
||||||
build.MustRun(gomobileTool("init"))
|
build.MustRun(gomobileTool("init"))
|
||||||
bind := gomobileTool("bind", "-ldflags", "-s -w", "--target", "ios", "--tags", "ios", "-v", "github.com/ethereum/go-ethereum/mobile")
|
bind := gomobileTool("bind", "-ldflags", "-s -w", "--target", "ios", "-v", "github.com/ethereum/go-ethereum/mobile")
|
||||||
|
|
||||||
if *local {
|
if *local {
|
||||||
// If we're building locally, use the build folder and stop afterwards
|
// If we're building locally, use the build folder and stop afterwards
|
||||||
@@ -1021,7 +992,7 @@ func doXgo(cmdline []string) {
|
|||||||
|
|
||||||
if *alltools {
|
if *alltools {
|
||||||
args = append(args, []string{"--dest", GOBIN}...)
|
args = append(args, []string{"--dest", GOBIN}...)
|
||||||
for _, res := range allCrossCompiledArchiveFiles {
|
for _, res := range allToolsArchiveFiles {
|
||||||
if strings.HasPrefix(res, GOBIN) {
|
if strings.HasPrefix(res, GOBIN) {
|
||||||
// Binary tool found, cross build it explicitly
|
// Binary tool found, cross build it explicitly
|
||||||
args = append(args, "./"+filepath.Join("cmd", filepath.Base(res)))
|
args = append(args, "./"+filepath.Join("cmd", filepath.Base(res)))
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{{.Name}} ({{.VersionString}}) {{.Distro}}; urgency=low
|
|
||||||
|
|
||||||
* git build of {{.Env.Commit}}
|
|
||||||
|
|
||||||
-- {{.Author}} {{.Time}}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
Source: {{.Name}}
|
|
||||||
Section: science
|
|
||||||
Priority: extra
|
|
||||||
Maintainer: {{.Author}}
|
|
||||||
Build-Depends: debhelper (>= 8.0.0), golang-1.10
|
|
||||||
Standards-Version: 3.9.5
|
|
||||||
Homepage: https://ethereum.org
|
|
||||||
Vcs-Git: git://github.com/ethereum/go-ethereum.git
|
|
||||||
Vcs-Browser: https://github.com/ethereum/go-ethereum
|
|
||||||
|
|
||||||
{{range .Executables}}
|
|
||||||
Package: {{$.ExeName .}}
|
|
||||||
Conflicts: {{$.ExeConflicts .}}
|
|
||||||
Architecture: any
|
|
||||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
|
||||||
Built-Using: ${misc:Built-Using}
|
|
||||||
Description: {{.Description}}
|
|
||||||
{{.Description}}
|
|
||||||
{{end}}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
Copyright 2018 The go-ethereum Authors
|
|
||||||
|
|
||||||
go-ethereum is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
go-ethereum is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
AUTHORS
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
build/bin/{{.BinaryName}} usr/bin
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
# -*- makefile -*-
|
|
||||||
|
|
||||||
# Uncomment this to turn on verbose mode.
|
|
||||||
#export DH_VERBOSE=1
|
|
||||||
|
|
||||||
override_dh_auto_build:
|
|
||||||
build/env.sh /usr/lib/go-1.10/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
|
|
||||||
|
|
||||||
override_dh_auto_test:
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
||||||
@@ -2,7 +2,7 @@ Source: {{.Name}}
|
|||||||
Section: science
|
Section: science
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Maintainer: {{.Author}}
|
Maintainer: {{.Author}}
|
||||||
Build-Depends: debhelper (>= 8.0.0), golang-1.10
|
Build-Depends: debhelper (>= 8.0.0), golang-1.11
|
||||||
Standards-Version: 3.9.5
|
Standards-Version: 3.9.5
|
||||||
Homepage: https://ethereum.org
|
Homepage: https://ethereum.org
|
||||||
Vcs-Git: git://github.com/ethereum/go-ethereum.git
|
Vcs-Git: git://github.com/ethereum/go-ethereum.git
|
||||||
@@ -11,8 +11,8 @@ Vcs-Browser: https://github.com/ethereum/go-ethereum
|
|||||||
Package: {{.Name}}
|
Package: {{.Name}}
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${misc:Depends}, {{.ExeList}}
|
Depends: ${misc:Depends}, {{.ExeList}}
|
||||||
Description: Meta-package to install geth, swarm, and other tools
|
Description: Meta-package to install geth and other tools
|
||||||
Meta-package to install geth, swarm and other tools
|
Meta-package to install geth and other tools
|
||||||
|
|
||||||
{{range .Executables}}
|
{{range .Executables}}
|
||||||
Package: {{$.ExeName .}}
|
Package: {{$.ExeName .}}
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
# Uncomment this to turn on verbose mode.
|
# Uncomment this to turn on verbose mode.
|
||||||
#export DH_VERBOSE=1
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
|
# Launchpad rejects Go's access to $HOME/.cache, use custom folder
|
||||||
|
export GOCACHE=/tmp/go-build
|
||||||
|
|
||||||
override_dh_auto_build:
|
override_dh_auto_build:
|
||||||
build/env.sh /usr/lib/go-1.10/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
|
build/env.sh /usr/lib/go-1.11/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}}
|
||||||
|
|
||||||
override_dh_auto_test:
|
override_dh_auto_test:
|
||||||
|
|
||||||
|
|||||||
46
build/travis_keepalive.sh
Executable file
46
build/travis_keepalive.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# travis_keepalive runs the given command and preserves its return value,
|
||||||
|
# while it forks a child process what periodically produces a log line,
|
||||||
|
# so that Travis won't abort the build after 10 minutes.
|
||||||
|
|
||||||
|
# Why?
|
||||||
|
# `t.Log()` in Go holds the buffer until the test does not pass or fail,
|
||||||
|
# and `-race` can increase the execution time by 2-20x.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly KEEPALIVE_INTERVAL=300 # seconds => 5m
|
||||||
|
|
||||||
|
main() {
|
||||||
|
keepalive
|
||||||
|
$@
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keepalive produces a log line in each KEEPALIVE_INTERVAL.
|
||||||
|
keepalive() {
|
||||||
|
local child_pid
|
||||||
|
# Note: We fork here!
|
||||||
|
repeat "keepalive" &
|
||||||
|
child_pid=$!
|
||||||
|
ensureChildOnEXIT "${child_pid}"
|
||||||
|
}
|
||||||
|
|
||||||
|
repeat() {
|
||||||
|
local this="$1"
|
||||||
|
while true; do
|
||||||
|
echo "${this}"
|
||||||
|
sleep "${KEEPALIVE_INTERVAL}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensures that the child gets killed on normal program exit.
|
||||||
|
ensureChildOnEXIT() {
|
||||||
|
# Note: SIGINT and SIGTERM are forwarded to the child process by Bash
|
||||||
|
# automatically, so we don't have to deal with signals.
|
||||||
|
|
||||||
|
local child_pid="$1"
|
||||||
|
trap "kill ${child_pid}" EXIT
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -62,18 +62,22 @@ var (
|
|||||||
skipPrefixes = []string{
|
skipPrefixes = []string{
|
||||||
// boring stuff
|
// boring stuff
|
||||||
"vendor/", "tests/testdata/", "build/",
|
"vendor/", "tests/testdata/", "build/",
|
||||||
|
|
||||||
// don't relicense vendored sources
|
// don't relicense vendored sources
|
||||||
"cmd/internal/browser",
|
"cmd/internal/browser",
|
||||||
|
"common/bitutil/bitutil",
|
||||||
|
"common/prque/",
|
||||||
"consensus/ethash/xor.go",
|
"consensus/ethash/xor.go",
|
||||||
"crypto/bn256/",
|
"crypto/bn256/",
|
||||||
"crypto/ecies/",
|
"crypto/ecies/",
|
||||||
"crypto/secp256k1/curve.go",
|
"graphql/graphiql.go",
|
||||||
"crypto/sha3/",
|
|
||||||
"internal/jsre/deps",
|
"internal/jsre/deps",
|
||||||
"log/",
|
"log/",
|
||||||
"common/bitutil/bitutil",
|
"metrics/",
|
||||||
// don't license generated files
|
"signer/rules/deps",
|
||||||
"contracts/chequebook/contract/code.go",
|
|
||||||
|
// skip special licenses
|
||||||
|
"crypto/secp256k1", // Relicensed to BSD-3 via https://github.com/ethereum/go-ethereum/pull/17225
|
||||||
}
|
}
|
||||||
|
|
||||||
// paths with this prefix are licensed as GPL. all other files are LGPL.
|
// paths with this prefix are licensed as GPL. all other files are LGPL.
|
||||||
@@ -146,6 +150,13 @@ func (i info) gpl() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// authors implements the sort.Interface for strings in case-insensitive mode.
|
||||||
|
type authors []string
|
||||||
|
|
||||||
|
func (as authors) Len() int { return len(as) }
|
||||||
|
func (as authors) Less(i, j int) bool { return strings.ToLower(as[i]) < strings.ToLower(as[j]) }
|
||||||
|
func (as authors) Swap(i, j int) { as[i], as[j] = as[j], as[i] }
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
files = getFiles()
|
files = getFiles()
|
||||||
@@ -264,27 +275,32 @@ func mailmapLookup(authors []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeAuthors(files []string) {
|
func writeAuthors(files []string) {
|
||||||
merge := make(map[string]bool)
|
var (
|
||||||
// Add authors that Git reports as contributorxs.
|
dedup = make(map[string]bool)
|
||||||
|
list []string
|
||||||
|
)
|
||||||
|
// Add authors that Git reports as contributors.
|
||||||
// This is the primary source of author information.
|
// This is the primary source of author information.
|
||||||
for _, a := range gitAuthors(files) {
|
for _, a := range gitAuthors(files) {
|
||||||
merge[a] = true
|
if la := strings.ToLower(a); !dedup[la] {
|
||||||
|
list = append(list, a)
|
||||||
|
dedup[la] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add existing authors from the file. This should ensure that we
|
// Add existing authors from the file. This should ensure that we
|
||||||
// never lose authors, even if Git stops listing them. We can also
|
// never lose authors, even if Git stops listing them. We can also
|
||||||
// add authors manually this way.
|
// add authors manually this way.
|
||||||
for _, a := range readAuthors() {
|
for _, a := range readAuthors() {
|
||||||
merge[a] = true
|
if la := strings.ToLower(a); !dedup[la] {
|
||||||
|
list = append(list, a)
|
||||||
|
dedup[la] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Write sorted list of authors back to the file.
|
// Write sorted list of authors back to the file.
|
||||||
var result []string
|
sort.Sort(authors(list))
|
||||||
for a := range merge {
|
|
||||||
result = append(result, a)
|
|
||||||
}
|
|
||||||
sort.Strings(result)
|
|
||||||
content := new(bytes.Buffer)
|
content := new(bytes.Buffer)
|
||||||
content.WriteString(authorsFileHeader)
|
content.WriteString(authorsFileHeader)
|
||||||
for _, a := range result {
|
for _, a := range list {
|
||||||
content.WriteString(a)
|
content.WriteString(a)
|
||||||
content.WriteString("\n")
|
content.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,83 +18,199 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common/compiler"
|
"github.com/ethereum/go-ethereum/common/compiler"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
commandHelperTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...]
|
||||||
|
{{if .Description}}{{.Description}}
|
||||||
|
{{end}}{{if .Subcommands}}
|
||||||
|
SUBCOMMANDS:
|
||||||
|
{{range .Subcommands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
||||||
|
{{end}}{{end}}{{if .Flags}}
|
||||||
|
OPTIONS:
|
||||||
|
{{range $.Flags}}{{"\t"}}{{.}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}`
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
abiFlag = flag.String("abi", "", "Path to the Ethereum contract ABI json to bind, - for STDIN")
|
// Git SHA1 commit hash of the release (set via linker flags)
|
||||||
binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)")
|
gitCommit = ""
|
||||||
typFlag = flag.String("type", "", "Struct name for the binding (default = package name)")
|
gitDate = ""
|
||||||
|
|
||||||
solFlag = flag.String("sol", "", "Path to the Ethereum contract Solidity source to build and bind")
|
app *cli.App
|
||||||
solcFlag = flag.String("solc", "solc", "Solidity compiler to use if source builds are requested")
|
|
||||||
excFlag = flag.String("exc", "", "Comma separated types to exclude from binding")
|
|
||||||
|
|
||||||
pkgFlag = flag.String("pkg", "", "Package name to generate the binding into")
|
// Flags needed by abigen
|
||||||
outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)")
|
abiFlag = cli.StringFlag{
|
||||||
langFlag = flag.String("lang", "go", "Destination language for the bindings (go, java, objc)")
|
Name: "abi",
|
||||||
|
Usage: "Path to the Ethereum contract ABI json to bind, - for STDIN",
|
||||||
|
}
|
||||||
|
binFlag = cli.StringFlag{
|
||||||
|
Name: "bin",
|
||||||
|
Usage: "Path to the Ethereum contract bytecode (generate deploy method)",
|
||||||
|
}
|
||||||
|
typeFlag = cli.StringFlag{
|
||||||
|
Name: "type",
|
||||||
|
Usage: "Struct name for the binding (default = package name)",
|
||||||
|
}
|
||||||
|
jsonFlag = cli.StringFlag{
|
||||||
|
Name: "combined-json",
|
||||||
|
Usage: "Path to the combined-json file generated by compiler",
|
||||||
|
}
|
||||||
|
solFlag = cli.StringFlag{
|
||||||
|
Name: "sol",
|
||||||
|
Usage: "Path to the Ethereum contract Solidity source to build and bind",
|
||||||
|
}
|
||||||
|
solcFlag = cli.StringFlag{
|
||||||
|
Name: "solc",
|
||||||
|
Usage: "Solidity compiler to use if source builds are requested",
|
||||||
|
Value: "solc",
|
||||||
|
}
|
||||||
|
vyFlag = cli.StringFlag{
|
||||||
|
Name: "vy",
|
||||||
|
Usage: "Path to the Ethereum contract Vyper source to build and bind",
|
||||||
|
}
|
||||||
|
vyperFlag = cli.StringFlag{
|
||||||
|
Name: "vyper",
|
||||||
|
Usage: "Vyper compiler to use if source builds are requested",
|
||||||
|
Value: "vyper",
|
||||||
|
}
|
||||||
|
excFlag = cli.StringFlag{
|
||||||
|
Name: "exc",
|
||||||
|
Usage: "Comma separated types to exclude from binding",
|
||||||
|
}
|
||||||
|
pkgFlag = cli.StringFlag{
|
||||||
|
Name: "pkg",
|
||||||
|
Usage: "Package name to generate the binding into",
|
||||||
|
}
|
||||||
|
outFlag = cli.StringFlag{
|
||||||
|
Name: "out",
|
||||||
|
Usage: "Output file for the generated binding (default = stdout)",
|
||||||
|
}
|
||||||
|
langFlag = cli.StringFlag{
|
||||||
|
Name: "lang",
|
||||||
|
Usage: "Destination language for the bindings (go, java, objc)",
|
||||||
|
Value: "go",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func init() {
|
||||||
// Parse and ensure all needed inputs are specified
|
app = utils.NewApp(gitCommit, gitDate, "ethereum checkpoint helper tool")
|
||||||
flag.Parse()
|
app.Flags = []cli.Flag{
|
||||||
|
abiFlag,
|
||||||
if *abiFlag == "" && *solFlag == "" {
|
binFlag,
|
||||||
fmt.Printf("No contract ABI (--abi) or Solidity source (--sol) specified\n")
|
typeFlag,
|
||||||
os.Exit(-1)
|
jsonFlag,
|
||||||
} else if (*abiFlag != "" || *binFlag != "" || *typFlag != "") && *solFlag != "" {
|
solFlag,
|
||||||
fmt.Printf("Contract ABI (--abi), bytecode (--bin) and type (--type) flags are mutually exclusive with the Solidity source (--sol) flag\n")
|
solcFlag,
|
||||||
os.Exit(-1)
|
vyFlag,
|
||||||
|
vyperFlag,
|
||||||
|
excFlag,
|
||||||
|
pkgFlag,
|
||||||
|
outFlag,
|
||||||
|
langFlag,
|
||||||
}
|
}
|
||||||
if *pkgFlag == "" {
|
app.Action = utils.MigrateFlags(abigen)
|
||||||
fmt.Printf("No destination package specified (--pkg)\n")
|
cli.CommandHelpTemplate = commandHelperTemplate
|
||||||
os.Exit(-1)
|
}
|
||||||
|
|
||||||
|
func abigen(c *cli.Context) error {
|
||||||
|
utils.CheckExclusive(c, abiFlag, jsonFlag, solFlag, vyFlag) // Only one source can be selected.
|
||||||
|
if c.GlobalString(pkgFlag.Name) == "" {
|
||||||
|
utils.Fatalf("No destination package specified (--pkg)")
|
||||||
}
|
}
|
||||||
var lang bind.Lang
|
var lang bind.Lang
|
||||||
switch *langFlag {
|
switch c.GlobalString(langFlag.Name) {
|
||||||
case "go":
|
case "go":
|
||||||
lang = bind.LangGo
|
lang = bind.LangGo
|
||||||
case "java":
|
case "java":
|
||||||
lang = bind.LangJava
|
lang = bind.LangJava
|
||||||
case "objc":
|
case "objc":
|
||||||
lang = bind.LangObjC
|
lang = bind.LangObjC
|
||||||
|
utils.Fatalf("Objc binding generation is uncompleted")
|
||||||
default:
|
default:
|
||||||
fmt.Printf("Unsupported destination language \"%s\" (--lang)\n", *langFlag)
|
utils.Fatalf("Unsupported destination language \"%s\" (--lang)", c.GlobalString(langFlag.Name))
|
||||||
os.Exit(-1)
|
|
||||||
}
|
}
|
||||||
// If the entire solidity code was specified, build and bind based on that
|
// If the entire solidity code was specified, build and bind based on that
|
||||||
var (
|
var (
|
||||||
abis []string
|
abis []string
|
||||||
bins []string
|
bins []string
|
||||||
types []string
|
types []string
|
||||||
|
sigs []map[string]string
|
||||||
|
libs = make(map[string]string)
|
||||||
)
|
)
|
||||||
if *solFlag != "" || (*abiFlag == "-" && *pkgFlag == "") {
|
if c.GlobalString(abiFlag.Name) != "" {
|
||||||
|
// Load up the ABI, optional bytecode and type name from the parameters
|
||||||
|
var (
|
||||||
|
abi []byte
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
input := c.GlobalString(abiFlag.Name)
|
||||||
|
if input == "-" {
|
||||||
|
abi, err = ioutil.ReadAll(os.Stdin)
|
||||||
|
} else {
|
||||||
|
abi, err = ioutil.ReadFile(input)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to read input ABI: %v", err)
|
||||||
|
}
|
||||||
|
abis = append(abis, string(abi))
|
||||||
|
|
||||||
|
var bin []byte
|
||||||
|
if binFile := c.GlobalString(binFlag.Name); binFile != "" {
|
||||||
|
if bin, err = ioutil.ReadFile(binFile); err != nil {
|
||||||
|
utils.Fatalf("Failed to read input bytecode: %v", err)
|
||||||
|
}
|
||||||
|
if strings.Contains(string(bin), "//") {
|
||||||
|
utils.Fatalf("Contract has additional library references, please use other mode(e.g. --combined-json) to catch library infos")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bins = append(bins, string(bin))
|
||||||
|
|
||||||
|
kind := c.GlobalString(typeFlag.Name)
|
||||||
|
if kind == "" {
|
||||||
|
kind = c.GlobalString(pkgFlag.Name)
|
||||||
|
}
|
||||||
|
types = append(types, kind)
|
||||||
|
} else {
|
||||||
// Generate the list of types to exclude from binding
|
// Generate the list of types to exclude from binding
|
||||||
exclude := make(map[string]bool)
|
exclude := make(map[string]bool)
|
||||||
for _, kind := range strings.Split(*excFlag, ",") {
|
for _, kind := range strings.Split(c.GlobalString(excFlag.Name), ",") {
|
||||||
exclude[strings.ToLower(kind)] = true
|
exclude[strings.ToLower(kind)] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var contracts map[string]*compiler.Contract
|
|
||||||
var err error
|
var err error
|
||||||
if *solFlag != "" {
|
var contracts map[string]*compiler.Contract
|
||||||
contracts, err = compiler.CompileSolidity(*solcFlag, *solFlag)
|
|
||||||
|
switch {
|
||||||
|
case c.GlobalIsSet(solFlag.Name):
|
||||||
|
contracts, err = compiler.CompileSolidity(c.GlobalString(solcFlag.Name), c.GlobalString(solFlag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to build Solidity contract: %v\n", err)
|
utils.Fatalf("Failed to build Solidity contract: %v", err)
|
||||||
os.Exit(-1)
|
|
||||||
}
|
}
|
||||||
} else {
|
case c.GlobalIsSet(vyFlag.Name):
|
||||||
contracts, err = contractsFromStdin()
|
contracts, err = compiler.CompileVyper(c.GlobalString(vyperFlag.Name), c.GlobalString(vyFlag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to read input ABIs from STDIN: %v\n", err)
|
utils.Fatalf("Failed to build Vyper contract: %v", err)
|
||||||
os.Exit(-1)
|
}
|
||||||
|
case c.GlobalIsSet(jsonFlag.Name):
|
||||||
|
jsonOutput, err := ioutil.ReadFile(c.GlobalString(jsonFlag.Name))
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to read combined-json from compiler: %v", err)
|
||||||
|
}
|
||||||
|
contracts, err = compiler.ParseCombinedJSON(jsonOutput, "", "", "", "")
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to read contract information from json output: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Gather all non-excluded contract for binding
|
// Gather all non-excluded contract for binding
|
||||||
@@ -102,64 +218,41 @@ func main() {
|
|||||||
if exclude[strings.ToLower(name)] {
|
if exclude[strings.ToLower(name)] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
abi, _ := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse
|
abi, err := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to parse ABIs from compiler output: %v", err)
|
||||||
|
}
|
||||||
abis = append(abis, string(abi))
|
abis = append(abis, string(abi))
|
||||||
bins = append(bins, contract.Code)
|
bins = append(bins, contract.Code)
|
||||||
|
sigs = append(sigs, contract.Hashes)
|
||||||
nameParts := strings.Split(name, ":")
|
nameParts := strings.Split(name, ":")
|
||||||
types = append(types, nameParts[len(nameParts)-1])
|
types = append(types, nameParts[len(nameParts)-1])
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Otherwise load up the ABI, optional bytecode and type name from the parameters
|
|
||||||
var abi []byte
|
|
||||||
var err error
|
|
||||||
if *abiFlag == "-" {
|
|
||||||
abi, err = ioutil.ReadAll(os.Stdin)
|
|
||||||
} else {
|
|
||||||
abi, err = ioutil.ReadFile(*abiFlag)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Failed to read input ABI: %v\n", err)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
abis = append(abis, string(abi))
|
|
||||||
|
|
||||||
bin := []byte{}
|
libPattern := crypto.Keccak256Hash([]byte(name)).String()[2:36]
|
||||||
if *binFlag != "" {
|
libs[libPattern] = nameParts[len(nameParts)-1]
|
||||||
if bin, err = ioutil.ReadFile(*binFlag); err != nil {
|
|
||||||
fmt.Printf("Failed to read input bytecode: %v\n", err)
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bins = append(bins, string(bin))
|
|
||||||
|
|
||||||
kind := *typFlag
|
|
||||||
if kind == "" {
|
|
||||||
kind = *pkgFlag
|
|
||||||
}
|
|
||||||
types = append(types, kind)
|
|
||||||
}
|
}
|
||||||
// Generate the contract binding
|
// Generate the contract binding
|
||||||
code, err := bind.Bind(types, abis, bins, *pkgFlag, lang)
|
code, err := bind.Bind(types, abis, bins, sigs, c.GlobalString(pkgFlag.Name), lang, libs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to generate ABI binding: %v\n", err)
|
utils.Fatalf("Failed to generate ABI binding: %v", err)
|
||||||
os.Exit(-1)
|
|
||||||
}
|
}
|
||||||
// Either flush it out to a file or display on the standard output
|
// Either flush it out to a file or display on the standard output
|
||||||
if *outFlag == "" {
|
if !c.GlobalIsSet(outFlag.Name) {
|
||||||
fmt.Printf("%s\n", code)
|
fmt.Printf("%s\n", code)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(*outFlag, []byte(code), 0600); err != nil {
|
if err := ioutil.WriteFile(c.GlobalString(outFlag.Name), []byte(code), 0600); err != nil {
|
||||||
fmt.Printf("Failed to write ABI binding: %v\n", err)
|
utils.Fatalf("Failed to write ABI binding: %v", err)
|
||||||
os.Exit(-1)
|
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func contractsFromStdin() (map[string]*compiler.Contract, error) {
|
func main() {
|
||||||
bytes, err := ioutil.ReadAll(os.Stdin)
|
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return compiler.ParseCombinedJSON(bytes, "", "", "", "")
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ func main() {
|
|||||||
if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil {
|
if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
return
|
if !*writeAddr {
|
||||||
|
return
|
||||||
|
}
|
||||||
case *nodeKeyFile == "" && *nodeKeyHex == "":
|
case *nodeKeyFile == "" && *nodeKeyHex == "":
|
||||||
utils.Fatalf("Use -nodekey or -nodekeyhex to specify a private key")
|
utils.Fatalf("Use -nodekey or -nodekeyhex to specify a private key")
|
||||||
case *nodeKeyFile != "" && *nodeKeyHex != "":
|
case *nodeKeyFile != "" && *nodeKeyHex != "":
|
||||||
@@ -112,12 +114,13 @@ func main() {
|
|||||||
if !realaddr.IP.IsLoopback() {
|
if !realaddr.IP.IsLoopback() {
|
||||||
go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery")
|
go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery")
|
||||||
}
|
}
|
||||||
// TODO: react to external IP changes over time.
|
|
||||||
if ext, err := natm.ExternalIP(); err == nil {
|
if ext, err := natm.ExternalIP(); err == nil {
|
||||||
realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port}
|
realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printNotice(&nodeKey.PublicKey, *realaddr)
|
||||||
|
|
||||||
if *runv5 {
|
if *runv5 {
|
||||||
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
|
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
@@ -136,3 +139,13 @@ func main() {
|
|||||||
|
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func printNotice(nodeKey *ecdsa.PublicKey, addr net.UDPAddr) {
|
||||||
|
if addr.IP.IsUnspecified() {
|
||||||
|
addr.IP = net.IP{127, 0, 0, 1}
|
||||||
|
}
|
||||||
|
n := enode.NewV4(nodeKey, addr.IP, 0, addr.Port)
|
||||||
|
fmt.Println(n.URLv4())
|
||||||
|
fmt.Println("Note: you're using cmd/bootnode, a developer tool.")
|
||||||
|
fmt.Println("We recommend using a regular node as bootstrap node for production deployments.")
|
||||||
|
}
|
||||||
|
|||||||
120
cmd/checkpoint-admin/common.go
Normal file
120
cmd/checkpoint-admin/common.go
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of go-ethereum.
|
||||||
|
//
|
||||||
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// go-ethereum is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/accounts/external"
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/contracts/checkpointoracle"
|
||||||
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// newClient creates a client with specified remote URL.
|
||||||
|
func newClient(ctx *cli.Context) *ethclient.Client {
|
||||||
|
client, err := ethclient.Dial(ctx.GlobalString(nodeURLFlag.Name))
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to connect to Ethereum node: %v", err)
|
||||||
|
}
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
// newRPCClient creates a rpc client with specified node URL.
|
||||||
|
func newRPCClient(url string) *rpc.Client {
|
||||||
|
client, err := rpc.Dial(url)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to connect to Ethereum node: %v", err)
|
||||||
|
}
|
||||||
|
return client
|
||||||
|
}
|
||||||
|
|
||||||
|
// getContractAddr retrieves the register contract address through
|
||||||
|
// rpc request.
|
||||||
|
func getContractAddr(client *rpc.Client) common.Address {
|
||||||
|
var addr string
|
||||||
|
if err := client.Call(&addr, "les_getCheckpointContractAddress"); err != nil {
|
||||||
|
utils.Fatalf("Failed to fetch checkpoint oracle address: %v", err)
|
||||||
|
}
|
||||||
|
return common.HexToAddress(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getCheckpoint retrieves the specified checkpoint or the latest one
|
||||||
|
// through rpc request.
|
||||||
|
func getCheckpoint(ctx *cli.Context, client *rpc.Client) *params.TrustedCheckpoint {
|
||||||
|
var checkpoint *params.TrustedCheckpoint
|
||||||
|
|
||||||
|
if ctx.GlobalIsSet(indexFlag.Name) {
|
||||||
|
var result [3]string
|
||||||
|
index := uint64(ctx.GlobalInt64(indexFlag.Name))
|
||||||
|
if err := client.Call(&result, "les_getCheckpoint", index); err != nil {
|
||||||
|
utils.Fatalf("Failed to get local checkpoint %v, please ensure the les API is exposed", err)
|
||||||
|
}
|
||||||
|
checkpoint = ¶ms.TrustedCheckpoint{
|
||||||
|
SectionIndex: index,
|
||||||
|
SectionHead: common.HexToHash(result[0]),
|
||||||
|
CHTRoot: common.HexToHash(result[1]),
|
||||||
|
BloomRoot: common.HexToHash(result[2]),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var result [4]string
|
||||||
|
err := client.Call(&result, "les_latestCheckpoint")
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to get local checkpoint %v, please ensure the les API is exposed", err)
|
||||||
|
}
|
||||||
|
index, err := strconv.ParseUint(result[0], 0, 64)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to parse checkpoint index %v", err)
|
||||||
|
}
|
||||||
|
checkpoint = ¶ms.TrustedCheckpoint{
|
||||||
|
SectionIndex: index,
|
||||||
|
SectionHead: common.HexToHash(result[1]),
|
||||||
|
CHTRoot: common.HexToHash(result[2]),
|
||||||
|
BloomRoot: common.HexToHash(result[3]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return checkpoint
|
||||||
|
}
|
||||||
|
|
||||||
|
// newContract creates a registrar contract instance with specified
|
||||||
|
// contract address or the default contracts for mainnet or testnet.
|
||||||
|
func newContract(client *rpc.Client) (common.Address, *checkpointoracle.CheckpointOracle) {
|
||||||
|
addr := getContractAddr(client)
|
||||||
|
if addr == (common.Address{}) {
|
||||||
|
utils.Fatalf("No specified registrar contract address")
|
||||||
|
}
|
||||||
|
contract, err := checkpointoracle.NewCheckpointOracle(addr, ethclient.NewClient(client))
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to setup registrar contract %s: %v", addr, err)
|
||||||
|
}
|
||||||
|
return addr, contract
|
||||||
|
}
|
||||||
|
|
||||||
|
// newClefSigner sets up a clef backend and returns a clef transaction signer.
|
||||||
|
func newClefSigner(ctx *cli.Context) *bind.TransactOpts {
|
||||||
|
clef, err := external.NewExternalSigner(ctx.String(clefURLFlag.Name))
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to create clef signer %v", err)
|
||||||
|
}
|
||||||
|
return bind.NewClefTransactor(clef, accounts.Account{Address: common.HexToAddress(ctx.String(signerFlag.Name))})
|
||||||
|
}
|
||||||
311
cmd/checkpoint-admin/exec.go
Normal file
311
cmd/checkpoint-admin/exec.go
Normal file
@@ -0,0 +1,311 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of go-ethereum.
|
||||||
|
//
|
||||||
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// go-ethereum is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
"github.com/ethereum/go-ethereum/contracts/checkpointoracle"
|
||||||
|
"github.com/ethereum/go-ethereum/contracts/checkpointoracle/contract"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var commandDeploy = cli.Command{
|
||||||
|
Name: "deploy",
|
||||||
|
Usage: "Deploy a new checkpoint oracle contract",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
nodeURLFlag,
|
||||||
|
clefURLFlag,
|
||||||
|
signerFlag,
|
||||||
|
signersFlag,
|
||||||
|
thresholdFlag,
|
||||||
|
},
|
||||||
|
Action: utils.MigrateFlags(deploy),
|
||||||
|
}
|
||||||
|
|
||||||
|
var commandSign = cli.Command{
|
||||||
|
Name: "sign",
|
||||||
|
Usage: "Sign the checkpoint with the specified key",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
nodeURLFlag,
|
||||||
|
clefURLFlag,
|
||||||
|
signerFlag,
|
||||||
|
indexFlag,
|
||||||
|
hashFlag,
|
||||||
|
oracleFlag,
|
||||||
|
},
|
||||||
|
Action: utils.MigrateFlags(sign),
|
||||||
|
}
|
||||||
|
|
||||||
|
var commandPublish = cli.Command{
|
||||||
|
Name: "publish",
|
||||||
|
Usage: "Publish a checkpoint into the oracle",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
nodeURLFlag,
|
||||||
|
clefURLFlag,
|
||||||
|
signerFlag,
|
||||||
|
indexFlag,
|
||||||
|
signaturesFlag,
|
||||||
|
},
|
||||||
|
Action: utils.MigrateFlags(publish),
|
||||||
|
}
|
||||||
|
|
||||||
|
// deploy deploys the checkpoint registrar contract.
|
||||||
|
//
|
||||||
|
// Note the network where the contract is deployed depends on
|
||||||
|
// the network where the connected node is located.
|
||||||
|
func deploy(ctx *cli.Context) error {
|
||||||
|
// Gather all the addresses that should be permitted to sign
|
||||||
|
var addrs []common.Address
|
||||||
|
for _, account := range strings.Split(ctx.String(signersFlag.Name), ",") {
|
||||||
|
if trimmed := strings.TrimSpace(account); !common.IsHexAddress(trimmed) {
|
||||||
|
utils.Fatalf("Invalid account in --signers: '%s'", trimmed)
|
||||||
|
}
|
||||||
|
addrs = append(addrs, common.HexToAddress(account))
|
||||||
|
}
|
||||||
|
// Retrieve and validate the signing threshold
|
||||||
|
needed := ctx.Int(thresholdFlag.Name)
|
||||||
|
if needed == 0 || needed > len(addrs) {
|
||||||
|
utils.Fatalf("Invalid signature threshold %d", needed)
|
||||||
|
}
|
||||||
|
// Print a summary to ensure the user understands what they're signing
|
||||||
|
fmt.Printf("Deploying new checkpoint oracle:\n\n")
|
||||||
|
for i, addr := range addrs {
|
||||||
|
fmt.Printf("Admin %d => %s\n", i+1, addr.Hex())
|
||||||
|
}
|
||||||
|
fmt.Printf("\nSignatures needed to publish: %d\n", needed)
|
||||||
|
|
||||||
|
// setup clef signer, create an abigen transactor and an RPC client
|
||||||
|
transactor, client := newClefSigner(ctx), newClient(ctx)
|
||||||
|
|
||||||
|
// Deploy the checkpoint oracle
|
||||||
|
fmt.Println("Sending deploy request to Clef...")
|
||||||
|
oracle, tx, _, err := contract.DeployCheckpointOracle(transactor, client, addrs, big.NewInt(int64(params.CheckpointFrequency)),
|
||||||
|
big.NewInt(int64(params.CheckpointProcessConfirmations)), big.NewInt(int64(needed)))
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to deploy checkpoint oracle %v", err)
|
||||||
|
}
|
||||||
|
log.Info("Deployed checkpoint oracle", "address", oracle, "tx", tx.Hash().Hex())
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// sign creates the signature for specific checkpoint
|
||||||
|
// with local key. Only contract admins have the permission to
|
||||||
|
// sign checkpoint.
|
||||||
|
func sign(ctx *cli.Context) error {
|
||||||
|
var (
|
||||||
|
offline bool // The indicator whether we sign checkpoint by offline.
|
||||||
|
chash common.Hash
|
||||||
|
cindex uint64
|
||||||
|
address common.Address
|
||||||
|
|
||||||
|
node *rpc.Client
|
||||||
|
oracle *checkpointoracle.CheckpointOracle
|
||||||
|
)
|
||||||
|
if !ctx.GlobalIsSet(nodeURLFlag.Name) {
|
||||||
|
// Offline mode signing
|
||||||
|
offline = true
|
||||||
|
if !ctx.IsSet(hashFlag.Name) {
|
||||||
|
utils.Fatalf("Please specify the checkpoint hash (--hash) to sign in offline mode")
|
||||||
|
}
|
||||||
|
chash = common.HexToHash(ctx.String(hashFlag.Name))
|
||||||
|
|
||||||
|
if !ctx.IsSet(indexFlag.Name) {
|
||||||
|
utils.Fatalf("Please specify checkpoint index (--index) to sign in offline mode")
|
||||||
|
}
|
||||||
|
cindex = ctx.Uint64(indexFlag.Name)
|
||||||
|
|
||||||
|
if !ctx.IsSet(oracleFlag.Name) {
|
||||||
|
utils.Fatalf("Please specify oracle address (--oracle) to sign in offline mode")
|
||||||
|
}
|
||||||
|
address = common.HexToAddress(ctx.String(oracleFlag.Name))
|
||||||
|
} else {
|
||||||
|
// Interactive mode signing, retrieve the data from the remote node
|
||||||
|
node = newRPCClient(ctx.GlobalString(nodeURLFlag.Name))
|
||||||
|
|
||||||
|
checkpoint := getCheckpoint(ctx, node)
|
||||||
|
chash, cindex, address = checkpoint.Hash(), checkpoint.SectionIndex, getContractAddr(node)
|
||||||
|
|
||||||
|
// Check the validity of checkpoint
|
||||||
|
reqCtx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
defer cancelFn()
|
||||||
|
|
||||||
|
head, err := ethclient.NewClient(node).HeaderByNumber(reqCtx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
num := head.Number.Uint64()
|
||||||
|
if num < ((cindex+1)*params.CheckpointFrequency + params.CheckpointProcessConfirmations) {
|
||||||
|
utils.Fatalf("Invalid future checkpoint")
|
||||||
|
}
|
||||||
|
_, oracle = newContract(node)
|
||||||
|
latest, _, h, err := oracle.Contract().GetLatestCheckpoint(nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if cindex < latest {
|
||||||
|
utils.Fatalf("Checkpoint is too old")
|
||||||
|
}
|
||||||
|
if cindex == latest && (latest != 0 || h.Uint64() != 0) {
|
||||||
|
utils.Fatalf("Stale checkpoint, latest registered %d, given %d", latest, cindex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
signature string
|
||||||
|
signer string
|
||||||
|
)
|
||||||
|
// isAdmin checks whether the specified signer is admin.
|
||||||
|
isAdmin := func(addr common.Address) error {
|
||||||
|
signers, err := oracle.Contract().GetAllAdmin(nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, s := range signers {
|
||||||
|
if s == addr {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("signer %v is not the admin", addr.Hex())
|
||||||
|
}
|
||||||
|
// Print to the user the data thy are about to sign
|
||||||
|
fmt.Printf("Oracle => %s\n", address.Hex())
|
||||||
|
fmt.Printf("Index %4d => %s\n", cindex, chash.Hex())
|
||||||
|
|
||||||
|
// Sign checkpoint in clef mode.
|
||||||
|
signer = ctx.String(signerFlag.Name)
|
||||||
|
|
||||||
|
if !offline {
|
||||||
|
if err := isAdmin(common.HexToAddress(signer)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clef := newRPCClient(ctx.String(clefURLFlag.Name))
|
||||||
|
p := make(map[string]string)
|
||||||
|
buf := make([]byte, 8)
|
||||||
|
binary.BigEndian.PutUint64(buf, cindex)
|
||||||
|
p["address"] = address.Hex()
|
||||||
|
p["message"] = hexutil.Encode(append(buf, chash.Bytes()...))
|
||||||
|
|
||||||
|
fmt.Println("Sending signing request to Clef...")
|
||||||
|
if err := clef.Call(&signature, "account_signData", accounts.MimetypeDataWithValidator, signer, p); err != nil {
|
||||||
|
utils.Fatalf("Failed to sign checkpoint, err %v", err)
|
||||||
|
}
|
||||||
|
fmt.Printf("Signer => %s\n", signer)
|
||||||
|
fmt.Printf("Signature => %s\n", signature)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// sighash calculates the hash of the data to sign for the checkpoint oracle.
|
||||||
|
func sighash(index uint64, oracle common.Address, hash common.Hash) []byte {
|
||||||
|
buf := make([]byte, 8)
|
||||||
|
binary.BigEndian.PutUint64(buf, index)
|
||||||
|
|
||||||
|
data := append([]byte{0x19, 0x00}, append(oracle[:], append(buf, hash[:]...)...)...)
|
||||||
|
return crypto.Keccak256(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ecrecover calculates the sender address from a sighash and signature combo.
|
||||||
|
func ecrecover(sighash []byte, sig []byte) common.Address {
|
||||||
|
sig[64] -= 27
|
||||||
|
defer func() { sig[64] += 27 }()
|
||||||
|
|
||||||
|
signer, err := crypto.SigToPub(sighash, sig)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Failed to recover sender from signature %x: %v", sig, err)
|
||||||
|
}
|
||||||
|
return crypto.PubkeyToAddress(*signer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// publish registers the specified checkpoint which generated by connected node
|
||||||
|
// with a authorised private key.
|
||||||
|
func publish(ctx *cli.Context) error {
|
||||||
|
// Print the checkpoint oracle's current status to make sure we're interacting
|
||||||
|
// with the correct network and contract.
|
||||||
|
status(ctx)
|
||||||
|
|
||||||
|
// Gather the signatures from the CLI
|
||||||
|
var sigs [][]byte
|
||||||
|
for _, sig := range strings.Split(ctx.String(signaturesFlag.Name), ",") {
|
||||||
|
trimmed := strings.TrimPrefix(strings.TrimSpace(sig), "0x")
|
||||||
|
if len(trimmed) != 130 {
|
||||||
|
utils.Fatalf("Invalid signature in --signature: '%s'", trimmed)
|
||||||
|
} else {
|
||||||
|
sigs = append(sigs, common.Hex2Bytes(trimmed))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Retrieve the checkpoint we want to sign to sort the signatures
|
||||||
|
var (
|
||||||
|
client = newRPCClient(ctx.GlobalString(nodeURLFlag.Name))
|
||||||
|
addr, oracle = newContract(client)
|
||||||
|
checkpoint = getCheckpoint(ctx, client)
|
||||||
|
sighash = sighash(checkpoint.SectionIndex, addr, checkpoint.Hash())
|
||||||
|
)
|
||||||
|
for i := 0; i < len(sigs); i++ {
|
||||||
|
for j := i + 1; j < len(sigs); j++ {
|
||||||
|
signerA := ecrecover(sighash, sigs[i])
|
||||||
|
signerB := ecrecover(sighash, sigs[j])
|
||||||
|
if bytes.Compare(signerA.Bytes(), signerB.Bytes()) > 0 {
|
||||||
|
sigs[i], sigs[j] = sigs[j], sigs[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Retrieve recent header info to protect replay attack
|
||||||
|
reqCtx, cancelFn := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
defer cancelFn()
|
||||||
|
|
||||||
|
head, err := ethclient.NewClient(client).HeaderByNumber(reqCtx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
num := head.Number.Uint64()
|
||||||
|
recent, err := ethclient.NewClient(client).HeaderByNumber(reqCtx, big.NewInt(int64(num-128)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Print a summary of the operation that's going to be performed
|
||||||
|
fmt.Printf("Publishing %d => %s:\n\n", checkpoint.SectionIndex, checkpoint.Hash().Hex())
|
||||||
|
for i, sig := range sigs {
|
||||||
|
fmt.Printf("Signer %d => %s\n", i+1, ecrecover(sighash, sig).Hex())
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Printf("Sentry number => %d\nSentry hash => %s\n", recent.Number, recent.Hash().Hex())
|
||||||
|
|
||||||
|
// Publish the checkpoint into the oracle
|
||||||
|
fmt.Println("Sending publish request to Clef...")
|
||||||
|
tx, err := oracle.RegisterCheckpoint(newClefSigner(ctx), checkpoint.SectionIndex, checkpoint.Hash().Bytes(), recent.Number, recent.Hash(), sigs)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("Register contract failed %v", err)
|
||||||
|
}
|
||||||
|
log.Info("Successfully registered checkpoint", "tx", tx.Hash().Hex())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
117
cmd/checkpoint-admin/main.go
Normal file
117
cmd/checkpoint-admin/main.go
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of go-ethereum.
|
||||||
|
//
|
||||||
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// go-ethereum is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// checkpoint-admin is a utility that can be used to query checkpoint information
|
||||||
|
// and register stable checkpoints into an oracle contract.
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
commandHelperTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...]
|
||||||
|
{{if .Description}}{{.Description}}
|
||||||
|
{{end}}{{if .Subcommands}}
|
||||||
|
SUBCOMMANDS:
|
||||||
|
{{range .Subcommands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
||||||
|
{{end}}{{end}}{{if .Flags}}
|
||||||
|
OPTIONS:
|
||||||
|
{{range $.Flags}}{{"\t"}}{{.}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}`
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Git SHA1 commit hash of the release (set via linker flags)
|
||||||
|
gitCommit = ""
|
||||||
|
gitDate = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
var app *cli.App
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
app = utils.NewApp(gitCommit, gitDate, "ethereum checkpoint helper tool")
|
||||||
|
app.Commands = []cli.Command{
|
||||||
|
commandStatus,
|
||||||
|
commandDeploy,
|
||||||
|
commandSign,
|
||||||
|
commandPublish,
|
||||||
|
}
|
||||||
|
app.Flags = []cli.Flag{
|
||||||
|
oracleFlag,
|
||||||
|
nodeURLFlag,
|
||||||
|
}
|
||||||
|
cli.CommandHelpTemplate = commandHelperTemplate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commonly used command line flags.
|
||||||
|
var (
|
||||||
|
indexFlag = cli.Int64Flag{
|
||||||
|
Name: "index",
|
||||||
|
Usage: "Checkpoint index (query latest from remote node if not specified)",
|
||||||
|
}
|
||||||
|
hashFlag = cli.StringFlag{
|
||||||
|
Name: "hash",
|
||||||
|
Usage: "Checkpoint hash (query latest from remote node if not specified)",
|
||||||
|
}
|
||||||
|
oracleFlag = cli.StringFlag{
|
||||||
|
Name: "oracle",
|
||||||
|
Usage: "Checkpoint oracle address (query from remote node if not specified)",
|
||||||
|
}
|
||||||
|
thresholdFlag = cli.Int64Flag{
|
||||||
|
Name: "threshold",
|
||||||
|
Usage: "Minimal number of signatures required to approve a checkpoint",
|
||||||
|
}
|
||||||
|
nodeURLFlag = cli.StringFlag{
|
||||||
|
Name: "rpc",
|
||||||
|
Value: "http://localhost:8545",
|
||||||
|
Usage: "The rpc endpoint of a local or remote geth node",
|
||||||
|
}
|
||||||
|
clefURLFlag = cli.StringFlag{
|
||||||
|
Name: "clef",
|
||||||
|
Value: "http://localhost:8550",
|
||||||
|
Usage: "The rpc endpoint of clef",
|
||||||
|
}
|
||||||
|
signerFlag = cli.StringFlag{
|
||||||
|
Name: "signer",
|
||||||
|
Usage: "Signer address for clef signing",
|
||||||
|
}
|
||||||
|
signersFlag = cli.StringFlag{
|
||||||
|
Name: "signers",
|
||||||
|
Usage: "Comma separated accounts of trusted checkpoint signers",
|
||||||
|
}
|
||||||
|
signaturesFlag = cli.StringFlag{
|
||||||
|
Name: "signatures",
|
||||||
|
Usage: "Comma separated checkpoint signatures to submit",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
|
||||||
|
fdlimit.Raise(2048)
|
||||||
|
|
||||||
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
61
cmd/checkpoint-admin/status.go
Normal file
61
cmd/checkpoint-admin/status.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2019 The go-ethereum Authors
|
||||||
|
// This file is part of go-ethereum.
|
||||||
|
//
|
||||||
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// go-ethereum is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var commandStatus = cli.Command{
|
||||||
|
Name: "status",
|
||||||
|
Usage: "Fetches the signers and checkpoint status of the oracle contract",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
nodeURLFlag,
|
||||||
|
},
|
||||||
|
Action: utils.MigrateFlags(status),
|
||||||
|
}
|
||||||
|
|
||||||
|
// status fetches the admin list of specified registrar contract.
|
||||||
|
func status(ctx *cli.Context) error {
|
||||||
|
// Create a wrapper around the checkpoint oracle contract
|
||||||
|
addr, oracle := newContract(newRPCClient(ctx.GlobalString(nodeURLFlag.Name)))
|
||||||
|
fmt.Printf("Oracle => %s\n", addr.Hex())
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
// Retrieve the list of authorized signers (admins)
|
||||||
|
admins, err := oracle.Contract().GetAllAdmin(nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for i, admin := range admins {
|
||||||
|
fmt.Printf("Admin %d => %s\n", i+1, admin.Hex())
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
// Retrieve the latest checkpoint
|
||||||
|
index, checkpoint, height, err := oracle.Contract().GetLatestCheckpoint(nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Printf("Checkpoint (published at #%d) %d => %s\n", height, index, common.Hash(checkpoint).Hex())
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,95 +1,87 @@
|
|||||||
Clef
|
# Clef
|
||||||
----
|
|
||||||
Clef can be used to sign transactions and data and is meant as a replacement for geth's account management.
|
|
||||||
This allows DApps not to depend on geth's account management. When a DApp wants to sign data it can send the data to
|
|
||||||
the signer, the signer will then provide the user with context and asks the user for permission to sign the data. If
|
|
||||||
the users grants the signing request the signer will send the signature back to the DApp.
|
|
||||||
|
|
||||||
This setup allows a DApp to connect to a remote Ethereum node and send transactions that are locally signed. This can
|
|
||||||
help in situations when a DApp is connected to a remote node because a local Ethereum node is not available, not
|
|
||||||
synchronised with the chain or a particular Ethereum node that has no built-in (or limited) account management.
|
|
||||||
|
|
||||||
Clef can run as a daemon on the same machine, or off a usb-stick like [usb armory](https://inversepath.com/usbarmory),
|
|
||||||
or a separate VM in a [QubesOS](https://www.qubes-os.org/) type os setup.
|
|
||||||
|
|
||||||
Check out
|
Clef can be used to sign transactions and data and is meant as a(n eventual) replacement for Geth's account management. This allows DApps to not depend on Geth's account management. When a DApp wants to sign data (or a transaction), it can send the content to Clef, which will then provide the user with context and asks for permission to sign the content. If the users grants the signing request, Clef will send the signature back to the DApp.
|
||||||
|
|
||||||
* the [tutorial](tutorial.md) for some concrete examples on how the signer works.
|
This setup allows a DApp to connect to a remote Ethereum node and send transactions that are locally signed. This can help in situations when a DApp is connected to an untrusted remote Ethereum node, because a local one is not available, not synchronised with the chain, or is a node that has no built-in (or limited) account management.
|
||||||
* the [setup docs](docs/setup.md) for some information on how to configure it to work on QubesOS or USBArmory.
|
|
||||||
|
|
||||||
|
Clef can run as a daemon on the same machine, off a usb-stick like [USB armory](https://inversepath.com/usbarmory), or even a separate VM in a [QubesOS](https://www.qubes-os.org/) type setup.
|
||||||
|
|
||||||
|
Check out the
|
||||||
|
|
||||||
|
* [CLI tutorial](tutorial.md) for some concrete examples on how Clef works.
|
||||||
|
* [Setup docs](docs/setup.md) for infos on how to configure Clef on QubesOS or USB Armory.
|
||||||
|
* [Data types](datatypes.md) for details on the communication messages between Clef and an external UI.
|
||||||
|
|
||||||
## Command line flags
|
## Command line flags
|
||||||
|
|
||||||
Clef accepts the following command line options:
|
Clef accepts the following command line options:
|
||||||
|
|
||||||
```
|
```
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
init Initialize the signer, generate secret storage
|
init Initialize the signer, generate secret storage
|
||||||
attest Attest that a js-file is to be used
|
attest Attest that a js-file is to be used
|
||||||
addpw Store a credential for a keystore file
|
setpw Store a credential for a keystore file
|
||||||
|
delpw Remove a credential for a keystore file
|
||||||
|
gendoc Generate documentation about json-rpc format
|
||||||
help Shows a list of commands or help for one command
|
help Shows a list of commands or help for one command
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
--loglevel value log level to emit to the screen (default: 4)
|
--loglevel value log level to emit to the screen (default: 4)
|
||||||
--keystore value Directory for the keystore (default: "$HOME/.ethereum/keystore")
|
--keystore value Directory for the keystore (default: "$HOME/.ethereum/keystore")
|
||||||
--configdir value Directory for clef configuration (default: "$HOME/.clef")
|
--configdir value Directory for Clef configuration (default: "$HOME/.clef")
|
||||||
--networkid value Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: 1)
|
--chainid value Chain id to use for signing (1=mainnet, 3=Ropsten, 4=Rinkeby, 5=Goerli) (default: 1)
|
||||||
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
|
--lightkdf Reduce key-derivation RAM & CPU usage at some expense of KDF strength
|
||||||
--nousb Disables monitoring for and managing USB hardware wallets
|
--nousb Disables monitoring for and managing USB hardware wallets
|
||||||
|
--pcscdpath value Path to the smartcard daemon (pcscd) socket file (default: "/run/pcscd/pcscd.comm")
|
||||||
--rpcaddr value HTTP-RPC server listening interface (default: "localhost")
|
--rpcaddr value HTTP-RPC server listening interface (default: "localhost")
|
||||||
|
--rpcvhosts value Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
|
||||||
|
--ipcdisable Disable the IPC-RPC server
|
||||||
|
--ipcpath Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
||||||
|
--rpc Enable the HTTP-RPC server
|
||||||
--rpcport value HTTP-RPC server listening port (default: 8550)
|
--rpcport value HTTP-RPC server listening port (default: 8550)
|
||||||
--signersecret value A file containing the password used to encrypt signer credentials, e.g. keystore credentials and ruleset hash
|
--signersecret value A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash
|
||||||
--4bytedb value File containing 4byte-identifiers (default: "./4byte.json")
|
|
||||||
--4bytedb-custom value File used for writing new 4byte-identifiers submitted via API (default: "./4byte-custom.json")
|
--4bytedb-custom value File used for writing new 4byte-identifiers submitted via API (default: "./4byte-custom.json")
|
||||||
--auditlog value File used to emit audit logs. Set to "" to disable (default: "audit.log")
|
--auditlog value File used to emit audit logs. Set to "" to disable (default: "audit.log")
|
||||||
--rules value Enable rule-engine (default: "rules.json")
|
--rules value Path to the rule file to auto-authorize requests with
|
||||||
--stdio-ui Use STDIN/STDOUT as a channel for an external UI. This means that an STDIN/STDOUT is used for RPC-communication with a e.g. a graphical user interface, and can be used when the signer is started by an external process.
|
--stdio-ui Use STDIN/STDOUT as a channel for an external UI. This means that an STDIN/STDOUT is used for RPC-communication with a e.g. a graphical user interface, and can be used when Clef is started by an external process.
|
||||||
--stdio-ui-test Mechanism to test interface between signer and UI. Requires 'stdio-ui'.
|
--stdio-ui-test Mechanism to test interface between Clef and UI. Requires 'stdio-ui'.
|
||||||
|
--advanced If enabled, issues warnings instead of rejections for suspicious requests. Default off
|
||||||
--help, -h show help
|
--help, -h show help
|
||||||
--version, -v print the version
|
--version, -v print the version
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```
|
|
||||||
signer -keystore /my/keystore -chainid 4
|
|
||||||
```
|
|
||||||
|
|
||||||
|
```
|
||||||
|
$ clef -keystore /my/keystore -chainid 4
|
||||||
|
```
|
||||||
|
|
||||||
## Security model
|
## Security model
|
||||||
|
|
||||||
The security model of the signer is as follows:
|
The security model of Clef is as follows:
|
||||||
|
|
||||||
* One critical component (the signer binary / daemon) is responsible for handling cryptographic operations: signing, private keys, encryption/decryption of keystore files.
|
* One critical component (the Clef binary / daemon) is responsible for handling cryptographic operations: signing, private keys, encryption/decryption of keystore files.
|
||||||
* The signer binary has a well-defined 'external' API.
|
* Clef has a well-defined 'external' API.
|
||||||
* The 'external' API is considered UNTRUSTED.
|
* The 'external' API is considered UNTRUSTED.
|
||||||
* The signer binary also communicates with whatever process that invoked the binary, via stdin/stdout.
|
* Clef also communicates with whatever process that invoked the binary, via stdin/stdout.
|
||||||
* This channel is considered 'trusted'. Over this channel, approvals and passwords are communicated.
|
* This channel is considered 'trusted'. Over this channel, approvals and passwords are communicated.
|
||||||
|
|
||||||
The general flow for signing a transaction using e.g. geth is as follows:
|
The general flow for signing a transaction using e.g. Geth is as follows:
|
||||||

|

|
||||||
|
|
||||||
In this case, `geth` would be started with `--externalsigner=http://localhost:8550` and would relay requests to `eth.sendTransaction`.
|
In this case, `geth` would be started with `--signer http://localhost:8550` and would relay requests to `eth.sendTransaction`.
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
Some snags and todos
|
Some snags and todos
|
||||||
|
|
||||||
* [ ] The signer should take a startup param "--no-change", for UIs that do not contain the capability
|
* [ ] Clef should take a startup param "--no-change", for UIs that do not contain the capability to perform changes to things, only approve/deny. Such a UI should be able to start the signer in a more secure mode by telling it that it only wants approve/deny capabilities.
|
||||||
to perform changes to things, only approve/deny. Such a UI should be able to start the signer in
|
* [x] It would be nice if Clef could collect new 4byte-id:s/method selectors, and have a secondary database for those (`4byte_custom.json`). Users could then (optionally) submit their collections for inclusion upstream.
|
||||||
a more secure mode by telling it that it only wants approve/deny capabilities.
|
* [ ] It should be possible to configure Clef to check if an account is indeed known to it, before passing on to the UI. The reason it currently does not, is that it would make it possible to enumerate accounts if it immediately returned "unknown account" (side channel attack).
|
||||||
|
* [x] It should be possible to configure Clef to auto-allow listing (certain) accounts, instead of asking every time.
|
||||||
* [x] It would be nice if the signer could collect new 4byte-id:s/method selectors, and have a
|
* [x] Done Upon startup, Clef should spit out some info to the caller (particularly important when executed in `stdio-ui`-mode), invoking methods with the following info:
|
||||||
secondary database for those (`4byte_custom.json`). Users could then (optionally) submit their collections for
|
|
||||||
inclusion upstream.
|
|
||||||
|
|
||||||
* It should be possible to configure the signer to check if an account is indeed known to it, before
|
|
||||||
passing on to the UI. The reason it currently does not, is that it would make it possible to enumerate
|
|
||||||
accounts if it immediately returned "unknown account".
|
|
||||||
* [x] It should be possible to configure the signer to auto-allow listing (certain) accounts, instead of asking every time.
|
|
||||||
* [x] Done Upon startup, the signer should spit out some info to the caller (particularly important when executed in `stdio-ui`-mode),
|
|
||||||
invoking methods with the following info:
|
|
||||||
* [x] Version info about the signer
|
* [x] Version info about the signer
|
||||||
* [x] Address of API (http/ipc)
|
* [x] Address of API (HTTP/IPC)
|
||||||
* [ ] List of known accounts
|
* [ ] List of known accounts
|
||||||
* [ ] Have a default timeout on signing operations, so that if the user has not answered within e.g. 60 seconds, the request is rejected.
|
* [ ] Have a default timeout on signing operations, so that if the user has not answered within e.g. 60 seconds, the request is rejected.
|
||||||
* [ ] `account_signRawTransaction`
|
* [ ] `account_signRawTransaction`
|
||||||
@@ -102,21 +94,16 @@ invoking methods with the following info:
|
|||||||
* the number of unique recipients
|
* the number of unique recipients
|
||||||
|
|
||||||
* Geth todos
|
* Geth todos
|
||||||
- The signer should pass the `Origin` header as call-info to the UI. As of right now, the way that info about the request is
|
- The signer should pass the `Origin` header as call-info to the UI. As of right now, the way that info about the request is put together is a bit of a hack into the HTTP server. This could probably be greatly improved.
|
||||||
put together is a bit of a hack into the http server. This could probably be greatly improved
|
- Relay: Geth should be started in `geth --signer localhost:8550`.
|
||||||
- Relay: Geth should be started in `geth --external_signer localhost:8550`.
|
- Currently, the Geth APIs use `common.Address` in the arguments to transaction submission (e.g `to` field). This type is 20 `bytes`, and is incapable of carrying checksum information. The signer uses `common.MixedcaseAddress`, which retains the original input.
|
||||||
- Currently, the Geth APIs use `common.Address` in the arguments to transaction submission (e.g `to` field). This
|
- The Geth API should switch to use the same type, and relay `to`-account verbatim to the external API.
|
||||||
type is 20 `bytes`, and is incapable of carrying checksum information. The signer uses `common.MixedcaseAddress`, which
|
|
||||||
retains the original input.
|
|
||||||
- The Geth api should switch to use the same type, and relay `to`-account verbatim to the external api.
|
|
||||||
|
|
||||||
* [x] Storage
|
* [x] Storage
|
||||||
* [x] An encrypted key-value storage should be implemented
|
* [x] An encrypted key-value storage should be implemented.
|
||||||
* See [rules.md](rules.md) for more info about this.
|
* See [rules.md](rules.md) for more info about this.
|
||||||
|
|
||||||
* Another potential thing to introduce is pairing.
|
* Another potential thing to introduce is pairing.
|
||||||
* To prevent spurious requests which users just accept, implement a way to "pair" the caller with the signer (external API).
|
* To prevent spurious requests which users just accept, implement a way to "pair" the caller with the signer (external API).
|
||||||
* Thus geth/mist/cpp would cryptographically handshake and afterwards the caller would be allowed to make signing requests.
|
* Thus Geth/cpp would cryptographically handshake and afterwards the caller would be allowed to make signing requests.
|
||||||
* This feature would make the addition of rules less dangerous.
|
* This feature would make the addition of rules less dangerous.
|
||||||
|
|
||||||
* Wallets / accounts. Add API methods for wallets.
|
* Wallets / accounts. Add API methods for wallets.
|
||||||
@@ -125,37 +112,31 @@ put together is a bit of a hack into the http server. This could probably be gre
|
|||||||
|
|
||||||
### External API
|
### External API
|
||||||
|
|
||||||
The signer listens to HTTP requests on `rpcaddr`:`rpcport`, with the same JSONRPC standard as Geth. The messages are
|
Clef listens to HTTP requests on `rpcaddr`:`rpcport` (or to IPC on `ipcpath`), with the same JSON-RPC standard as Geth. The messages are expected to be [JSON-RPC 2.0 standard](https://www.jsonrpc.org/specification).
|
||||||
expected to be JSON [jsonrpc 2.0 standard](http://www.jsonrpc.org/specification).
|
|
||||||
|
|
||||||
Some of these call can require user interaction. Clients must be aware that responses
|
Some of these call can require user interaction. Clients must be aware that responses may be delayed significantly or may never be received if a users decides to ignore the confirmation request.
|
||||||
may be delayed significantly or may never be received if a users decides to ignore the confirmation request.
|
|
||||||
|
|
||||||
The External API is **untrusted** : it does not accept credentials over this api, nor does it expect
|
The External API is **untrusted**: it does not accept credentials over this API, nor does it expect that requests have any authority.
|
||||||
that requests have any authority.
|
|
||||||
|
|
||||||
### UI API
|
### Internal UI API
|
||||||
|
|
||||||
The signer has one native console-based UI, for operation without any standalone tools.
|
Clef has one native console-based UI, for operation without any standalone tools. However, there is also an API to communicate with an external UI. To enable that UI, the signer needs to be executed with the `--stdio-ui` option, which allocates `stdin` / `stdout` for the UI API.
|
||||||
However, there is also an API to communicate with an external UI. To enable that UI,
|
|
||||||
the signer needs to be executed with the `--stdio-ui` option, which allocates the
|
|
||||||
`stdin`/`stdout` for the UI-api.
|
|
||||||
|
|
||||||
An example (insecure) proof-of-concept of has been implemented in `pythonsigner.py`.
|
An example (insecure) proof-of-concept of has been implemented in `pythonsigner.py`.
|
||||||
|
|
||||||
The model is as follows:
|
The model is as follows:
|
||||||
|
|
||||||
* The user starts the UI app (`pythonsigner.py`).
|
* The user starts the UI app (`pythonsigner.py`).
|
||||||
* The UI app starts the `signer` with `--stdio-ui`, and listens to the
|
* The UI app starts `clef` with `--stdio-ui`, and listens to the
|
||||||
process output for confirmation-requests.
|
process output for confirmation-requests.
|
||||||
* The `signer` opens the external http api.
|
* `clef` opens the external HTTP API.
|
||||||
* When the `signer` receives requests, it sends a `jsonrpc` request via `stdout`.
|
* When the `signer` receives requests, it sends a JSON-RPC request via `stdout`.
|
||||||
* The UI app prompts the user accordingly, and responds to the `signer`
|
* The UI app prompts the user accordingly, and responds to `clef`.
|
||||||
* The `signer` signs (or not), and responds to the original request.
|
* `clef` signs (or not), and responds to the original request.
|
||||||
|
|
||||||
## External API
|
## External API
|
||||||
|
|
||||||
See the [external api changelog](extapi_changelog.md) for information about changes to this API.
|
See the [external API changelog](extapi_changelog.md) for information about changes to this API.
|
||||||
|
|
||||||
### Encoding
|
### Encoding
|
||||||
- number: positive integers that are hex encoded
|
- number: positive integers that are hex encoded
|
||||||
@@ -180,7 +161,7 @@ None
|
|||||||
#### Result
|
#### Result
|
||||||
- address [string]: account address that is derived from the generated key
|
- address [string]: account address that is derived from the generated key
|
||||||
- url [string]: location of the keyfile
|
- url [string]: location of the keyfile
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -189,7 +170,9 @@ None
|
|||||||
"method": "account_new",
|
"method": "account_new",
|
||||||
"params": []
|
"params": []
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
Response
|
||||||
|
```
|
||||||
{
|
{
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
@@ -212,9 +195,9 @@ None
|
|||||||
#### Result
|
#### Result
|
||||||
- array with account records:
|
- array with account records:
|
||||||
- account.address [string]: account address that is derived from the generated key
|
- account.address [string]: account address that is derived from the generated key
|
||||||
- account.type [string]: type of the
|
- account.type [string]: type of the
|
||||||
- account.url [string]: location of the account
|
- account.url [string]: location of the account
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -222,7 +205,9 @@ None
|
|||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "account_list"
|
"method": "account_list"
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
Response
|
||||||
|
```
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
@@ -261,7 +246,7 @@ None
|
|||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
- signed transaction in RLP encoded form [data]
|
- signed transaction in RLP encoded form [data]
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -285,8 +270,8 @@ Response
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"id": 2,
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 67,
|
|
||||||
"error": {
|
"error": {
|
||||||
"code": -32000,
|
"code": -32000,
|
||||||
"message": "Request denied"
|
"message": "Request denied"
|
||||||
@@ -298,6 +283,7 @@ Response
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"id": 67,
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "account_signTransaction",
|
"method": "account_signTransaction",
|
||||||
"params": [
|
"params": [
|
||||||
@@ -311,8 +297,7 @@ Response
|
|||||||
"data": "0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
"data": "0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"
|
||||||
},
|
},
|
||||||
"safeSend(address)"
|
"safeSend(address)"
|
||||||
],
|
]
|
||||||
"id": 67
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Response
|
Response
|
||||||
@@ -346,26 +331,30 @@ Bash example:
|
|||||||
{"jsonrpc":"2.0","id":67,"result":{"raw":"0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663","tx":{"nonce":"0x0","gasPrice":"0x1","gas":"0x333","to":"0x07a565b7ed7d7a678680a4c162885bedbb695fe0","value":"0x0","input":"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012","v":"0x26","r":"0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e","s":"0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663","hash":"0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e"}}}
|
{"jsonrpc":"2.0","id":67,"result":{"raw":"0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663","tx":{"nonce":"0x0","gasPrice":"0x1","gas":"0x333","to":"0x07a565b7ed7d7a678680a4c162885bedbb695fe0","value":"0x0","input":"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012","v":"0x26","r":"0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e","s":"0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663","hash":"0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e"}}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### account_signData
|
||||||
### account_sign
|
|
||||||
|
|
||||||
#### Sign data
|
#### Sign data
|
||||||
Signs a chunk of data and returns the calculated signature.
|
Signs a chunk of data and returns the calculated signature.
|
||||||
|
|
||||||
#### Arguments
|
#### Arguments
|
||||||
|
- content type [string]: type of signed data
|
||||||
|
- `text/validator`: hex data with custom validator defined in a contract
|
||||||
|
- `application/clique`: [clique](https://github.com/ethereum/EIPs/issues/225) headers
|
||||||
|
- `text/plain`: simple hex data validated by `account_ecRecover`
|
||||||
- account [address]: account to sign with
|
- account [address]: account to sign with
|
||||||
- data [data]: data to sign
|
- data [object]: data to sign
|
||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
- calculated signature [data]
|
- calculated signature [data]
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "account_sign",
|
"method": "account_signData",
|
||||||
"params": [
|
"params": [
|
||||||
|
"data/plain",
|
||||||
"0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
|
"0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
|
||||||
"0xaabbccdd"
|
"0xaabbccdd"
|
||||||
]
|
]
|
||||||
@@ -381,18 +370,116 @@ Response
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### account_signTypedData
|
||||||
|
|
||||||
|
#### Sign data
|
||||||
|
Signs a chunk of structured data conformant to [EIP712]([EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md)) and returns the calculated signature.
|
||||||
|
|
||||||
|
#### Arguments
|
||||||
|
- account [address]: account to sign with
|
||||||
|
- data [object]: data to sign
|
||||||
|
|
||||||
|
#### Result
|
||||||
|
- calculated signature [data]
|
||||||
|
|
||||||
|
#### Sample call
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 68,
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "account_signTypedData",
|
||||||
|
"params": [
|
||||||
|
"0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826",
|
||||||
|
{
|
||||||
|
"types": {
|
||||||
|
"EIP712Domain": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "version",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "chainId",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "verifyingContract",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Person": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wallet",
|
||||||
|
"type": "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Mail": [
|
||||||
|
{
|
||||||
|
"name": "from",
|
||||||
|
"type": "Person"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "to",
|
||||||
|
"type": "Person"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contents",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"primaryType": "Mail",
|
||||||
|
"domain": {
|
||||||
|
"name": "Ether Mail",
|
||||||
|
"version": "1",
|
||||||
|
"chainId": 1,
|
||||||
|
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"from": {
|
||||||
|
"name": "Cow",
|
||||||
|
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
|
||||||
|
},
|
||||||
|
"to": {
|
||||||
|
"name": "Bob",
|
||||||
|
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
|
||||||
|
},
|
||||||
|
"contents": "Hello, Bob!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Response
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"result": "0x4355c47d63924e8a72e509b65029052eb6c299d53a04e167c5775fd466751c9d07299936d304c153f6443dfa05f40ff007d72911b6f72307f996231605b915621c"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### account_ecRecover
|
### account_ecRecover
|
||||||
|
|
||||||
#### Recover address
|
#### Sign data
|
||||||
Derive the address from the account that was used to sign data from the data and signature.
|
|
||||||
|
Derive the address from the account that was used to sign data with content type `text/plain` and the signature.
|
||||||
|
|
||||||
#### Arguments
|
#### Arguments
|
||||||
- data [data]: data that was signed
|
- data [data]: data that was signed
|
||||||
- signature [data]: the signature to verify
|
- signature [data]: the signature to verify
|
||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
- derived account [address]
|
- derived account [address]
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -400,6 +487,7 @@ Response
|
|||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "account_ecRecover",
|
"method": "account_ecRecover",
|
||||||
"params": [
|
"params": [
|
||||||
|
"data/plain",
|
||||||
"0xaabbccdd",
|
"0xaabbccdd",
|
||||||
"0x5b6693f153b48ec1c706ba4169960386dbaa6903e249cc79a8e6ddc434451d417e1e57327872c7f538beeb323c300afa9999a3d4a5de6caf3be0d5ef832b67ef1c"
|
"0x5b6693f153b48ec1c706ba4169960386dbaa6903e249cc79a8e6ddc434451d417e1e57327872c7f538beeb323c300afa9999a3d4a5de6caf3be0d5ef832b67ef1c"
|
||||||
]
|
]
|
||||||
@@ -413,7 +501,6 @@ Response
|
|||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"result": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db"
|
"result": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db"
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### account_import
|
### account_import
|
||||||
@@ -421,16 +508,16 @@ Response
|
|||||||
#### Import account
|
#### Import account
|
||||||
Import a private key into the keystore. The imported key is expected to be encrypted according to the web3 keystore
|
Import a private key into the keystore. The imported key is expected to be encrypted according to the web3 keystore
|
||||||
format.
|
format.
|
||||||
|
|
||||||
#### Arguments
|
#### Arguments
|
||||||
- account [object]: key in [web3 keystore format](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) (retrieved with account_export)
|
- account [object]: key in [web3 keystore format](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) (retrieved with account_export)
|
||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
- imported key [object]:
|
- imported key [object]:
|
||||||
- key.address [address]: address of the imported key
|
- key.address [address]: address of the imported key
|
||||||
- key.type [string]: type of the account
|
- key.type [string]: type of the account
|
||||||
- key.url [string]: key URL
|
- key.url [string]: key URL
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -458,7 +545,7 @@ Response
|
|||||||
},
|
},
|
||||||
"id": "09bccb61-b8d3-4e93-bf4f-205a8194f0b9",
|
"id": "09bccb61-b8d3-4e93-bf4f-205a8194f0b9",
|
||||||
"version": 3
|
"version": 3
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -479,16 +566,16 @@ Response
|
|||||||
### account_export
|
### account_export
|
||||||
|
|
||||||
#### Export account from keystore
|
#### Export account from keystore
|
||||||
Export a private key from the keystore. The exported private key is encrypted with the original passphrase. When the
|
Export a private key from the keystore. The exported private key is encrypted with the original password. When the
|
||||||
key is imported later this passphrase is required.
|
key is imported later this password is required.
|
||||||
|
|
||||||
#### Arguments
|
#### Arguments
|
||||||
- account [address]: export private key that is associated with this account
|
- account [address]: export private key that is associated with this account
|
||||||
|
|
||||||
#### Result
|
#### Result
|
||||||
- exported key, see [web3 keystore format](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for
|
- exported key, see [web3 keystore format](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for
|
||||||
more information
|
more information
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -530,8 +617,6 @@ Response
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## UI API
|
## UI API
|
||||||
|
|
||||||
These methods needs to be implemented by a UI listener.
|
These methods needs to be implemented by a UI listener.
|
||||||
@@ -542,13 +627,13 @@ See `pythonsigner`, which can be invoked via `python3 pythonsigner.py test` to p
|
|||||||
|
|
||||||
All methods in this API uses object-based parameters, so that there can be no mixups of parameters: each piece of data is accessed by key.
|
All methods in this API uses object-based parameters, so that there can be no mixups of parameters: each piece of data is accessed by key.
|
||||||
|
|
||||||
See the [ui api changelog](intapi_changelog.md) for information about changes to this API.
|
See the [ui API changelog](intapi_changelog.md) for information about changes to this API.
|
||||||
|
|
||||||
OBS! A slight deviation from `json` standard is in place: every request and response should be confined to a single line.
|
OBS! A slight deviation from `json` standard is in place: every request and response should be confined to a single line.
|
||||||
Whereas the `json` specification allows for linebreaks, linebreaks __should not__ be used in this communication channel, to make
|
Whereas the `json` specification allows for linebreaks, linebreaks __should not__ be used in this communication channel, to make
|
||||||
things simpler for both parties.
|
things simpler for both parties.
|
||||||
|
|
||||||
### ApproveTx
|
### ApproveTx / `ui_approveTx`
|
||||||
|
|
||||||
Invoked when there's a transaction for approval.
|
Invoked when there's a transaction for approval.
|
||||||
|
|
||||||
@@ -560,13 +645,13 @@ Here's a method invocation:
|
|||||||
|
|
||||||
curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"account_signTransaction","params":[{"from":"0x694267f14675d7e1b9494fd8d72fefe1755710fa","gas":"0x333","gasPrice":"0x1","nonce":"0x0","to":"0x07a565b7ed7d7a678680a4c162885bedbb695fe0", "value":"0x0", "data":"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"},"safeSend(address)"],"id":67}' http://localhost:8550/
|
curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"account_signTransaction","params":[{"from":"0x694267f14675d7e1b9494fd8d72fefe1755710fa","gas":"0x333","gasPrice":"0x1","nonce":"0x0","to":"0x07a565b7ed7d7a678680a4c162885bedbb695fe0", "value":"0x0", "data":"0x4401a6e40000000000000000000000000000000000000000000000000000000000000012"},"safeSend(address)"],"id":67}' http://localhost:8550/
|
||||||
```
|
```
|
||||||
|
Results in the following invocation on the UI:
|
||||||
```json
|
```json
|
||||||
|
|
||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"method": "ApproveTx",
|
"method": "ui_approveTx",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"transaction": {
|
"transaction": {
|
||||||
@@ -611,7 +696,7 @@ curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","me
|
|||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"method": "ApproveTx",
|
"method": "ui_approveTx",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"transaction": {
|
"transaction": {
|
||||||
@@ -654,7 +739,7 @@ One which has missing `to`, but with no `data`:
|
|||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"method": "ApproveTx",
|
"method": "ui_approveTx",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"transaction": {
|
"transaction": {
|
||||||
@@ -683,33 +768,7 @@ One which has missing `to`, but with no `data`:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### ApproveExport
|
### ApproveListing / `ui_approveListing`
|
||||||
|
|
||||||
Invoked when a request to export an account has been made.
|
|
||||||
|
|
||||||
#### Sample call
|
|
||||||
|
|
||||||
```json
|
|
||||||
|
|
||||||
{
|
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": 7,
|
|
||||||
"method": "ApproveExport",
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"address": "0x0000000000000000000000000000000000000000",
|
|
||||||
"meta": {
|
|
||||||
"remote": "signer binary",
|
|
||||||
"local": "main",
|
|
||||||
"scheme": "in-proc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### ApproveListing
|
|
||||||
|
|
||||||
Invoked when a request for account listing has been made.
|
Invoked when a request for account listing has been made.
|
||||||
|
|
||||||
@@ -720,7 +779,7 @@ Invoked when a request for account listing has been made.
|
|||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 5,
|
"id": 5,
|
||||||
"method": "ApproveListing",
|
"method": "ui_approveListing",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"accounts": [
|
"accounts": [
|
||||||
@@ -747,7 +806,7 @@ Invoked when a request for account listing has been made.
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### ApproveSignData
|
### ApproveSignData / `ui_approveSignData`
|
||||||
|
|
||||||
#### Sample call
|
#### Sample call
|
||||||
|
|
||||||
@@ -755,7 +814,7 @@ Invoked when a request for account listing has been made.
|
|||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"method": "ApproveSignData",
|
"method": "ui_approveSignData",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"address": "0x123409812340981234098123409812deadbeef42",
|
"address": "0x123409812340981234098123409812deadbeef42",
|
||||||
@@ -773,7 +832,7 @@ Invoked when a request for account listing has been made.
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### ShowInfo
|
### ShowInfo / `ui_showInfo`
|
||||||
|
|
||||||
The UI should show the info to the user. Does not expect response.
|
The UI should show the info to the user. Does not expect response.
|
||||||
|
|
||||||
@@ -783,7 +842,7 @@ The UI should show the info to the user. Does not expect response.
|
|||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 9,
|
"id": 9,
|
||||||
"method": "ShowInfo",
|
"method": "ui_showInfo",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"text": "Tests completed"
|
"text": "Tests completed"
|
||||||
@@ -793,7 +852,7 @@ The UI should show the info to the user. Does not expect response.
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### ShowError
|
### ShowError / `ui_showError`
|
||||||
|
|
||||||
The UI should show the info to the user. Does not expect response.
|
The UI should show the info to the user. Does not expect response.
|
||||||
|
|
||||||
@@ -812,7 +871,7 @@ The UI should show the info to the user. Does not expect response.
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### OnApproved
|
### OnApprovedTx / `ui_onApprovedTx`
|
||||||
|
|
||||||
`OnApprovedTx` is called when a transaction has been approved and signed. The call contains the return value that will be sent to the external caller. The return value from this method is ignored - the reason for having this callback is to allow the ruleset to keep track of approved transactions.
|
`OnApprovedTx` is called when a transaction has been approved and signed. The call contains the return value that will be sent to the external caller. The return value from this method is ignored - the reason for having this callback is to allow the ruleset to keep track of approved transactions.
|
||||||
|
|
||||||
@@ -820,9 +879,9 @@ When implementing rate-limited rules, this callback should be used.
|
|||||||
|
|
||||||
TLDR; Use this method to keep track of signed transactions, instead of using the data in `ApproveTx`.
|
TLDR; Use this method to keep track of signed transactions, instead of using the data in `ApproveTx`.
|
||||||
|
|
||||||
### OnSignerStartup
|
### OnSignerStartup / `ui_onSignerStartup`
|
||||||
|
|
||||||
This method provide the UI with information about what API version the signer uses (both internal and external) aswell as build-info and external api,
|
This method provide the UI with information about what API version the signer uses (both internal and external) aswell as build-info and external API,
|
||||||
in k/v-form.
|
in k/v-form.
|
||||||
|
|
||||||
Example call:
|
Example call:
|
||||||
@@ -831,7 +890,7 @@ Example call:
|
|||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"method": "OnSignerStartup",
|
"method": "ui_onSignerStartup",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"info": {
|
"info": {
|
||||||
@@ -855,7 +914,7 @@ A UI should conform to the following rules.
|
|||||||
* For example, not load icons, stylesheets from the internet
|
* For example, not load icons, stylesheets from the internet
|
||||||
* Not load files from the filesystem, unless they reside in the same local directory (e.g. config files)
|
* Not load files from the filesystem, unless they reside in the same local directory (e.g. config files)
|
||||||
* A Graphical UI MUST show the blocky-identicon for ethereum addresses.
|
* A Graphical UI MUST show the blocky-identicon for ethereum addresses.
|
||||||
* A UI MUST warn display approproate warning if the destination-account is formatted with invalid checksum.
|
* A UI MUST warn display appropriate warning if the destination-account is formatted with invalid checksum.
|
||||||
* A UI MUST NOT open any ports or services
|
* A UI MUST NOT open any ports or services
|
||||||
* The signer opens the public port
|
* The signer opens the public port
|
||||||
* A UI SHOULD verify the permissions on the signer binary, and refuse to execute or warn if permissions allow non-user write.
|
* A UI SHOULD verify the permissions on the signer binary, and refuse to execute or warn if permissions allow non-user write.
|
||||||
@@ -866,9 +925,9 @@ A UI should conform to the following rules.
|
|||||||
along with the UI.
|
along with the UI.
|
||||||
|
|
||||||
|
|
||||||
### UI Implementations
|
### UI Implementations
|
||||||
|
|
||||||
There are a couple of implementation for a UI. We'll try to keep this list up to date.
|
There are a couple of implementation for a UI. We'll try to keep this list up to date.
|
||||||
|
|
||||||
| Name | Repo | UI type| No external resources| Blocky support| Verifies permissions | Hash information | No secondary storage | Statically linked| Can modify parameters|
|
| Name | Repo | UI type| No external resources| Blocky support| Verifies permissions | Hash information | No secondary storage | Statically linked| Can modify parameters|
|
||||||
| ---- | ---- | -------| ---- | ---- | ---- |---- | ---- | ---- | ---- |
|
| ---- | ---- | -------| ---- | ---- | ---- |---- | ---- | ---- | ---- |
|
||||||
|
|||||||
224
cmd/clef/datatypes.md
Normal file
224
cmd/clef/datatypes.md
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
## UI Client interface
|
||||||
|
|
||||||
|
These data types are defined in the channel between clef and the UI
|
||||||
|
### SignDataRequest
|
||||||
|
|
||||||
|
SignDataRequest contains information about a pending request to sign some data. The data to be signed can be of various types, defined by content-type. Clef has done most of the work in canonicalizing and making sense of the data, and it's up to the UI to presentthe user with the contents of the `message`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"content_type": "text/plain",
|
||||||
|
"address": "0xDEADbEeF000000000000000000000000DeaDbeEf",
|
||||||
|
"raw_data": "GUV0aGVyZXVtIFNpZ25lZCBNZXNzYWdlOgoxMWhlbGxvIHdvcmxk",
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"name": "message",
|
||||||
|
"value": "\u0019Ethereum Signed Message:\n11hello world",
|
||||||
|
"type": "text/plain"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hash": "0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68",
|
||||||
|
"meta": {
|
||||||
|
"remote": "localhost:9999",
|
||||||
|
"local": "localhost:8545",
|
||||||
|
"scheme": "http",
|
||||||
|
"User-Agent": "Firefox 3.2",
|
||||||
|
"Origin": "www.malicious.ru"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### SignDataResponse - approve
|
||||||
|
|
||||||
|
Response to SignDataRequest
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"approved": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### SignDataResponse - deny
|
||||||
|
|
||||||
|
Response to SignDataRequest
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"approved": false
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### SignTxRequest
|
||||||
|
|
||||||
|
SignTxRequest contains information about a pending request to sign a transaction. Aside from the transaction itself, there is also a `call_info`-struct. That struct contains messages of various types, that the user should be informed of.
|
||||||
|
|
||||||
|
As in any request, it's important to consider that the `meta` info also contains untrusted data.
|
||||||
|
|
||||||
|
The `transaction` (on input into clef) can have either `data` or `input` -- if both are set, they must be identical, otherwise an error is generated. However, Clef will always use `data` when passing this struct on (if Clef does otherwise, please file a ticket)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"transaction": {
|
||||||
|
"from": "0xDEADbEeF000000000000000000000000DeaDbeEf",
|
||||||
|
"to": null,
|
||||||
|
"gas": "0x3e8",
|
||||||
|
"gasPrice": "0x5",
|
||||||
|
"value": "0x6",
|
||||||
|
"nonce": "0x1",
|
||||||
|
"data": "0x01020304"
|
||||||
|
},
|
||||||
|
"call_info": [
|
||||||
|
{
|
||||||
|
"type": "Warning",
|
||||||
|
"message": "Something looks odd, show this message as a warning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Info",
|
||||||
|
"message": "User should see this aswell"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {
|
||||||
|
"remote": "localhost:9999",
|
||||||
|
"local": "localhost:8545",
|
||||||
|
"scheme": "http",
|
||||||
|
"User-Agent": "Firefox 3.2",
|
||||||
|
"Origin": "www.malicious.ru"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### SignTxResponse - approve
|
||||||
|
|
||||||
|
Response to request to sign a transaction. This response needs to contain the `transaction`, because the UI is free to make modifications to the transaction.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"transaction": {
|
||||||
|
"from": "0xDEADbEeF000000000000000000000000DeaDbeEf",
|
||||||
|
"to": null,
|
||||||
|
"gas": "0x3e8",
|
||||||
|
"gasPrice": "0x5",
|
||||||
|
"value": "0x6",
|
||||||
|
"nonce": "0x4",
|
||||||
|
"data": "0x04030201"
|
||||||
|
},
|
||||||
|
"approved": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### SignTxResponse - deny
|
||||||
|
|
||||||
|
Response to SignTxRequest. When denying a request, there's no need to provide the transaction in return
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"transaction": {
|
||||||
|
"from": "0x",
|
||||||
|
"to": null,
|
||||||
|
"gas": "0x0",
|
||||||
|
"gasPrice": "0x0",
|
||||||
|
"value": "0x0",
|
||||||
|
"nonce": "0x0",
|
||||||
|
"data": null
|
||||||
|
},
|
||||||
|
"approved": false
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### OnApproved - SignTransactionResult
|
||||||
|
|
||||||
|
SignTransactionResult is used in the call `clef` -> `OnApprovedTx(result)`
|
||||||
|
|
||||||
|
This occurs _after_ successful completion of the entire signing procedure, but right before the signed transaction is passed to the external caller. This method (and data) can be used by the UI to signal to the user that the transaction was signed, but it is primarily useful for ruleset implementations.
|
||||||
|
|
||||||
|
A ruleset that implements a rate limitation needs to know what transactions are sent out to the external interface. By hooking into this methods, the ruleset can maintain track of that count.
|
||||||
|
|
||||||
|
**OBS:** Note that if an attacker can restore your `clef` data to a previous point in time (e.g through a backup), the attacker can reset such windows, even if he/she is unable to decrypt the content.
|
||||||
|
|
||||||
|
The `OnApproved` method cannot be responded to, it's purely informative
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"raw": "0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
|
||||||
|
"tx": {
|
||||||
|
"nonce": "0x64",
|
||||||
|
"gasPrice": "0x1",
|
||||||
|
"gas": "0x1",
|
||||||
|
"to": "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192",
|
||||||
|
"value": "0x1",
|
||||||
|
"input": "0x",
|
||||||
|
"v": "0x26",
|
||||||
|
"r": "0x716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293",
|
||||||
|
"s": "0x4e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed",
|
||||||
|
"hash": "0x662f6d772692dd692f1b5e8baa77a9ff95bbd909362df3fc3d301aafebde5441"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### UserInputRequest
|
||||||
|
|
||||||
|
Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"prompt": "The question to ask the user",
|
||||||
|
"title": "The title here",
|
||||||
|
"isPassword": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### UserInputResponse
|
||||||
|
|
||||||
|
Response to UserInputRequest
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"text": "The textual response from user"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### ListRequest
|
||||||
|
|
||||||
|
Sent when a request has been made to list addresses. The UI is provided with the full `account`s, including local directory names. Note: this information is not passed back to the external caller, who only sees the `address`es.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"address": "0xdeadbeef000000000000000000000000deadbeef",
|
||||||
|
"url": "keystore:///path/to/keyfile/a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address": "0x1111111122222222222233333333334444444444",
|
||||||
|
"url": "keystore:///path/to/keyfile/b"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meta": {
|
||||||
|
"remote": "localhost:9999",
|
||||||
|
"local": "localhost:8545",
|
||||||
|
"scheme": "http",
|
||||||
|
"User-Agent": "Firefox 3.2",
|
||||||
|
"Origin": "www.malicious.ru"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### ListResponse
|
||||||
|
|
||||||
|
Response to list request. The response contains a list of all addresses to show to the caller. Note: the UI is free to respond with any address the caller, regardless of whether it exists or not
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"address": "0x0000000000000000000000000000000000000000",
|
||||||
|
"url": ".. ignored .."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address": "0xffffffffffffffffffffffffffffffffffffffff",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
BIN
cmd/clef/docs/clef_architecture_pt1.png
Normal file
BIN
cmd/clef/docs/clef_architecture_pt1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
BIN
cmd/clef/docs/clef_architecture_pt2.png
Normal file
BIN
cmd/clef/docs/clef_architecture_pt2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
BIN
cmd/clef/docs/clef_architecture_pt3.png
Normal file
BIN
cmd/clef/docs/clef_architecture_pt3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
BIN
cmd/clef/docs/clef_architecture_pt4.png
Normal file
BIN
cmd/clef/docs/clef_architecture_pt4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user