0

I started to listen to the "wss://ws.blockchain.info/inv" websocket address in the link below, but none of the transactions I made were sent to the messages. Later, when I tried the blockcyper's websocket, all the transactions came. Currently, I am looking for a free websocket service, not a paid one.

https://www.blockchain.com/explorer/api/api_websocket

Vojtěch Strnad
  • 5,623
  • 1
  • 8
  • 31

1 Answers1

0

I had to solve the problem by listening to all transactions and checking the address as follows.

ws.addEventListener('open', () => {
    ws.send(JSON.stringify({
        "op": "unconfirmed_sub"
    }));
});

ws.addEventListener('message', (res) => {
    let data = JSON.parse(res.data);
    let outs = data.x.out;
    let out = outs.find(o => {
        return String(o.addr).toLowerCase() == receiver.toLowerCase();
    });
    if (out) {
        setTimeout(() => {
           startCallback(data);
        }, 6000);
    }
});