forked from trezor/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accountinfo.html
58 lines (45 loc) · 2.34 KB
/
accountinfo.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
<!DOCTYPE html>
<html>
<head>
<title>TREZOR Get account info</title>
<script>
function trezorGetAccountInfo() {
var description = "m/44'/0'/2'"; // third account
// (note that names on connect start with Account 1, which has index 0)
// var description = [44 | 0x80000000,
// 0 | 0x80000000,
// 2 | 0x80000000 ]; // same, in raw form
// var description = 2 // third account
// var description = "2" // can also be input as string
// var description = null // will start account discovery and let user select
// var description = "xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy"
// if specified by xpub, it has to be of one of the first 10 accounts
// this one is from test account, specified here
// https://github.com/satoshilabs/slips/blob/master/slip-0014.md
TrezorConnect.closeAfterFailure(false);
TrezorConnect.getAccountInfo(description, function (response) {
if (response.success) {
console.log('Account ID: ', response.id);
console.log('Account path: ', response.path);
console.log('Serialized account path: ', response.serializedPath);
console.log('Xpub', response.xpub);
console.log('Fresh address (first unused address): ', response.freshAddress);
console.log('Fresh address ID: ', response.freshAddressId);
console.log('Fresh address path: ', response.freshAddressPath);
console.log('Serialized fresh address path: ', response.serializedFreshAddressPath);
console.log('Balance in satoshis (including unconfirmed):', response.balance);
console.log('Balance in satoshis (only confirmed):', response.confirmed);
} else {
console.error('Error:', response.error); // error message
}
document.getElementById("response").innerHTML = JSON.stringify(response, undefined, 2);
});
}
</script>
</head>
<body>
<button onclick="trezorGetAccountInfo()">Get account info</button>
<pre id="response"></pre>
<script src="../connect.js"></script>
</body>
</html>