brk-client 0.2.4 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +523 -29
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -107,6 +107,37 @@
|
|
|
107
107
|
* @typedef {Object} BlockCountParam
|
|
108
108
|
* @property {number} blockCount - Number of recent blocks to include
|
|
109
109
|
*/
|
|
110
|
+
/**
|
|
111
|
+
* Extended block data matching mempool.space /api/v1/blocks extras
|
|
112
|
+
*
|
|
113
|
+
* @typedef {Object} BlockExtras
|
|
114
|
+
* @property {Sats} totalFees - Total fees in satoshis
|
|
115
|
+
* @property {FeeRate} medianFee - Median fee rate in sat/vB
|
|
116
|
+
* @property {FeeRate[]} feeRange - Fee rate range: [min, 10%, 25%, 50%, 75%, 90%, max]
|
|
117
|
+
* @property {Sats} reward - Total block reward (subsidy + fees) in satoshis
|
|
118
|
+
* @property {BlockPool} pool - Mining pool that mined this block
|
|
119
|
+
* @property {Sats} avgFee - Average fee per transaction in satoshis
|
|
120
|
+
* @property {FeeRate} avgFeeRate - Average fee rate in sat/vB
|
|
121
|
+
* @property {string} coinbaseRaw - Raw coinbase transaction scriptsig as hex
|
|
122
|
+
* @property {?string=} coinbaseAddress - Primary coinbase output address
|
|
123
|
+
* @property {string[]} coinbaseAddresses - All coinbase output addresses
|
|
124
|
+
* @property {string} coinbaseSignature - Coinbase output script in ASM format
|
|
125
|
+
* @property {string} coinbaseSignatureAscii - Coinbase scriptsig decoded as ASCII
|
|
126
|
+
* @property {number} avgTxSize - Average transaction size in bytes
|
|
127
|
+
* @property {number} totalInputs - Total number of inputs (excluding coinbase)
|
|
128
|
+
* @property {number} totalOutputs - Total number of outputs
|
|
129
|
+
* @property {Sats} totalOutputAmt - Total output amount in satoshis
|
|
130
|
+
* @property {Sats} medianFeeAmt - Median fee amount in satoshis
|
|
131
|
+
* @property {Sats[]} feePercentiles - Fee amount percentiles in satoshis: [min, 10%, 25%, 50%, 75%, 90%, max]
|
|
132
|
+
* @property {number} segwitTotalTxs - Number of segwit transactions
|
|
133
|
+
* @property {number} segwitTotalSize - Total size of segwit transactions in bytes
|
|
134
|
+
* @property {Weight} segwitTotalWeight - Total weight of segwit transactions
|
|
135
|
+
* @property {string} header - Raw 80-byte block header as hex
|
|
136
|
+
* @property {number} utxoSetChange - UTXO set change (outputs created minus inputs spent)
|
|
137
|
+
* @property {number} utxoSetSize - Total UTXO set size at this height
|
|
138
|
+
* @property {Sats} totalInputAmt - Total input amount in satoshis
|
|
139
|
+
* @property {number} virtualSize - Virtual size in vbytes
|
|
140
|
+
*/
|
|
110
141
|
/**
|
|
111
142
|
* A single block fees data point.
|
|
112
143
|
*
|
|
@@ -135,16 +166,51 @@
|
|
|
135
166
|
* @property {TxIndex} index - Transaction index within the block (0-based)
|
|
136
167
|
*/
|
|
137
168
|
/**
|
|
138
|
-
* Block information
|
|
169
|
+
* Block information matching mempool.space /api/block/{hash}
|
|
139
170
|
*
|
|
140
171
|
* @typedef {Object} BlockInfo
|
|
141
172
|
* @property {BlockHash} id - Block hash
|
|
142
173
|
* @property {Height} height - Block height
|
|
174
|
+
* @property {number} version - Block version, used for soft fork signaling
|
|
175
|
+
* @property {BlockHash} previousblockhash - Previous block hash
|
|
176
|
+
* @property {string} merkleRoot - Merkle root of the transaction tree
|
|
177
|
+
* @property {number} time - Block timestamp as claimed by the miner (Unix time)
|
|
178
|
+
* @property {number} bits - Compact target (bits)
|
|
179
|
+
* @property {number} nonce - Nonce used to produce a valid block hash
|
|
180
|
+
* @property {Timestamp} timestamp - Block timestamp (Unix time)
|
|
143
181
|
* @property {number} txCount - Number of transactions in the block
|
|
144
182
|
* @property {number} size - Block size in bytes
|
|
145
183
|
* @property {Weight} weight - Block weight in weight units
|
|
184
|
+
* @property {Timestamp} mediantime - Median time of the last 11 blocks
|
|
185
|
+
* @property {number} difficulty - Block difficulty
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* Block information with extras, matching mempool.space /api/v1/blocks
|
|
189
|
+
*
|
|
190
|
+
* @typedef {Object} BlockInfoV1
|
|
191
|
+
* @property {BlockHash} id - Block hash
|
|
192
|
+
* @property {Height} height - Block height
|
|
193
|
+
* @property {number} version - Block version, used for soft fork signaling
|
|
194
|
+
* @property {BlockHash} previousblockhash - Previous block hash
|
|
195
|
+
* @property {string} merkleRoot - Merkle root of the transaction tree
|
|
196
|
+
* @property {number} time - Block timestamp as claimed by the miner (Unix time)
|
|
197
|
+
* @property {number} bits - Compact target (bits)
|
|
198
|
+
* @property {number} nonce - Nonce used to produce a valid block hash
|
|
146
199
|
* @property {Timestamp} timestamp - Block timestamp (Unix time)
|
|
147
|
-
* @property {number}
|
|
200
|
+
* @property {number} txCount - Number of transactions in the block
|
|
201
|
+
* @property {number} size - Block size in bytes
|
|
202
|
+
* @property {Weight} weight - Block weight in weight units
|
|
203
|
+
* @property {Timestamp} mediantime - Median time of the last 11 blocks
|
|
204
|
+
* @property {number} difficulty - Block difficulty
|
|
205
|
+
* @property {BlockExtras} extras - Extended block data
|
|
206
|
+
*/
|
|
207
|
+
/**
|
|
208
|
+
* Mining pool identification for a block
|
|
209
|
+
*
|
|
210
|
+
* @typedef {Object} BlockPool
|
|
211
|
+
* @property {number} id - Unique pool identifier
|
|
212
|
+
* @property {string} name - Pool name
|
|
213
|
+
* @property {PoolSlug} slug - URL-friendly pool identifier
|
|
148
214
|
*/
|
|
149
215
|
/**
|
|
150
216
|
* A single block rewards data point.
|
|
@@ -228,6 +294,17 @@
|
|
|
228
294
|
*
|
|
229
295
|
* @typedef {string} Cohort
|
|
230
296
|
*/
|
|
297
|
+
/**
|
|
298
|
+
* Coinbase scriptSig tag for pool identification.
|
|
299
|
+
*
|
|
300
|
+
* Stored as a fixed 101-byte record (1 byte length + 100 bytes data).
|
|
301
|
+
* Uses `[u8; 101]` internally so that `size_of::<CoinbaseTag>()` matches
|
|
302
|
+
* the serialized `Bytes::Array` size (vecdb requires this for alignment).
|
|
303
|
+
*
|
|
304
|
+
* Bitcoin consensus limits coinbase scriptSig to 2-100 bytes.
|
|
305
|
+
*
|
|
306
|
+
* @typedef {string} CoinbaseTag
|
|
307
|
+
*/
|
|
231
308
|
/**
|
|
232
309
|
* Bucket type for cost basis aggregation.
|
|
233
310
|
* Options: raw (no aggregation), lin200/lin500/lin1000 (linear $200/$500/$1000),
|
|
@@ -261,6 +338,22 @@
|
|
|
261
338
|
*
|
|
262
339
|
* @typedef {("supply"|"realized"|"unrealized")} CostBasisValue
|
|
263
340
|
*/
|
|
341
|
+
/**
|
|
342
|
+
* A transaction in a CPFP relationship
|
|
343
|
+
*
|
|
344
|
+
* @typedef {Object} CpfpEntry
|
|
345
|
+
* @property {Txid} txid
|
|
346
|
+
* @property {Weight} weight
|
|
347
|
+
* @property {Sats} fee
|
|
348
|
+
*/
|
|
349
|
+
/**
|
|
350
|
+
* CPFP (Child Pays For Parent) information for a transaction
|
|
351
|
+
*
|
|
352
|
+
* @typedef {Object} CpfpInfo
|
|
353
|
+
* @property {CpfpEntry[]} ancestors
|
|
354
|
+
* @property {CpfpEntry[]} descendants
|
|
355
|
+
* @property {FeeRate} effectiveFeePerVsize
|
|
356
|
+
*/
|
|
264
357
|
/**
|
|
265
358
|
* Data range with output format for API query parameters
|
|
266
359
|
*
|
|
@@ -357,6 +450,11 @@
|
|
|
357
450
|
* @property {string} message - Human-readable description
|
|
358
451
|
* @property {string} docUrl - Link to API documentation
|
|
359
452
|
*/
|
|
453
|
+
/**
|
|
454
|
+
* Exchange rates (USD base, on-chain only — no fiat pairs available)
|
|
455
|
+
*
|
|
456
|
+
* @typedef {Object} ExchangeRates
|
|
457
|
+
*/
|
|
360
458
|
/**
|
|
361
459
|
* Fee rate in sats/vB
|
|
362
460
|
*
|
|
@@ -424,14 +522,23 @@
|
|
|
424
522
|
* @property {Height} height
|
|
425
523
|
*/
|
|
426
524
|
/**
|
|
427
|
-
*
|
|
525
|
+
* Highest price value for a time period
|
|
428
526
|
*
|
|
429
|
-
* @typedef {
|
|
527
|
+
* @typedef {Dollars} High
|
|
430
528
|
*/
|
|
431
529
|
/**
|
|
432
|
-
*
|
|
530
|
+
* Historical price response
|
|
433
531
|
*
|
|
434
|
-
* @typedef {
|
|
532
|
+
* @typedef {Object} HistoricalPrice
|
|
533
|
+
* @property {HistoricalPriceEntry[]} prices
|
|
534
|
+
* @property {ExchangeRates} exchangeRates
|
|
535
|
+
*/
|
|
536
|
+
/**
|
|
537
|
+
* A single price data point
|
|
538
|
+
*
|
|
539
|
+
* @typedef {Object} HistoricalPriceEntry
|
|
540
|
+
* @property {number} time
|
|
541
|
+
* @property {Dollars} uSD
|
|
435
542
|
*/
|
|
436
543
|
/** @typedef {number} Hour1 */
|
|
437
544
|
/** @typedef {number} Hour12 */
|
|
@@ -484,12 +591,30 @@
|
|
|
484
591
|
* @property {FeeRate[]} feeRange - Fee rate range: [min, 10%, 25%, 50%, 75%, 90%, max]
|
|
485
592
|
*/
|
|
486
593
|
/**
|
|
487
|
-
* Mempool statistics
|
|
594
|
+
* Mempool statistics with incrementally maintained fee histogram.
|
|
488
595
|
*
|
|
489
596
|
* @typedef {Object} MempoolInfo
|
|
490
597
|
* @property {number} count - Number of transactions in the mempool
|
|
491
598
|
* @property {VSize} vsize - Total virtual size of all transactions in the mempool (vbytes)
|
|
492
599
|
* @property {Sats} totalFee - Total fees of all transactions in the mempool (satoshis)
|
|
600
|
+
* @property {{ [key: string]: VSize }} feeHistogram - Fee histogram: `[[fee_rate, vsize], ...]` sorted by descending fee rate
|
|
601
|
+
*/
|
|
602
|
+
/**
|
|
603
|
+
* Simplified mempool transaction for the recent transactions endpoint
|
|
604
|
+
*
|
|
605
|
+
* @typedef {Object} MempoolRecentTx
|
|
606
|
+
* @property {Txid} txid
|
|
607
|
+
* @property {Sats} fee
|
|
608
|
+
* @property {VSize} vsize
|
|
609
|
+
* @property {Sats} value
|
|
610
|
+
*/
|
|
611
|
+
/**
|
|
612
|
+
* Merkle inclusion proof for a transaction
|
|
613
|
+
*
|
|
614
|
+
* @typedef {Object} MerkleProof
|
|
615
|
+
* @property {Height} blockHeight
|
|
616
|
+
* @property {string[]} merkle
|
|
617
|
+
* @property {number} pos
|
|
493
618
|
*/
|
|
494
619
|
/** @typedef {number} Minute10 */
|
|
495
620
|
/** @typedef {number} Minute30 */
|
|
@@ -529,6 +654,10 @@
|
|
|
529
654
|
*
|
|
530
655
|
* @typedef {Dollars} Open
|
|
531
656
|
*/
|
|
657
|
+
/**
|
|
658
|
+
* @typedef {Object} OptionalTimestampParam
|
|
659
|
+
* @property {(Timestamp|null)=} timestamp
|
|
660
|
+
*/
|
|
532
661
|
/** @typedef {number} OutPoint */
|
|
533
662
|
/**
|
|
534
663
|
* Type (P2PKH, P2WPKH, P2SH, P2TR, etc.)
|
|
@@ -607,6 +736,15 @@
|
|
|
607
736
|
* @property {string[]} regexes - Coinbase tag patterns (regexes)
|
|
608
737
|
* @property {PoolSlug} slug - URL-friendly pool identifier
|
|
609
738
|
*/
|
|
739
|
+
/**
|
|
740
|
+
* A single pool hashrate data point.
|
|
741
|
+
*
|
|
742
|
+
* @typedef {Object} PoolHashrateEntry
|
|
743
|
+
* @property {Timestamp} timestamp - Unix timestamp.
|
|
744
|
+
* @property {number} avgHashrate - Average hashrate (H/s).
|
|
745
|
+
* @property {number} share - Pool's share of total network hashrate.
|
|
746
|
+
* @property {string} poolName - Pool name.
|
|
747
|
+
*/
|
|
610
748
|
/**
|
|
611
749
|
* Basic pool information for listing all pools
|
|
612
750
|
*
|
|
@@ -616,6 +754,11 @@
|
|
|
616
754
|
* @property {number} uniqueId - Unique numeric pool identifier
|
|
617
755
|
*/
|
|
618
756
|
/** @typedef {("unknown"|"blockfills"|"ultimuspool"|"terrapool"|"luxor"|"onethash"|"btccom"|"bitfarms"|"huobipool"|"wayicn"|"canoepool"|"btctop"|"bitcoincom"|"pool175btc"|"gbminers"|"axbt"|"asicminer"|"bitminter"|"bitcoinrussia"|"btcserv"|"simplecoinus"|"btcguild"|"eligius"|"ozcoin"|"eclipsemc"|"maxbtc"|"triplemining"|"coinlab"|"pool50btc"|"ghashio"|"stminingcorp"|"bitparking"|"mmpool"|"polmine"|"kncminer"|"bitalo"|"f2pool"|"hhtt"|"megabigpower"|"mtred"|"nmcbit"|"yourbtcnet"|"givemecoins"|"braiinspool"|"antpool"|"multicoinco"|"bcpoolio"|"cointerra"|"kanopool"|"solock"|"ckpool"|"nicehash"|"bitclub"|"bitcoinaffiliatenetwork"|"btcc"|"bwpool"|"exxbw"|"bitsolo"|"bitfury"|"twentyoneinc"|"digitalbtc"|"eightbaochi"|"mybtccoinpool"|"tbdice"|"hashpool"|"nexious"|"bravomining"|"hotpool"|"okexpool"|"bcmonster"|"onehash"|"bixin"|"tatmaspool"|"viabtc"|"connectbtc"|"batpool"|"waterhole"|"dcexploration"|"dcex"|"btpool"|"fiftyeightcoin"|"bitcoinindia"|"shawnp0wers"|"phashio"|"rigpool"|"haozhuzhu"|"sevenpool"|"miningkings"|"hashbx"|"dpool"|"rawpool"|"haominer"|"helix"|"bitcoinukraine"|"poolin"|"secretsuperstar"|"tigerpoolnet"|"sigmapoolcom"|"okpooltop"|"hummerpool"|"tangpool"|"bytepool"|"spiderpool"|"novablock"|"miningcity"|"binancepool"|"minerium"|"lubiancom"|"okkong"|"aaopool"|"emcdpool"|"foundryusa"|"sbicrypto"|"arkpool"|"purebtccom"|"marapool"|"kucoinpool"|"entrustcharitypool"|"okminer"|"titan"|"pegapool"|"btcnuggets"|"cloudhashing"|"digitalxmintsy"|"telco214"|"btcpoolparty"|"multipool"|"transactioncoinmining"|"btcdig"|"trickysbtcpool"|"btcmp"|"eobot"|"unomp"|"patels"|"gogreenlight"|"bitcoinindiapool"|"ekanembtc"|"canoe"|"tiger"|"onem1x"|"zulupool"|"secpool"|"ocean"|"whitepool"|"wiz"|"wk057"|"futurebitapollosolo"|"carbonnegative"|"portlandhodl"|"phoenix"|"neopool"|"maxipool"|"bitfufupool"|"gdpool"|"miningdutch"|"publicpool"|"miningsquared"|"innopolistech"|"btclab"|"parasite"|"redrockpool"|"est3lar")} PoolSlug */
|
|
757
|
+
/**
|
|
758
|
+
* @typedef {Object} PoolSlugAndHeightParam
|
|
759
|
+
* @property {PoolSlug} slug
|
|
760
|
+
* @property {Height} height
|
|
761
|
+
*/
|
|
619
762
|
/**
|
|
620
763
|
* @typedef {Object} PoolSlugParam
|
|
621
764
|
* @property {PoolSlug} slug
|
|
@@ -641,6 +784,13 @@
|
|
|
641
784
|
* @property {number} blockCount - Total blocks in the time period
|
|
642
785
|
* @property {number} lastEstimatedHashrate - Estimated network hashrate (hashes per second)
|
|
643
786
|
*/
|
|
787
|
+
/**
|
|
788
|
+
* Current price response matching mempool.space /api/v1/prices format
|
|
789
|
+
*
|
|
790
|
+
* @typedef {Object} Prices
|
|
791
|
+
* @property {Timestamp} time
|
|
792
|
+
* @property {Dollars} uSD
|
|
793
|
+
*/
|
|
644
794
|
/**
|
|
645
795
|
* A range boundary: integer index, date, or timestamp.
|
|
646
796
|
*
|
|
@@ -982,6 +1132,20 @@
|
|
|
982
1132
|
const _isBrowser = typeof window !== 'undefined' && 'caches' in window;
|
|
983
1133
|
const _runIdle = (/** @type {VoidFunction} */ fn) => (globalThis.requestIdleCallback ?? setTimeout)(fn);
|
|
984
1134
|
const _defaultCacheName = '__BRK_CLIENT__';
|
|
1135
|
+
/** @param {*} v */
|
|
1136
|
+
const _addCamelGetters = (v) => {
|
|
1137
|
+
if (Array.isArray(v)) { v.forEach(_addCamelGetters); return v; }
|
|
1138
|
+
if (v && typeof v === 'object' && v.constructor === Object) {
|
|
1139
|
+
for (const k in v) {
|
|
1140
|
+
if (k.includes('_')) {
|
|
1141
|
+
const c = k.replace(/_([a-z])/g, (_, l) => l.toUpperCase());
|
|
1142
|
+
if (!(c in v)) Object.defineProperty(v, c, { get() { return this[k]; } });
|
|
1143
|
+
}
|
|
1144
|
+
_addCamelGetters(v[k]);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return v;
|
|
1148
|
+
};
|
|
985
1149
|
|
|
986
1150
|
/**
|
|
987
1151
|
* @param {string|boolean|undefined} cache
|
|
@@ -1378,7 +1542,7 @@ class BrkClientBase {
|
|
|
1378
1542
|
const cachePromise = cache?.match(url).then(async (res) => {
|
|
1379
1543
|
cachedRes = res ?? null;
|
|
1380
1544
|
if (!res) return null;
|
|
1381
|
-
const json = await res.json();
|
|
1545
|
+
const json = _addCamelGetters(await res.json());
|
|
1382
1546
|
if (!resolved && onUpdate) {
|
|
1383
1547
|
resolved = true;
|
|
1384
1548
|
onUpdate(json);
|
|
@@ -1388,7 +1552,7 @@ class BrkClientBase {
|
|
|
1388
1552
|
|
|
1389
1553
|
const networkPromise = this.get(path).then(async (res) => {
|
|
1390
1554
|
const cloned = res.clone();
|
|
1391
|
-
const json = await res.json();
|
|
1555
|
+
const json = _addCamelGetters(await res.json());
|
|
1392
1556
|
// Skip update if ETag matches and cache already delivered
|
|
1393
1557
|
if (cachedRes?.headers.get('ETag') === res.headers.get('ETag')) {
|
|
1394
1558
|
if (!resolved && onUpdate) {
|
|
@@ -4145,7 +4309,6 @@ function createTransferPattern(client, acc) {
|
|
|
4145
4309
|
* @property {SeriesTree_Addrs} addrs
|
|
4146
4310
|
* @property {SeriesTree_Scripts} scripts
|
|
4147
4311
|
* @property {SeriesTree_Mining} mining
|
|
4148
|
-
* @property {SeriesTree_Positions} positions
|
|
4149
4312
|
* @property {SeriesTree_Cointime} cointime
|
|
4150
4313
|
* @property {SeriesTree_Constants} constants
|
|
4151
4314
|
* @property {SeriesTree_Indexes} indexes
|
|
@@ -4161,10 +4324,14 @@ function createTransferPattern(client, acc) {
|
|
|
4161
4324
|
/**
|
|
4162
4325
|
* @typedef {Object} SeriesTree_Blocks
|
|
4163
4326
|
* @property {SeriesPattern18<BlockHash>} blockhash
|
|
4327
|
+
* @property {SeriesPattern18<CoinbaseTag>} coinbaseTag
|
|
4164
4328
|
* @property {SeriesTree_Blocks_Difficulty} difficulty
|
|
4165
4329
|
* @property {SeriesTree_Blocks_Time} time
|
|
4166
4330
|
* @property {SeriesTree_Blocks_Size} size
|
|
4167
4331
|
* @property {AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern<Weight>} weight
|
|
4332
|
+
* @property {SeriesPattern18<StoredU32>} segwitTxs
|
|
4333
|
+
* @property {SeriesPattern18<StoredU64>} segwitSize
|
|
4334
|
+
* @property {SeriesPattern18<Weight>} segwitWeight
|
|
4168
4335
|
* @property {SeriesTree_Blocks_Count} count
|
|
4169
4336
|
* @property {SeriesTree_Blocks_Lookback} lookback
|
|
4170
4337
|
* @property {SeriesTree_Blocks_Interval} interval
|
|
@@ -4328,6 +4495,7 @@ function createTransferPattern(client, acc) {
|
|
|
4328
4495
|
* @property {SeriesPattern19<Sats>} outputValue
|
|
4329
4496
|
* @property {_6bBlockTxPattern<Sats>} fee
|
|
4330
4497
|
* @property {_6bBlockTxPattern<FeeRate>} feeRate
|
|
4498
|
+
* @property {_6bBlockTxPattern<FeeRate>} effectiveFeeRate
|
|
4331
4499
|
*/
|
|
4332
4500
|
|
|
4333
4501
|
/**
|
|
@@ -4597,6 +4765,7 @@ function createTransferPattern(client, acc) {
|
|
|
4597
4765
|
* @property {AverageBlockCumulativeSumPattern3} coinbase
|
|
4598
4766
|
* @property {SeriesTree_Mining_Rewards_Subsidy} subsidy
|
|
4599
4767
|
* @property {SeriesTree_Mining_Rewards_Fees} fees
|
|
4768
|
+
* @property {SeriesPattern18<Sats>} outputVolume
|
|
4600
4769
|
* @property {BlockCumulativePattern} unclaimed
|
|
4601
4770
|
*/
|
|
4602
4771
|
|
|
@@ -4657,10 +4826,6 @@ function createTransferPattern(client, acc) {
|
|
|
4657
4826
|
* @property {SeriesPattern1<StoredF64>} _1y
|
|
4658
4827
|
*/
|
|
4659
4828
|
|
|
4660
|
-
/**
|
|
4661
|
-
* @typedef {Object} SeriesTree_Positions
|
|
4662
|
-
*/
|
|
4663
|
-
|
|
4664
4829
|
/**
|
|
4665
4830
|
* @typedef {Object} SeriesTree_Cointime
|
|
4666
4831
|
* @property {SeriesTree_Cointime_Activity} activity
|
|
@@ -6381,7 +6546,7 @@ function createTransferPattern(client, acc) {
|
|
|
6381
6546
|
* @extends BrkClientBase
|
|
6382
6547
|
*/
|
|
6383
6548
|
class BrkClient extends BrkClientBase {
|
|
6384
|
-
VERSION = "v0.
|
|
6549
|
+
VERSION = "v0.3.0-alpha.0";
|
|
6385
6550
|
|
|
6386
6551
|
INDEXES = /** @type {const} */ ([
|
|
6387
6552
|
"minute10",
|
|
@@ -7572,6 +7737,7 @@ class BrkClient extends BrkClientBase {
|
|
|
7572
7737
|
return {
|
|
7573
7738
|
blocks: {
|
|
7574
7739
|
blockhash: createSeriesPattern18(this, 'blockhash'),
|
|
7740
|
+
coinbaseTag: createSeriesPattern18(this, 'coinbase_tag'),
|
|
7575
7741
|
difficulty: {
|
|
7576
7742
|
value: createSeriesPattern1(this, 'difficulty'),
|
|
7577
7743
|
hashrate: createSeriesPattern1(this, 'difficulty_hashrate'),
|
|
@@ -7597,6 +7763,9 @@ class BrkClient extends BrkClientBase {
|
|
|
7597
7763
|
pct90: create_1m1w1y24hPattern(this, 'block_size_pct90'),
|
|
7598
7764
|
},
|
|
7599
7765
|
weight: createAverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern(this, 'block_weight'),
|
|
7766
|
+
segwitTxs: createSeriesPattern18(this, 'segwit_txs'),
|
|
7767
|
+
segwitSize: createSeriesPattern18(this, 'segwit_size'),
|
|
7768
|
+
segwitWeight: createSeriesPattern18(this, 'segwit_weight'),
|
|
7600
7769
|
count: {
|
|
7601
7770
|
target: create_1m1w1y24hPattern(this, 'block_count_target'),
|
|
7602
7771
|
total: createAverageBlockCumulativeSumPattern2(this, 'block_count'),
|
|
@@ -7695,6 +7864,7 @@ class BrkClient extends BrkClientBase {
|
|
|
7695
7864
|
outputValue: createSeriesPattern19(this, 'output_value'),
|
|
7696
7865
|
fee: create_6bBlockTxPattern(this, 'fee'),
|
|
7697
7866
|
feeRate: create_6bBlockTxPattern(this, 'fee_rate'),
|
|
7867
|
+
effectiveFeeRate: create_6bBlockTxPattern(this, 'effective_fee_rate'),
|
|
7698
7868
|
},
|
|
7699
7869
|
versions: {
|
|
7700
7870
|
v1: createAverageBlockCumulativeSumPattern(this, 'tx_v1'),
|
|
@@ -7893,6 +8063,7 @@ class BrkClient extends BrkClientBase {
|
|
|
7893
8063
|
_1y: createBpsRatioPattern2(this, 'fee_to_subsidy_ratio_1y'),
|
|
7894
8064
|
},
|
|
7895
8065
|
},
|
|
8066
|
+
outputVolume: createSeriesPattern18(this, 'output_volume'),
|
|
7896
8067
|
unclaimed: createBlockCumulativePattern(this, 'unclaimed_rewards'),
|
|
7897
8068
|
},
|
|
7898
8069
|
hashrate: {
|
|
@@ -7911,8 +8082,6 @@ class BrkClient extends BrkClientBase {
|
|
|
7911
8082
|
value: createPhsReboundThsPattern(this, 'hash_value'),
|
|
7912
8083
|
},
|
|
7913
8084
|
},
|
|
7914
|
-
positions: {
|
|
7915
|
-
},
|
|
7916
8085
|
cointime: {
|
|
7917
8086
|
activity: {
|
|
7918
8087
|
coinblocksCreated: createAverageBlockCumulativeSumPattern(this, 'coinblocks_created'),
|
|
@@ -9338,16 +9507,16 @@ class BrkClient extends BrkClientBase {
|
|
|
9338
9507
|
}
|
|
9339
9508
|
|
|
9340
9509
|
/**
|
|
9341
|
-
* Block by height
|
|
9510
|
+
* Block hash by height
|
|
9342
9511
|
*
|
|
9343
|
-
* Retrieve block
|
|
9512
|
+
* Retrieve the block hash at a given height. Returns the hash as plain text.
|
|
9344
9513
|
*
|
|
9345
9514
|
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-height)*
|
|
9346
9515
|
*
|
|
9347
9516
|
* Endpoint: `GET /api/block-height/{height}`
|
|
9348
9517
|
*
|
|
9349
9518
|
* @param {Height} height
|
|
9350
|
-
* @returns {Promise
|
|
9519
|
+
* @returns {Promise<*>}
|
|
9351
9520
|
*/
|
|
9352
9521
|
async getBlockByHeight(height) {
|
|
9353
9522
|
return this.getJson(`/api/block-height/${height}`);
|
|
@@ -9369,6 +9538,22 @@ class BrkClient extends BrkClientBase {
|
|
|
9369
9538
|
return this.getJson(`/api/block/${hash}`);
|
|
9370
9539
|
}
|
|
9371
9540
|
|
|
9541
|
+
/**
|
|
9542
|
+
* Block header
|
|
9543
|
+
*
|
|
9544
|
+
* Returns the hex-encoded block header.
|
|
9545
|
+
*
|
|
9546
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-header)*
|
|
9547
|
+
*
|
|
9548
|
+
* Endpoint: `GET /api/block/{hash}/header`
|
|
9549
|
+
*
|
|
9550
|
+
* @param {BlockHash} hash
|
|
9551
|
+
* @returns {Promise<*>}
|
|
9552
|
+
*/
|
|
9553
|
+
async getBlockHeader(hash) {
|
|
9554
|
+
return this.getJson(`/api/block/${hash}/header`);
|
|
9555
|
+
}
|
|
9556
|
+
|
|
9372
9557
|
/**
|
|
9373
9558
|
* Raw block
|
|
9374
9559
|
*
|
|
@@ -9412,7 +9597,7 @@ class BrkClient extends BrkClientBase {
|
|
|
9412
9597
|
*
|
|
9413
9598
|
* @param {BlockHash} hash - Bitcoin block hash
|
|
9414
9599
|
* @param {TxIndex} index - Transaction index within the block (0-based)
|
|
9415
|
-
* @returns {Promise
|
|
9600
|
+
* @returns {Promise<*>}
|
|
9416
9601
|
*/
|
|
9417
9602
|
async getBlockTxid(hash, index) {
|
|
9418
9603
|
return this.getJson(`/api/block/${hash}/txid/${index}`);
|
|
@@ -9434,6 +9619,22 @@ class BrkClient extends BrkClientBase {
|
|
|
9434
9619
|
return this.getJson(`/api/block/${hash}/txids`);
|
|
9435
9620
|
}
|
|
9436
9621
|
|
|
9622
|
+
/**
|
|
9623
|
+
* Block transactions
|
|
9624
|
+
*
|
|
9625
|
+
* Retrieve transactions in a block by block hash. Returns up to 25 transactions starting from index 0.
|
|
9626
|
+
*
|
|
9627
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-transactions)*
|
|
9628
|
+
*
|
|
9629
|
+
* Endpoint: `GET /api/block/{hash}/txs`
|
|
9630
|
+
*
|
|
9631
|
+
* @param {BlockHash} hash
|
|
9632
|
+
* @returns {Promise<Transaction[]>}
|
|
9633
|
+
*/
|
|
9634
|
+
async getBlockTxs(hash) {
|
|
9635
|
+
return this.getJson(`/api/block/${hash}/txs`);
|
|
9636
|
+
}
|
|
9637
|
+
|
|
9437
9638
|
/**
|
|
9438
9639
|
* Block transactions (paginated)
|
|
9439
9640
|
*
|
|
@@ -9447,7 +9648,7 @@ class BrkClient extends BrkClientBase {
|
|
|
9447
9648
|
* @param {TxIndex} start_index - Starting transaction index within the block (0-based)
|
|
9448
9649
|
* @returns {Promise<Transaction[]>}
|
|
9449
9650
|
*/
|
|
9450
|
-
async
|
|
9651
|
+
async getBlockTxsFromIndex(hash, start_index) {
|
|
9451
9652
|
return this.getJson(`/api/block/${hash}/txs/${start_index}`);
|
|
9452
9653
|
}
|
|
9453
9654
|
|
|
@@ -9465,6 +9666,34 @@ class BrkClient extends BrkClientBase {
|
|
|
9465
9666
|
return this.getJson(`/api/blocks`);
|
|
9466
9667
|
}
|
|
9467
9668
|
|
|
9669
|
+
/**
|
|
9670
|
+
* Block tip hash
|
|
9671
|
+
*
|
|
9672
|
+
* Returns the hash of the last block.
|
|
9673
|
+
*
|
|
9674
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-tip-hash)*
|
|
9675
|
+
*
|
|
9676
|
+
* Endpoint: `GET /api/blocks/tip/hash`
|
|
9677
|
+
* @returns {Promise<*>}
|
|
9678
|
+
*/
|
|
9679
|
+
async getBlockTipHash() {
|
|
9680
|
+
return this.getJson(`/api/blocks/tip/hash`);
|
|
9681
|
+
}
|
|
9682
|
+
|
|
9683
|
+
/**
|
|
9684
|
+
* Block tip height
|
|
9685
|
+
*
|
|
9686
|
+
* Returns the height of the last block.
|
|
9687
|
+
*
|
|
9688
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-tip-height)*
|
|
9689
|
+
*
|
|
9690
|
+
* Endpoint: `GET /api/blocks/tip/height`
|
|
9691
|
+
* @returns {Promise<*>}
|
|
9692
|
+
*/
|
|
9693
|
+
async getBlockTipHeight() {
|
|
9694
|
+
return this.getJson(`/api/blocks/tip/height`);
|
|
9695
|
+
}
|
|
9696
|
+
|
|
9468
9697
|
/**
|
|
9469
9698
|
* Blocks from height
|
|
9470
9699
|
*
|
|
@@ -9484,15 +9713,15 @@ class BrkClient extends BrkClientBase {
|
|
|
9484
9713
|
/**
|
|
9485
9714
|
* Mempool statistics
|
|
9486
9715
|
*
|
|
9487
|
-
* Get current mempool statistics including transaction count, total vsize, and
|
|
9716
|
+
* Get current mempool statistics including transaction count, total vsize, total fees, and fee histogram.
|
|
9488
9717
|
*
|
|
9489
9718
|
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mempool)*
|
|
9490
9719
|
*
|
|
9491
|
-
* Endpoint: `GET /api/mempool
|
|
9720
|
+
* Endpoint: `GET /api/mempool`
|
|
9492
9721
|
* @returns {Promise<MempoolInfo>}
|
|
9493
9722
|
*/
|
|
9494
9723
|
async getMempool() {
|
|
9495
|
-
return this.getJson(`/api/mempool
|
|
9724
|
+
return this.getJson(`/api/mempool`);
|
|
9496
9725
|
}
|
|
9497
9726
|
|
|
9498
9727
|
/**
|
|
@@ -9507,6 +9736,20 @@ class BrkClient extends BrkClientBase {
|
|
|
9507
9736
|
return this.getJson(`/api/mempool/price`);
|
|
9508
9737
|
}
|
|
9509
9738
|
|
|
9739
|
+
/**
|
|
9740
|
+
* Recent mempool transactions
|
|
9741
|
+
*
|
|
9742
|
+
* Get the last 10 transactions to enter the mempool.
|
|
9743
|
+
*
|
|
9744
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mempool-recent)*
|
|
9745
|
+
*
|
|
9746
|
+
* Endpoint: `GET /api/mempool/recent`
|
|
9747
|
+
* @returns {Promise<MempoolRecentTx[]>}
|
|
9748
|
+
*/
|
|
9749
|
+
async getMempoolRecent() {
|
|
9750
|
+
return this.getJson(`/api/mempool/recent`);
|
|
9751
|
+
}
|
|
9752
|
+
|
|
9510
9753
|
/**
|
|
9511
9754
|
* Mempool transaction IDs
|
|
9512
9755
|
*
|
|
@@ -9847,12 +10090,44 @@ class BrkClient extends BrkClientBase {
|
|
|
9847
10090
|
* Endpoint: `GET /api/tx/{txid}/hex`
|
|
9848
10091
|
*
|
|
9849
10092
|
* @param {Txid} txid
|
|
9850
|
-
* @returns {Promise
|
|
10093
|
+
* @returns {Promise<*>}
|
|
9851
10094
|
*/
|
|
9852
10095
|
async getTxHex(txid) {
|
|
9853
10096
|
return this.getJson(`/api/tx/${txid}/hex`);
|
|
9854
10097
|
}
|
|
9855
10098
|
|
|
10099
|
+
/**
|
|
10100
|
+
* Transaction merkle proof
|
|
10101
|
+
*
|
|
10102
|
+
* Get the merkle inclusion proof for a transaction.
|
|
10103
|
+
*
|
|
10104
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-merkle-proof)*
|
|
10105
|
+
*
|
|
10106
|
+
* Endpoint: `GET /api/tx/{txid}/merkle-proof`
|
|
10107
|
+
*
|
|
10108
|
+
* @param {Txid} txid
|
|
10109
|
+
* @returns {Promise<MerkleProof>}
|
|
10110
|
+
*/
|
|
10111
|
+
async getTxMerkleProof(txid) {
|
|
10112
|
+
return this.getJson(`/api/tx/${txid}/merkle-proof`);
|
|
10113
|
+
}
|
|
10114
|
+
|
|
10115
|
+
/**
|
|
10116
|
+
* Transaction merkleblock proof
|
|
10117
|
+
*
|
|
10118
|
+
* Get the merkleblock proof for a transaction (BIP37 format, hex encoded).
|
|
10119
|
+
*
|
|
10120
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-merkleblock-proof)*
|
|
10121
|
+
*
|
|
10122
|
+
* Endpoint: `GET /api/tx/{txid}/merkleblock-proof`
|
|
10123
|
+
*
|
|
10124
|
+
* @param {Txid} txid
|
|
10125
|
+
* @returns {Promise<*>}
|
|
10126
|
+
*/
|
|
10127
|
+
async getTxMerkleblockProof(txid) {
|
|
10128
|
+
return this.getJson(`/api/tx/${txid}/merkleblock-proof`);
|
|
10129
|
+
}
|
|
10130
|
+
|
|
9856
10131
|
/**
|
|
9857
10132
|
* Output spend status
|
|
9858
10133
|
*
|
|
@@ -9886,6 +10161,22 @@ class BrkClient extends BrkClientBase {
|
|
|
9886
10161
|
return this.getJson(`/api/tx/${txid}/outspends`);
|
|
9887
10162
|
}
|
|
9888
10163
|
|
|
10164
|
+
/**
|
|
10165
|
+
* Transaction raw
|
|
10166
|
+
*
|
|
10167
|
+
* Returns a transaction as binary data.
|
|
10168
|
+
*
|
|
10169
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-raw)*
|
|
10170
|
+
*
|
|
10171
|
+
* Endpoint: `GET /api/tx/{txid}/raw`
|
|
10172
|
+
*
|
|
10173
|
+
* @param {Txid} txid
|
|
10174
|
+
* @returns {Promise<number[]>}
|
|
10175
|
+
*/
|
|
10176
|
+
async getTxRaw(txid) {
|
|
10177
|
+
return this.getJson(`/api/tx/${txid}/raw`);
|
|
10178
|
+
}
|
|
10179
|
+
|
|
9889
10180
|
/**
|
|
9890
10181
|
* Transaction status
|
|
9891
10182
|
*
|
|
@@ -9902,10 +10193,72 @@ class BrkClient extends BrkClientBase {
|
|
|
9902
10193
|
return this.getJson(`/api/tx/${txid}/status`);
|
|
9903
10194
|
}
|
|
9904
10195
|
|
|
10196
|
+
/**
|
|
10197
|
+
* Block (v1)
|
|
10198
|
+
*
|
|
10199
|
+
* Returns block details with extras by hash.
|
|
10200
|
+
*
|
|
10201
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-block-v1)*
|
|
10202
|
+
*
|
|
10203
|
+
* Endpoint: `GET /api/v1/block/{hash}`
|
|
10204
|
+
*
|
|
10205
|
+
* @param {BlockHash} hash
|
|
10206
|
+
* @returns {Promise<BlockInfoV1>}
|
|
10207
|
+
*/
|
|
10208
|
+
async getBlockV1(hash) {
|
|
10209
|
+
return this.getJson(`/api/v1/block/${hash}`);
|
|
10210
|
+
}
|
|
10211
|
+
|
|
10212
|
+
/**
|
|
10213
|
+
* Recent blocks with extras
|
|
10214
|
+
*
|
|
10215
|
+
* Retrieve the last 10 blocks with extended data including pool identification and fee statistics.
|
|
10216
|
+
*
|
|
10217
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-blocks-v1)*
|
|
10218
|
+
*
|
|
10219
|
+
* Endpoint: `GET /api/v1/blocks`
|
|
10220
|
+
* @returns {Promise<BlockInfoV1[]>}
|
|
10221
|
+
*/
|
|
10222
|
+
async getBlocksV1() {
|
|
10223
|
+
return this.getJson(`/api/v1/blocks`);
|
|
10224
|
+
}
|
|
10225
|
+
|
|
10226
|
+
/**
|
|
10227
|
+
* Blocks from height with extras
|
|
10228
|
+
*
|
|
10229
|
+
* Retrieve up to 10 blocks with extended data going backwards from the given height.
|
|
10230
|
+
*
|
|
10231
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-blocks-v1)*
|
|
10232
|
+
*
|
|
10233
|
+
* Endpoint: `GET /api/v1/blocks/{height}`
|
|
10234
|
+
*
|
|
10235
|
+
* @param {Height} height
|
|
10236
|
+
* @returns {Promise<BlockInfoV1[]>}
|
|
10237
|
+
*/
|
|
10238
|
+
async getBlocksV1FromHeight(height) {
|
|
10239
|
+
return this.getJson(`/api/v1/blocks/${height}`);
|
|
10240
|
+
}
|
|
10241
|
+
|
|
10242
|
+
/**
|
|
10243
|
+
* CPFP info
|
|
10244
|
+
*
|
|
10245
|
+
* Returns ancestors and descendants for a CPFP transaction.
|
|
10246
|
+
*
|
|
10247
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-children-pay-for-parent)*
|
|
10248
|
+
*
|
|
10249
|
+
* Endpoint: `GET /api/v1/cpfp/{txid}`
|
|
10250
|
+
*
|
|
10251
|
+
* @param {Txid} txid
|
|
10252
|
+
* @returns {Promise<CpfpInfo>}
|
|
10253
|
+
*/
|
|
10254
|
+
async getCpfp(txid) {
|
|
10255
|
+
return this.getJson(`/api/v1/cpfp/${txid}`);
|
|
10256
|
+
}
|
|
10257
|
+
|
|
9905
10258
|
/**
|
|
9906
10259
|
* Difficulty adjustment
|
|
9907
10260
|
*
|
|
9908
|
-
* Get current difficulty adjustment
|
|
10261
|
+
* Get current difficulty adjustment progress and estimates.
|
|
9909
10262
|
*
|
|
9910
10263
|
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-difficulty-adjustment)*
|
|
9911
10264
|
*
|
|
@@ -9919,7 +10272,7 @@ class BrkClient extends BrkClientBase {
|
|
|
9919
10272
|
/**
|
|
9920
10273
|
* Projected mempool blocks
|
|
9921
10274
|
*
|
|
9922
|
-
* Get projected blocks from the mempool for fee estimation.
|
|
10275
|
+
* Get projected blocks from the mempool for fee estimation.
|
|
9923
10276
|
*
|
|
9924
10277
|
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mempool-blocks-fees)*
|
|
9925
10278
|
*
|
|
@@ -9930,10 +10283,24 @@ class BrkClient extends BrkClientBase {
|
|
|
9930
10283
|
return this.getJson(`/api/v1/fees/mempool-blocks`);
|
|
9931
10284
|
}
|
|
9932
10285
|
|
|
10286
|
+
/**
|
|
10287
|
+
* Precise recommended fees
|
|
10288
|
+
*
|
|
10289
|
+
* Get recommended fee rates with up to 3 decimal places.
|
|
10290
|
+
*
|
|
10291
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-recommended-fees-precise)*
|
|
10292
|
+
*
|
|
10293
|
+
* Endpoint: `GET /api/v1/fees/precise`
|
|
10294
|
+
* @returns {Promise<RecommendedFees>}
|
|
10295
|
+
*/
|
|
10296
|
+
async getPreciseFees() {
|
|
10297
|
+
return this.getJson(`/api/v1/fees/precise`);
|
|
10298
|
+
}
|
|
10299
|
+
|
|
9933
10300
|
/**
|
|
9934
10301
|
* Recommended fees
|
|
9935
10302
|
*
|
|
9936
|
-
* Get recommended fee rates for different confirmation targets
|
|
10303
|
+
* Get recommended fee rates for different confirmation targets.
|
|
9937
10304
|
*
|
|
9938
10305
|
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-recommended-fees)*
|
|
9939
10306
|
*
|
|
@@ -9944,6 +10311,26 @@ class BrkClient extends BrkClientBase {
|
|
|
9944
10311
|
return this.getJson(`/api/v1/fees/recommended`);
|
|
9945
10312
|
}
|
|
9946
10313
|
|
|
10314
|
+
/**
|
|
10315
|
+
* Historical price
|
|
10316
|
+
*
|
|
10317
|
+
* Get historical BTC/USD price. Optionally specify a UNIX timestamp to get the price at that time.
|
|
10318
|
+
*
|
|
10319
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-historical-price)*
|
|
10320
|
+
*
|
|
10321
|
+
* Endpoint: `GET /api/v1/historical-price`
|
|
10322
|
+
*
|
|
10323
|
+
* @param {Timestamp=} [timestamp]
|
|
10324
|
+
* @returns {Promise<HistoricalPrice>}
|
|
10325
|
+
*/
|
|
10326
|
+
async getHistoricalPrice(timestamp) {
|
|
10327
|
+
const params = new URLSearchParams();
|
|
10328
|
+
if (timestamp !== undefined) params.set('timestamp', String(timestamp));
|
|
10329
|
+
const query = params.toString();
|
|
10330
|
+
const path = `/api/v1/historical-price${query ? '?' + query : ''}`;
|
|
10331
|
+
return this.getJson(path);
|
|
10332
|
+
}
|
|
10333
|
+
|
|
9947
10334
|
/**
|
|
9948
10335
|
* Block fee rates (WIP)
|
|
9949
10336
|
*
|
|
@@ -10068,6 +10455,36 @@ class BrkClient extends BrkClientBase {
|
|
|
10068
10455
|
return this.getJson(`/api/v1/mining/hashrate`);
|
|
10069
10456
|
}
|
|
10070
10457
|
|
|
10458
|
+
/**
|
|
10459
|
+
* All pools hashrate (all time)
|
|
10460
|
+
*
|
|
10461
|
+
* Get hashrate data for all mining pools.
|
|
10462
|
+
*
|
|
10463
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mining-pool-hashrates)*
|
|
10464
|
+
*
|
|
10465
|
+
* Endpoint: `GET /api/v1/mining/hashrate/pools`
|
|
10466
|
+
* @returns {Promise<PoolHashrateEntry[]>}
|
|
10467
|
+
*/
|
|
10468
|
+
async getPoolsHashrate() {
|
|
10469
|
+
return this.getJson(`/api/v1/mining/hashrate/pools`);
|
|
10470
|
+
}
|
|
10471
|
+
|
|
10472
|
+
/**
|
|
10473
|
+
* All pools hashrate
|
|
10474
|
+
*
|
|
10475
|
+
* Get hashrate data for all mining pools for a time period. Valid periods: 1m, 3m, 6m, 1y, 2y, 3y
|
|
10476
|
+
*
|
|
10477
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mining-pool-hashrates)*
|
|
10478
|
+
*
|
|
10479
|
+
* Endpoint: `GET /api/v1/mining/hashrate/pools/{time_period}`
|
|
10480
|
+
*
|
|
10481
|
+
* @param {TimePeriod} time_period
|
|
10482
|
+
* @returns {Promise<PoolHashrateEntry[]>}
|
|
10483
|
+
*/
|
|
10484
|
+
async getPoolsHashrateByPeriod(time_period) {
|
|
10485
|
+
return this.getJson(`/api/v1/mining/hashrate/pools/${time_period}`);
|
|
10486
|
+
}
|
|
10487
|
+
|
|
10071
10488
|
/**
|
|
10072
10489
|
* Network hashrate
|
|
10073
10490
|
*
|
|
@@ -10100,6 +10517,55 @@ class BrkClient extends BrkClientBase {
|
|
|
10100
10517
|
return this.getJson(`/api/v1/mining/pool/${slug}`);
|
|
10101
10518
|
}
|
|
10102
10519
|
|
|
10520
|
+
/**
|
|
10521
|
+
* Mining pool blocks
|
|
10522
|
+
*
|
|
10523
|
+
* Get the 10 most recent blocks mined by a specific pool.
|
|
10524
|
+
*
|
|
10525
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mining-pool-blocks)*
|
|
10526
|
+
*
|
|
10527
|
+
* Endpoint: `GET /api/v1/mining/pool/{slug}/blocks`
|
|
10528
|
+
*
|
|
10529
|
+
* @param {PoolSlug} slug
|
|
10530
|
+
* @returns {Promise<BlockInfoV1[]>}
|
|
10531
|
+
*/
|
|
10532
|
+
async getPoolBlocks(slug) {
|
|
10533
|
+
return this.getJson(`/api/v1/mining/pool/${slug}/blocks`);
|
|
10534
|
+
}
|
|
10535
|
+
|
|
10536
|
+
/**
|
|
10537
|
+
* Mining pool blocks from height
|
|
10538
|
+
*
|
|
10539
|
+
* Get 10 blocks mined by a specific pool before (and including) the given height.
|
|
10540
|
+
*
|
|
10541
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mining-pool-blocks)*
|
|
10542
|
+
*
|
|
10543
|
+
* Endpoint: `GET /api/v1/mining/pool/{slug}/blocks/{height}`
|
|
10544
|
+
*
|
|
10545
|
+
* @param {PoolSlug} slug
|
|
10546
|
+
* @param {Height} height
|
|
10547
|
+
* @returns {Promise<BlockInfoV1[]>}
|
|
10548
|
+
*/
|
|
10549
|
+
async getPoolBlocksFrom(slug, height) {
|
|
10550
|
+
return this.getJson(`/api/v1/mining/pool/${slug}/blocks/${height}`);
|
|
10551
|
+
}
|
|
10552
|
+
|
|
10553
|
+
/**
|
|
10554
|
+
* Mining pool hashrate
|
|
10555
|
+
*
|
|
10556
|
+
* Get hashrate history for a specific mining pool.
|
|
10557
|
+
*
|
|
10558
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-mining-pool-hashrate)*
|
|
10559
|
+
*
|
|
10560
|
+
* Endpoint: `GET /api/v1/mining/pool/{slug}/hashrate`
|
|
10561
|
+
*
|
|
10562
|
+
* @param {PoolSlug} slug
|
|
10563
|
+
* @returns {Promise<PoolHashrateEntry[]>}
|
|
10564
|
+
*/
|
|
10565
|
+
async getPoolHashrate(slug) {
|
|
10566
|
+
return this.getJson(`/api/v1/mining/pool/${slug}/hashrate`);
|
|
10567
|
+
}
|
|
10568
|
+
|
|
10103
10569
|
/**
|
|
10104
10570
|
* List all mining pools
|
|
10105
10571
|
*
|
|
@@ -10146,6 +10612,34 @@ class BrkClient extends BrkClientBase {
|
|
|
10146
10612
|
return this.getJson(`/api/v1/mining/reward-stats/${block_count}`);
|
|
10147
10613
|
}
|
|
10148
10614
|
|
|
10615
|
+
/**
|
|
10616
|
+
* Current BTC price
|
|
10617
|
+
*
|
|
10618
|
+
* Returns bitcoin latest price (on-chain derived, USD only).
|
|
10619
|
+
*
|
|
10620
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-price)*
|
|
10621
|
+
*
|
|
10622
|
+
* Endpoint: `GET /api/v1/prices`
|
|
10623
|
+
* @returns {Promise<Prices>}
|
|
10624
|
+
*/
|
|
10625
|
+
async getPrices() {
|
|
10626
|
+
return this.getJson(`/api/v1/prices`);
|
|
10627
|
+
}
|
|
10628
|
+
|
|
10629
|
+
/**
|
|
10630
|
+
* Transaction first-seen times
|
|
10631
|
+
*
|
|
10632
|
+
* Returns timestamps when transactions were first seen in the mempool. Returns 0 for mined or unknown transactions.
|
|
10633
|
+
*
|
|
10634
|
+
* *[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-times)*
|
|
10635
|
+
*
|
|
10636
|
+
* Endpoint: `GET /api/v1/transaction-times`
|
|
10637
|
+
* @returns {Promise<number[]>}
|
|
10638
|
+
*/
|
|
10639
|
+
async getTransactionTimes() {
|
|
10640
|
+
return this.getJson(`/api/v1/transaction-times`);
|
|
10641
|
+
}
|
|
10642
|
+
|
|
10149
10643
|
/**
|
|
10150
10644
|
* Validate address
|
|
10151
10645
|
*
|
package/package.json
CHANGED