This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const getUncommonSat = (blockHeight) => { | |
| const initialReward = 5000000000; // 50 BTC in satoshis | |
| const halvingInterval = 210000; // halving every 210,000 blocks | |
| let totalSatoshis = 0; | |
| let currentReward = initialReward; | |
| for (let i = 0; i < blockHeight; i += halvingInterval) { | |
| const blocksInThisEra = Math.min(halvingInterval, blockHeight - i); | |
| totalSatoshis += blocksInThisEra * currentReward; | |
| currentReward /= 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { WebSocket } from 'ws'; | |
| const ws = new WebSocket('wss://mempool.space/api/v1/ws'); | |
| ws.on('open', () => { | |
| console.log('Connected to mempool.space WebSocket'); | |
| ws.send(JSON.stringify({ 'track-mempool': true })); | |
| }); | |
| ws.on('message', (data) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import express from 'express'; | |
| import { createServer } from 'http'; | |
| import cors from 'cors' | |
| const app = express(); | |
| const server = createServer(app); | |
| app.use(cors({ | |
| origin: '*', | |
| methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| function logTxSize (value, max = 55000000000000) { | |
| let scale = Math.ceil(Math.log10(value)) - 5 | |
| return Math.min(max || Infinity,Math.max(1, scale)) | |
| } | |
| function processBtcTxData(data) { | |
| const parsedData = (data); |