Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: myfy on April 26, 2024, 01:44:08 PM



Title: How do I find the information of the Bitcoin protocol version
Post by: myfy on April 26, 2024, 01:44:08 PM
Hello

I want to broadcast Bitcoin transactions using python's socket library.Now I can sign a transaction. But when sock is used to link other nodes, it is not known what information should be transmitted.The node I am linking to is protocol version 70016.I tried to find information on bitcoin.org.

This is the site I was looking for:
https://developer.bitcoin.org/reference/p2p_networking.html#protocol-versions

But it doesn't show how protocol 70016 works.I want to know which website I should visit for the 70016 version of the Bitcoin protocol.


Title: Re: How do I find the information of the Bitcoin protocol version
Post by: Cricktor on April 27, 2024, 09:44:02 PM
Sorry, if my post is sort of off-topic when you ask such a specific question. I'm no Python coder but there should be some already existing libraries and modules to do that. Do you have specific needs to use the socket lib?

A non-extensive search gave me some hits that look promissing (I had a quick look into each search result, but not more than that):

https://medium.com/coinmonks/how-to-make-a-bitcoin-transaction-with-python-450d7d3db864 (https://medium.com/coinmonks/how-to-make-a-bitcoin-transaction-with-python-450d7d3db864) --- seems incomplete
https://github.com/slush0/sendtx (https://github.com/slush0/sendtx)
https://bitcoinlib.readthedocs.io/en/latest/ (https://bitcoinlib.readthedocs.io/en/latest/) --- you need a Bitcoin node, preferably local
A from-scratch tour of Bitcoin in Python (http://karpathy.github.io/2021/06/21/blockchain/) --- maybe worth looking into how tx are actually send out
...

There's certainly more to find. I don't see this as my duty, improve your searching skills. Have a look at this thread as another find, I'm pretty confident there're more sources in this forum, too:
Make a bitcoin transaction with python? (https://bitcointalk.org/index.php?topic=5396894.msg60021668#msg60021668)


Title: Re: How do I find the information of the Bitcoin protocol version
Post by: pooya87 on April 28, 2024, 04:51:55 AM
I want to broadcast Bitcoin transactions using python's socket library.
If that's all you want to do, you need not concern yourself with the protocol version. Majority of these versions (https://github.com/bitcoin/bitcoin/blob/master/src/node/protocol_version.h) are defining stuff that concerns a full node not what you want to do.

The process you're looking for is like it's always been:
1. Open socket and connect to the peer using its IP address and port
2. Perform handshare (Send version, receive version and verack, send verack)
3. Push your tx in a tx message

The three message types and their structures on explained in the link you shared.
https://developer.bitcoin.org/reference/p2p_networking.html#version
https://developer.bitcoin.org/reference/p2p_networking.html#verack
https://developer.bitcoin.org/reference/p2p_networking.html#tx

FWIW protocol version 70016 introduced wtxid-based relay and nodes that have that version support this feature.