I am having hassle receiving WebSocket messages for address-related occasions. Right here is the code that I am utilizing (trackAddress will get referred to as externally and I am certain it sends the best factor). I additionally tried from an internet WebSocket consumer (as seen within the photograph) and the response to ping_tx is just not the best transaction (the docs state that if you’re subscribed to an deal with it could be that deal with’s final transaction), as a substitute, it returns the newest on the entire community. It is actually irritating however I don’t perceive what it’s that I’m doing mistaken. It is as if I am by no means actually subscribing to it…
You possibly can see the transaction right here: https://www.blockchain.com/explorer/addresses/btc/1P8wXFz6F7UdqnfsByZUf6tBxukcp9bJE9
import { WebSocket } from "ws"
const ws = new WebSocket("wss://ws.blockchain.data/inv")
setInterval(() => {
ws.ping()
}, 30000)
ws.on("open", async() => {
console.log(`Listener related to ${ws.url}`)
})
ws.on("shut", () => {
console.log("Listener disconnected")
})
ws.on("message", (information => {
const res = JSON.parse(information.toString())
console.log(res)
}))
export const trackAddress = (deal with: string) => {
console.log(`Monitoring deal with ${deal with}`)
ws.ship(JSON.stringify({
op: "addr_sub",
addr: deal with
}))
}