Hot answers tagged

22

ZeroMQ is a publisher / subscriber messaging system. In the case of Bitcoin Core it is a socket which other applications can connect to and get notifications of new events in real time, without having to repeatedly ask the daemon if there are any new events. ZMQ support is useful for any systems interfacing with the network like miners and wallets, which can ...


5

This will happen when you try to build with ZMQ support even though the required libraries are not on your system. In this case, configure will silently turn off ZMQ support, and you should see a line like configure: WARNING: libzmq version 4.x or greater not found, disabling in the output. When you install the required version of the ZMQ library on your ...


5

You should have a file named config.log in your Bitcoin Core working directory. Look in the file for ZMQ related lines. If ZMQ is enabled, you should see things like #define ENABLE_ZMQ 1. If it is not enabled, you should see things like #define ENABLE_ZMQ 0.


4

The PPA you have installed (https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin/+packages) is not compiled with ZMQ support (It should in future). You need to self-compile bitcoin v0.13.0 or use one of the "official" binaries: https://bitcoin.org/bin/bitcoin-core-0.13.0/ EDIT: since 0.14, ZMQ support is available via the PPA


4

As this question is related to executable compilation which has to do with linking (static or dynamic), therefore the ultimate way to know if your compiled bitcoind executable has been compiled with 0mq support is simply: ldd /usr/bin/bitcoind | grep -i mq


3

What do you mean by "decode"? A hash algorithm is a one-way function. The hash-function takes some block header information (timestamp, nonce, a hash of all transactions) and returns such a hexadecimal value. There is no way to "decode" such a hash. Its reason is just to identify a unique block (and deciding wheather someone gets the block reward or not). ...


3

These are indeed hard problems, but luckily already served by BTCPay Server, with extra features like lightning payments: https://github.com/btcpayserver/btcpayserver. You can just run it via the included docker recipe (https://github.com/btcpayserver/btcpayserver-docker) and communicate with it via its API. Or if you really want to reimplement the nitty ...


3

A tx will only be included in a single block in any given blockchain. Confirmations is simply a count of how many new blocks extend the chain. If your tx is in block n, it has 1 confirmation. When block n+1 is mined, you need to check that the prevblockhash is the hash of block n. If it is, you now have 2 confirmations, since the chain has been mined. ...


3

Actually, it's pretty much possible! You will have to listen for rawtx topic of ZeroMQ in order to retrieve binary representation of the transaction descriptor. Then you should parse the transaction body and extract Bitcoin addresses from it's output scripts. You could either do this manually, or use some third-party library. No need to make RPC calls! ...


3

Your best bet is to run a bitcoind node locally and then connect to it using zmq (ZeroMQ). Pulling it from anywhere else means you're trusting someone else and the data can easily be corrupted. Also blockchain.info has a horrible track record of being wrong and being down very often.


2

It is not specified what to subscribe. socket.connect("tcp://127.0.0.1:28332") socket.subscribe("hashtx"); # if you need raw data or block data, to add-> socket.subscribe("hashblock"); socket.subscribe("rawblock"); socket.subscribe("rawtx"); see. https://github.com/bitcoin/bitcoin/blob/master/contrib/zmq/zmq_sub.py


2

After some investigation, I found out that RAW topics actually include entire body of transaction/block descriptor. See, Raw Transactions. Actually, you could explore the transaction descriptor content in JSON format by first converting binary data to HEX-string and then by pasting it to the blockchain.info tool or by using RPC call of bitcoind: ...


2

I am speculating, at this point, that these transactions that have no time associated with them are unconfirmed? Is this understanding correct? Yes. The Bitcoin.org Developer Reference explains: The reason for this is that transaction themselves don't contain a time field, so the only times that can be used are either (1) when the node first received ...


2

Bitcoin Core does not give you strings for the data from ZMQ. It provides the raw bytes of the transactions, blocks, and their hashes. You will need to interpret the received data as byte arrays and handle them appropriately.


2

