28 lines
617 B
TypeScript
Raw Normal View History

import mempoolJS from "@mempool/mempool.js";
2021-02-09 16:22:48 -03:00
const { bitcoin: { websocket } } = mempoolJS();
const init = async () => {
const ws = websocket.initServer({
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
2021-02-09 16:22:48 -03:00
});
ws.on("message", function incoming(data) {
const res = JSON.parse(data.toString());
2021-02-09 16:22:48 -03:00
if (res.blocks) {
console.log(res.blocks);
2021-02-09 16:22:48 -03:00
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
}
2021-02-09 16:22:48 -03:00
init();