0
I installed the binary and try to listen to ZeroMQ stream. But I got nothing out. Then I installed ZeroMQ but still got nothing.
https://bitcoin.org/en/release/v0.17.1
so, are official bitcoin core releases compiled with zmq in general?
bitcoin.conf
listen=1
upnp=0
txindex=1
maxconnections=40
server=1
rpcthreads=4
rpcuser=alice
rpcpassword=alice
rpcauth=xxxxx
rpcallowip=0.0.0.0/0
rpctimeout=30
txconfirmtarget=6
mempoolexpiry=72
maxmempool=300
maxorphantx=100
debug=rpc
logips=1
limitfreerelay=10
minrelaytxfee=0.0001
zmqpubhashblock=tcp://127.0.0.1:28332
zmqpubhashtx=tcp://127.0.0.1:28333
[main]
rpcbind=192.168.1.107
[test]
rpcbind=0.0.0.0
[regtest]
rpcbind=0.0.0.0
I found this article https://bitcoin.stackexchange.com/a/65066/33448
but there is no such file config.log. but I did install successfully with apt-get --yes install libzmq3-dev
docker-compose.yml
....
bitcoincore:
image: bitcoincore
networks:
- my-network
build:
context: bitcoinCore/
volumes:
- shared:/rpc
ports:
- 8332:8332
- 8333:8333
- 18332:18332
- 18333:18333
- 18443:18443
- 18444:18444
- 28332:28332
- 28333:28333
....
net stat -pant
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:18332 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:18333 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.11:35491 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:28332 <--- 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:28333 <--- 0.0.0.0:* LISTEN -
tcp 0 0 172.22.0.2:38722 31.220.15.89:18333 ESTABLISHED -
tcp 0 0 172.22.0.2:60910 193.31.24.45:18333 TIME_WAIT -
tcp 0 0 172.22.0.2:40730 159.203.125.125:18333 ESTABLISHED -
tcp 0 0 172.22.0.2:60938 54.162.188.154:18333 ESTABLISHED -
tcp 0 0 127.0.0.1:58746 127.0.0.1:18332 TIME_WAIT -
tcp6 0 0 :::18333 :::* LISTEN -
getzmqnotifications(inside container)
# bitcoin-cli -testnet -rpcuser=alice -rpcpassword=alice getzmqnotifications
[
{
"type": "pubhashblock",
"address": "tcp://127.0.0.1:28332"
},
{
"type": "pubhashtx",
"address": "tcp://127.0.0.1:28333"
}
]
test RPC at host
$ curl --user alice:alice -H 'content-type:text/plain;' http://localhost:18332/ --data-binary '{"jsonrpc":"1.0","id":"1","method":"getmininginfo"}'
{"result":{"blocks":1348883,"currentblockweight":0,"currentblocktx":0,"difficulty":4194304,"networkhashps":48545593617877.57,"pooledtx":0,"chain":"test","warnings":""},"error":null,"id":"1"}
try to use lld to find out if dependency is ok, but no luck
# ldd /opt/bitcoin-0.17.1/bin/bitcoind
linux-vdso.so.1 (0x00007ffe29b6c000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6dd6f8c000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6dd6f82000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6dd6dff000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6dd6de5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6dd6c24000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6dd7c53000)
tester.js
var zmq = require('zeromq')
, sock = zmq.socket('sub')
, RpcClient = require('bitcoind-rpc')
, bitcoin = require("bitcoinjs-lib");
var config = {
protocol: 'http',
user: 'alice',
pass: 'alice',
host: 'localhost',
port: '18332',
};
var rpc = new RpcClient(config);
sock.connect('tcp://localhost:28333');
sock.on('message', function(topic, message) {
console.log(topic, message);
var tx = bitcoin.Transaction.fromHex(message)
if (!tx.isCoinbase()) {
rpc.generate(1, console.log)
console.log(topic, message)
}
})
// Subscribe to receive messages for a specific topic.
// This can be "hashblock", "hashtx", "rawtx", or "rawblock".
//sock.subscribe('rawtx');
sock.subscribe('hashtx');
rpc.getDifficulty( (err, data) => {
if (err) {
console.log(err);
return;
}
console.log('RPC working Ok; obtain difficulty as followed: ',data);
console.log('listening....');
});
Release binaries are statically linked, so the fact that you don't see a dependency on libzmq is not a surprise. It's also unnecessary to install anything as it's all built into the
bitcoindbinary. If it wasn't included you wouldn't be seeing the TCP listen on those ports. The fact that things don't work is probably due to an unrelated issue. – Pieter Wuille – 2019-11-20T20:22:06.737