I believe what merklexy wanted to know is how to get information about the block. And the answer is, you cannot get details about the block from its hash. If you have access to the bitcoin command line interface (bitcoin-cli) then you can simply execute bitcoin-cli getblock 00000000000000000045c639280aee532c5b12b03c80bfdec7aae674fd8246e0


1

I don't believe there is a direct way to do this via ZeroMQ. Your best bet would be to validate the ancestry for each block as you receive it. When you receive a block, check its parent hash against blocks you have already seen. If the parent chain validates and you do not have another, longer child chain from the parent block already, you can accept this ...


1

@PieterWuille is right, it is really not related to bitcoin but to ZeroMQ and docker. I look into the source code and bitcoin core uses zmq_bind( socket, bindingAddress ). For BindingAddress, I can change it to tcp://*:28332 because callers from another containers or from host would have different IPs, so the most convenient way is to set it to a range of ...


1

No, it is not possible to catch up via ZMQ itself. A sequence number is present with each notification so you can detect when you've missed notifications. In those cases, then you can fetch the missing blocks and transactions over the RPC interface.


1

Raghav Sood: you are right: here the correct code: const addresses = bitcoinjs.address.fromOutputScript(outputScript, bitcoinjs.networks.testnet); Thanks :-)


1

You need to parse the script and get to the script type by examining the opcodes. If you examine the rpc/rawtransaction.cpp source file on Bitcoin Core you'll see the RPC call that outputs this is getrawtransaction(). Tracing it further it leads us to ScriptPubKeyToUniv in core_write.cpp which calls so let's take a look at that: const char* ...


1

Internally, Bitcoin does not have the concept of scriptPubKey type. To the system, scriptPubKey is simply a mathematical equation into which some bitcoins have been locked (UTXO) and the spender must satisfy the unlocking conditions, which most of the times are the signature(s) and public key(s), in order to spend those bitcoins. These basic construct can be ...


1

I believe that your configs are ok, but when you launch lnd with the command like flags, you overwrite one parameter to a broken value. Specifically, I am talking about the flag --bitcoind.zmqpubrawtx=8332, which should be --bitcoind.zmqpubrawtx=127.0.0.1:28333 instead.


1

If I understand this correctly, you're trying to communicate with Bitcoin Core through ZeroMQ directly from the browser. This is not possible. The reason why JSMQ only supports Websockets (ws://) is that browsers don't allow you to use raw TCP sockets. The only protocols you can access from within the browser are HTTP(S), Websockets, and WebRTC (which is ...


1

Ok so i found the solution. The "hashtx, hashblock" etc messages are sent as raw binary bytes which then need to be converted to hexadecimal. Here is my code. public static void main(String[] args) { ZMQ.Context context = ZMQ.context(1); // Connect our subscriber socket ZMQ.Socket subscriber = context.socket(ZMQ.SUB); // Synchronize with ...


1

Try to subscribe by using prefix raw as topic . After this you will get both message on the one listener. socket.subscribe('raw'); socket.on('message', (topicRaw: Buffer, bodyRaw: Buffer, ...tailRaw: Buffer[]) => { const sequenceRaw = tailRaw[tailRaw.length - 1]; const sequence = sequenceRaw.readInt32LE(0); const topic = topicRaw.toString();...


1

With the current Bitcoin Core Version (0.14.2 by the time of writing), this is not possible. A quick hack in CZMQNotificationInterface::SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int posInBlock) would be simple (just add an if (!pindex)). If you don't want to change the sources, you could call gettransaction over RPC and get the ...


1

First ensure, that is 28332 port used: -zmqpubhashtx=tcp://127.0.0.1:28332 bitcoind parameter, next call python zmq_sub.py. This should work


1

I'm pretty much doing the same thing. I recommend you to use distributed cache services such as Redis for your addresses' storage and query against that database.


1

So after some investigations I realized that ZMQ support is not present on the latest tag on the repo (this line was in charge of giving me the latest tag). So I think that my problem is by now resolved by using master as building branch. Thanks at all, Dario.


Only top voted, non community-wiki answers of a minimum length are eligible