Bitmessage/PyBitmessage

Incorrect stream offset in `HandleDisseminatePreEncryptedMsg`

PeterSurda opened this issue · 0 comments

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:

toStreamNumber = decodeVarint(encryptedPayload[16:26])[0]

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