-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEOS-Offline-Sign-Tool.html
163 lines (126 loc) · 5.79 KB
/
EOS-Offline-Sign-Tool.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>EOS Offline Signing Tool 离线签名工具 | EOSeco 出品</title>
<link rel="shortcut icon" type="image/x-icon" href="resource/favicon.ico">
<link rel="stylesheet" href="resource/bootstrap.min.css">
<script src="js/eosjs-offline.js" type="text/javascript"></script>
<!-- <script src="js/clipboard.min.js" type="text/javascript"></script> -->
<script type="text/javascript">
function signMessage() {
let unsigned = document.getElementById('unsigned-message').value;
let jsonUnsigned;
try {
jsonUnsigned = JSON.parse(unsigned);
} catch {
alert('格式错误 | Format Error');
}
let chain_id = document.getElementById("chain-id").innerHTML;
let wif = document.getElementById('private-key').value;
document.getElementById('private-key').value = "";
let signed = EosOffline(jsonUnsigned, chain_id, wif);
document.getElementById('signed-message').innerHTML = signed;
//清空私钥
wif = null;
}
function parseTransaction() {
let unsigned = document.getElementById('unsigned-message').value;
let jsonUnsigned;
try {
jsonUnsigned = JSON.parse(unsigned);
} catch {
alert('格式错误 | Format Error');
}
if (jsonUnsigned.transaction.actions.length > 1) {
alert('暂时不支持多action | Do not support multi actions yet');
document.getElementById('unsigned-message').style.backgroundColor = "red";
}
let action = jsonUnsigned.transaction.actions[0];
let contract = action.account;
let func = action.name;
let accountName = action.authorization[0].actor;
document.getElementById('account_name').value = accountName;
document.getElementById('contract_name').value = contract;
document.getElementById('func_name').value = func;
if (contract != "eosio") {
document.getElementById('contract_name').style.backgroundColor = "red";
}
if (func != "voteproducer") {
document.getElementById('func_name').style.backgroundColor = "red";
}
}
</script>
</head>
<body class="container">
<div class="text-center">
<img height=150px src="resource/logo.png">
</div>
<h1 class="text-center">EOS Offline Signing Tool | EOS 离线签名工具</h1>
<section id="alerts">
<div class="alert alert-warning" role="alert">
此页面可以离线使用,私钥只会在本地用来签名交易,您的私钥不会通过网络传输。安全起见,请关闭所有其他网页,在签名成功,复制报文后请立即关闭此页面。
</div>
<div class="alert alert-danger" role="alert">
请注意交易报文的"合约"应该是"eosio","功能"应该是"voteproducer"。
</div>
<div class="alert alert-warning" role="alert">
This page can work offline, private key just for signing transaction, private key will not transfer through network. To be
safe, you can close other web pages. After signing, you can close this page immediately.
</div>
<div class="alert alert-danger" role="alert">
Please notify that "Contract" should be "eosio", and "Function" should be "voteproducer".
</div>
</section>
<div class="form-group">
<label for="eos-chain-id">
<strong>链ID | Chain ID</strong>
</label>
<p id="chain-id" class="form-control">aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906</p>
</div>
<div class="form-group">
<label for="eos-chain-id">
<strong>未签名报文 | Unsigned Transaction</strong>
</label>
<textarea id="unsigned-message" class="form-control" rows="10" onblur="parseTransaction()"></textarea>
</div>
<div class="form-group">
<label for="eos-chain-id">
<strong>账户 | Account</strong>
</label>
<input id="account_name" class="form-control" readonly=true></input>
<label for="eos-chain-id">
<strong>合约 | Contract</strong>
</label>
<input id="contract_name" class="form-control" readonly=true></input>
<label for="eos-chain-id">
<strong>功能 | Function</strong>
</label>
<input id="func_name" class="form-control" readonly=true></input>
</div>
<div class="form-group">
<label>私钥 | Private Key</label>
<input id="private-key" class="form-control" placeholder="输入私钥|Input private key">
</div>
</div>
<div class="form-group">
<button id="vote" class="btn btn-primary" onclick="signMessage()">签名交易报文|Sign Transaction</button>
</div>
<div class="form-group">
<label for="eos-chain-id">
<strong>已签名报文 | Signed Transaction</strong>
</label>
<textarea id="signed-message" class="form-control" rows="10" readonly=true></textarea>
</div>
<div class="form-group">
<button id="copy" class="btn btn-success" data-clipboard-target="#signed-message">复制已签名报文|Copy signed trasaction</button>
<button id="close" class="btn btn-danger" onclick="window.close()">关闭页面|Close Page</button>
</div>
<!-- 1、引入相关的 clipboard 文件 -->
<script src="js/clipboard.min.js"></script>
<script type="text/javascript">
// 2、实例化(参数内是要触发事件源对象元素)
new Clipboard('.btn');
</script>
</body>
</html>