Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Frodek on August 16, 2019, 07:49:40 AM



Title: "relayed_by" addres IP
Post by: Frodek on August 16, 2019, 07:49:40 AM
https://api.blockcypher.com/ has field "relayed_by"
How can be get this information, ZMQ gives me this info?


Title: Re: "relayed_by" addres IP
Post by: Frodek on August 16, 2019, 09:25:14 AM
IP of previous node can be obtained only by standalnone using protocol? Or is way to get that info from Bitcoin client - for exmaple by ZMQ?


Title: Re: "relayed_by" addres IP
Post by: AdolfinWolf on August 16, 2019, 09:37:04 AM
IP of previous node can be obtained only by standalnone using protocol? Or is way to get that info from Bitcoin client - for exmaple by ZMQ?

I believe this is how most block explorers get it (the relay IP of a new transaction that is:) (Not sure if it's still up to date either.)

Blockchain.info lists the first IP address it sees a new transaction from.

If you aren't the one creating the transaction, and aren't accidentally the node right in between the node that does and blockchain.info, it's unlikely that you're the first to do so. Furthermore, they may not even be connected to you the whole time.

To see what transactions are being relayed, start bitcoind with -debug=net, and look for 'inv' messages in the debug.log file.
Basically: the relayed_by stat is pretty darn useless.

I'm not sure if ZMQ actually gives info regarding IP adresses. https://bitcoin.stackexchange.com/a/40755 says only notifications for blocks/tx's.

and https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md

Might very well be wrong though.


Title: Re: "relayed_by" addres IP
Post by: Frodek on August 16, 2019, 12:05:27 PM
I run bitcoin with -debug=net
in log I have "got inv tx=hash, new peer=1"
peer = 1 or 9 but how get IP address from peer number?


Title: Re: "relayed_by" addres IP
Post by: AdolfinWolf on August 16, 2019, 12:13:51 PM
I run bitcoin with -debug=net
in log I have "got inv tx=hash, new peer=1"
peer = 1 or 9 but how get IP address from peer number?

GetPeerInfo (?) https://bitcoincore.org/en/doc/0.16.0/rpc/network/getpeerinfo/

Again though, you will see which node relayed the transaction to YOU. It's obviously not the node that is the original owner of the tx.

And thus, as others have also stated in the past, the information is rather useless. I don't really understand what you would want this for.


Title: Re: "relayed_by" addres IP
Post by: Frodek on August 16, 2019, 12:27:05 PM
I think, peers are not constant and must be often called getpeerinfo


Title: Re: "relayed_by" addres IP
Post by: AdolfinWolf on August 16, 2019, 12:34:25 PM
I think, peers are not constant and must be often called getpeerinfo
You can change that by only connecting to certain nodes but then the stat becomes even more useless as you're bound to only get new tx's relayed by those nodes anyway.
So really the question becomes about what you're trying to achieve with this?






I'm not sure how blockcypher and blockchain.com do it, or why they think this stat is useful to add anyway. Are they connected to what, 1000 peers?


Title: Re: "relayed_by" addres IP
Post by: franky1 on August 23, 2019, 08:23:24 PM
relayed by is about where the node got its tx from(the node directly connected to the node) its not about who created the tx/block

but normally Bitcoin client (such as Bitcoin Core) don't record from whom they receive a block/transaction.

bitcoin core client does.
its done because if it receives bad data, it gives the node that sent it a score and if the score reaches a certain level the node bans the malicious node


Title: Re: "relayed_by" addres IP
Post by: franky1 on August 24, 2019, 07:21:40 AM
but normally Bitcoin client (such as Bitcoin Core) don't record from whom they receive a block/transaction.

bitcoin core client does.
its done because if it receives bad data, it gives the node that sent it a score and if the score reaches a certain level the node bans the malicious node

I know that, but AFAIK Bitcoin Core don't add information about which node (along with details such as node's IP, version, service, etc.) send a transaction/block on that transaction/block which needed in this case.

hint:
https://github.com/bitcoin/bitcoin/blob/85883a9f8ea09f65092dc822a7ca98e64b96f4ab/src/net_processing.cpp#L120
Quote
    * Sources of received blocks, saved to be able to send them reject
     * messages or ban them when processing happens afterwards.