forked from andgohq/electrumx-regtest
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrpctest.js
18 lines (18 loc) · 800 Bytes
/
rpctest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const ElectrumCli = require('electrum-client')
const main = async () => {
// const ecl = new ElectrumCli(995, 'btc.smsys.me', 'tls') // tcp or tls
// const ecl = new ElectrumCli(50001, 'electrum.coinucopia.io', 'tcp') // tcp or tls
const ecl = new ElectrumCli(55001, 'localhost', 'tcp') // tcp or tls
await ecl.connect(); // connect(promise)
ecl.subscribe.on('blockchain.headers.subscribe', (v) => console.log(v)) // subscribe message(EventEmitter)
try{
const ver = await ecl.server_version("electrum-client", "1.2") // json-rpc(promise)
console.log(ver)
const response = await ecl.blockchainBlock_getHeader('570144');
console.log(response);
}catch(e){
console.log(e)
}
await ecl.close() // disconnect(promise)
}
main()