I'm having trouble receiving WebSocket messages for address-related events. Here is the code that I'm using (trackAddress gets called externally and I'm sure it sends the right thing). I also tried from an online WebSocket client (as seen in the photo) and the response to ping_tx is not the right transaction (the docs state that if you are subscribed to an address it would be that address's last transaction), instead, it returns the most recent on the whole network. It's really frustrating but I do not understand what it is that I am doing wrong. It's as if I'm never really subscribing to it...
You can see the transaction here: https://www.blockchain.com/explorer/addresses/btc/1P8wXFz6F7UdqnfsByZUf6tBxukcp9bJE9
import { WebSocket } from "ws"
const ws = new WebSocket("wss://ws.blockchain.info/inv")
setInterval(() => {
ws.ping()
}, 30000)
ws.on("open", async() => {
console.log(`Listener connected to ${ws.url}`)
})
ws.on("close", () => {
console.log("Listener disconnected")
})
ws.on("message", (data => {
const res = JSON.parse(data.toString())
console.log(res)
}))
export const trackAddress = (address: string) => {
console.log(`Tracking address ${address}`)
ws.send(JSON.stringify({
op: "addr_sub",
addr: address
}))
}