[zeromq-dev] How to get transactions from bitcoind?

Andy borucki.andrzej at gmail.com
Thu Jan 12 09:57:07 CET 2017


Python version is here:
https://github.com/bitcoin/bitcoin/blob/master/contrib/zmq/zmq_sub.py
I try to write C++ version using zeroMQ and wrapper
https://github.com/alanw/zmqcpp

#include <stdexcept>
#include <iostream>
#include <cstdlib>
#include <cstring>

#include "zmq.hpp"

int main(int argc, char **argv) {
    zmq::context_t context(1);
    zmq::socket_t socket(context, ZMQ_SUB);
    socket.setsockopt(ZMQ_SUBSCRIBE, "hashblock");
    socket.setsockopt(ZMQ_SUBSCRIBE, "hashtx");
    socket.setsockopt(ZMQ_SUBSCRIBE, "rawblock");
    socket.setsockopt(ZMQ_SUBSCRIBE, "rawtx");
    socket.connect("tcp://127.0.0.1:28332");
    zmq::message_t msg;
//    char buf[80];
    socket.recv(&msg,0); //<--here is blocked !
    return 0;
}

Code above is similar to Python code, but I don;t know how to receive
data to console

Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20170112/91e53dd2/attachment.htm>


More information about the zeromq-dev mailing list