Bitmessage / PyBitmessage

Reference client for Bitmessage: a P2P encrypted decentralised communication protocol:
https://bitmessage.org/wiki/Main_Page
Other
2.83k stars 576 forks source link

Incorrect stream offset in `HandleDisseminatePreEncryptedMsg` #2110

Closed PeterSurda closed 1 year ago

PeterSurda commented 2 years ago

A user wanted to use HandleDisseminatePreEncryptedMsg API call and it didn't appear to work. After reviewing the code and specification, it looks like when decoding destination stream:

https://github.com/Bitmessage/PyBitmessage/blob/a5a56fe7f1af86f5b8c40ee7d6307df62e0e6b3e/src/api.py#L1313

it uses a protocol v2 specification, and not protocol v3. In v2, the offset for the stream for a message starts at byte 16, but in v3 it starts at a variable position (at the moment it usually is byte 21, which allows for a quick workaround). This API method was introduced around the same time that v3 came out so I guess someone wasn't paying attention.

References: v2 specification from wiki: https://wiki.bitmessage.org/index.php?title=Protocol_specification&oldid=23575#msg v3 specification from rtd: https://pybitmessage.readthedocs.io/en/v0.6/protocol.html#object