Bitcoin full node and query server

Jan 20, 2025

View in context in the libbitcoin Slack #general mirror.

neillm03:27
$ telnet mainnet.libbitcoin.net 9091
Trying 72.65.246.83...
Connected to mainnet.libbitcoin.net.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
19 replies · cguida, neillm · last Jan 28, 2025
C
cguida02:34
Does it respond to requests?
neillm02:21
It should. Let me know if it's not and I have to restart it
C
cguida02:32
Can you just try the python code I was trying?
C
cguida02:32
Would love to get a python example working :)
neillm02:34
Unfortunately, not at the moment. There should be some working python code somewhere (wiki?) -- I had some working as well at one point a while back. For now, I can use bx, which always works for me, but sometimes when it works for me, I am told it's not externally available and I don't know why, but I'm chalking it up to my router being strange
(edited)
neillm02:39
Ok, nevermind, I ran it just now:
$ python libbitcoin.py 
010000000181d06e4403b989d1e003def4944080e9537ef38e219f58a3856333050d72fe4a080000008b483045022100943e28772ef850587034b447a76c1eb918d63c82a4619a01a34cf32dee13807a02204cbe75c49f8ced0ebc373a6d8e7cb7ecab31369861d8997873b94bac13c379b3014104dbfb10dd8a498b3431f4c7041bbba82aa33146d40b7def4315e9e6df7424d527e762042f9fcc5450cbfc5f849bd3dace5cc9d9b3be8fadc3de92f96e303cf599ffffffff02a8101300000000001976a914b4dc57e35f93de9ec155872c1ad0136134fb08b188acbbe633000000000017a91461ec8bf07c6a3a04a08d1251d70178c1b3d273cc8700000000
neillm02:40
$ cat libbitcoin.py 
#!python3
import zmq
import struct
from binascii import hexlify, unhexlify

# Connect to the server.
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://mainnet.libbitcoin.net:9091")

# Make the request in parts.
socket.send(b'blockchain.fetch_transaction2', zmq.SNDMORE)
socket.send(struct.pack('I', 42), zmq.SNDMORE)
socket.send(unhexlify('60e030aba2f593caf913a7d96880ff227143bfc370d03dbaee37d582801ebd83')[::-1])

# Collect the response in parts.
response_command = socket.recv()
response_id = socket.recv()
response_body = socket.recv()

# Decode and print transaction from message payload.
print(hexlify(response_body[4:]).decode('ascii'))
🔥 1
C
cguida03:30
Oh, hell yeah, thanks! Yeah the wiki example was the one I tried that didn't work. I'll give this a whirl!
👍 1
C
cguida22:04
Hmm I just tried it and it doesn't work 😕
C
cguida22:04
Still just hanging on the response_command = socket.recv() line
C
cguida22:04
i tried putting it all in a python file like the one you have but it just hangs also
C
cguida22:54
Maybe i have the wrong version of python?
C
cguida22:54
$ python --version
Python 3.12.1
C
cguida22:55
or pyzmq?
$ pip freeze
pyzmq==26.2.0
neillm00:44
Can you reach the server's port 9091 (e.g. telnet)? That exact code is working for me using both python2 and python3, so I don't think the version is the issue
C
cguida00:47
Yes, the telnet command seems to connect, though I'm not sure what to send
neillm00:54
Hrm, I'm not sure then. I have had people report connectivity problems to this server in particular in the past even when it was up/responsive to me. Until I can get things moved to another server, I'm not sure what else to try at the moment
C
cguida02:50
maybe i can try some other tool besides python?
C
cguida02:50
maybe bx?
👍 1