-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathledger.html
29 lines (28 loc) · 992 Bytes
/
ledger.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
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="../../../dist/index.umd.js"></script>
</head>
<body>
<h1>CAL + Ledger: Sign a message (Bitcoin)</h1>
<p>From: <span id="address"></span></p>
<p>Message: <input type="text" id="message"/> <button id="sign">Sign</button></p>
<p>Result: <span id="result"></span></p>
<p><code>For errors and logs, check console</code></p>
<script>
/* global $, ChainAbstractionLayer */
const { Client, providers, networks } = ChainAbstractionLayer
const bitcoin = new Client()
bitcoin.addProvider(new providers.bitcoin.BitcoinLedgerProvider({ network: networks.bitcoin_testnet }))
bitcoin.getAddresses().then(addresses => {
const from = addresses[0]
$('#address').text(from)
$('#sign').click(() => {
bitcoin.signMessage($('#message').val(), from).then(result => {
$('#result').text(JSON.stringify(result, null, 2))
})
})
})
</script>
</body>
</html>