bitpay / insight-api

The bitcoin blockchain API powering Insight
https://github.com/bitpay/insight
590 stars 1.04k forks source link

Any way to listen for a single address via websocket? #562

Open adangert opened 6 years ago

adangert commented 6 years ago

currently I only have this which seems to send every transaction, rather than a single address.

var eventToListenTo = 'tx' var room = 'inv' var socket = io("https://blockdozer.com/"); socket.on('connect', function() { // Join the room. socket.emit('subscribe', room); }) socket.on(eventToListenTo, function(data) { console.log(data); })

adangert commented 6 years ago

This also does not work, this is one of my bitcoin cash addresses

                 var room = 'qr9x435hmf5p0r2m35mjwq2tslce6p0tnctp0datec';
                 var eventToListenTo = 'qr9x435hmf5p0r2m35mjwq2tslce6p0tnctp0datec';

                  var socket = io("https://bch-insight.bitpay.com");
                  socket.on('connect', function() {
                    // Join the room.
                    socket.emit('subscribe', room);

                  })
                  socket.on(eventToListenTo, function(data) {
                    console.log("New transaction received: ");
                    console.log(data);

                  })
jimtendo commented 6 years ago

Would also like to know if this is possible as I've tried the above with both legacy and cashaddr with no success. The documentation seems to indicate that this is possible, but I cannot see where this might take place in the code.

aravind-ig commented 6 years ago

socket.on('bitcoind/addresstxid', data => console.log('new address data:', data)) socket.on('connect', () => socket.emit('subscribe', 'bitcoind/addresstxid', [ 'my_address_here' ])) This code above works for test-insight.bitpay.com but not for the Insight Node I set up. The socket connects and all other events are received well except for the room. My Insight Node : Version | 110200 Protocol version | 70002

parikshitsharma70 commented 5 years ago

Facing the same issue with bitcoin addresses, on my own insight node. Would immensely appreciate any help from the developers!

aravind-ig commented 5 years ago

@parikshitsharma70 socket.emit('subscribe', 'bitcoind/addresstxid', [ "btc_address_to_listen" ]) socket.on('bitcoind/addresstxid', function (data) { console.log('New Tx in that address : ', data) // you'll receive the transactions involving that address alone }) And also make sure, insight-api version >= 0.4.3

parikshitsharma70 commented 5 years ago

Thanks a lot, I figured this out eventually. Their docs need to be updated immediately, such a waste of time.

thackerronak commented 5 years ago

@parikshitsharma70 socket.emit('subscribe', 'bitcoind/addresstxid', [ "btc_address_to_listen" ]) socket.on('bitcoind/addresstxid', function (data) { console.log('New Tx in that address : ', data) // you'll receive the transactions involving that address alone }) And also make sure, insight-api version >= 0.4.3

is it working with bitcoin cash?