-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (19 loc) · 701 Bytes
/
index.js
File metadata and controls
21 lines (19 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const Socket = require('json-rpc-tls').Socket;
const Blockchain = require('../').Blockchain;
Socket.tlsSocket('185.64.116.15', 50002, {
// Note: this sends all data in plain text. You should connect using server's cert
rejectUnauthorized: false,
checkServerIdentity: () => undefined,
})
.then(async (socket) => {
socket.setEncoding('utf8');
socket.setKeepAlive(true, 0);
socket.setNoDelay(true);
const balance = await Blockchain.addressGetBalance({ id: 1, params: ['1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'], socket });
console.log(`Balance is ${balance.result.confirmed / 100000000} BTC`);
Socket.close(socket);
})
.catch((e) => {
console.log(e.error);
Socket.close(e.socket);
});