fix(psf-slp-indexer): Adding block height forecast to unconfirmed non-SLP TXs

This commit is contained in:
Chris Troutner
2026-01-15 16:23:47 -07:00
parent b1745d37e0
commit 2e88d26ff2
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -12,6 +12,7 @@ import axios from 'axios'
// Local libraries
import RawTransaction from './raw-transactions.js'
import SlpUtils from './slp/utils.js'
import Blockchain from './blockchain.js'
// let _this
@@ -31,6 +32,7 @@ class PsfSlpIndexer {
// Encapsulate dependencies
this.rawTransaction = new RawTransaction(config)
this.slpUtils = new SlpUtils(config)
this.blockchain = new Blockchain(config)
}
/**
@@ -317,6 +319,22 @@ class PsfSlpIndexer {
const txDetails = await this.rawTransaction.getTxData(txid)
// console.log(`txDetails: ${JSON.stringify(txDetails, null, 2)}`)
// Add blockheight, height, time, and blocktime to the txDetails object.
if (txDetails.height === null) {
// Get current block height and increment by 1
const currentBlockHeight = await this.blockchain.getBlockCount()
const estimatedHeight = currentBlockHeight + 1
// Set height and blockheight
txDetails.height = estimatedHeight
txDetails.blockheight = estimatedHeight
// Set time and blocktime to current unix timestamp
const currentTime = Math.floor(Date.now() / 1000)
txDetails.time = currentTime
txDetails.blocktime = currentTime
}
if (isInBlacklist) {
txDetails.isValidSlp = null
} else {
+1 -1
View File
@@ -18,7 +18,7 @@ describe('#price', () => {
})
describe('#getPsffppPrice', () => {
it('should get the price of BCH in several currencies', async () => {
it('should get the price to write 1MB to the PSFFPP', async () => {
const result = await bchjs.Price.getPsffppPrice()
// console.log(result)