Python SDK - How to parse a block in msgpack format

Hi, as far as I understand, there is no way with the Python SDK to “decode” a block in msgpack format. Is this accurate? It looks like the “go SDK” has some additional encoding/decoding capabilities to properly handle msgpack. Can anyone confirm this?

I’d like to use the block_info function to retrieve a block and process all transactions (load them into a Transaction object) and calculate the tx id. I’ve tried with both json and msgpack with no luck.

Has anyone been able to solve this?

Thanks!

I’ve also tried to manually recreate the transaction but “reusing” the dictify code, passing the data I got from the block. It works for 98% of the time, but there are still some application transactions for which I get a wrong transaction ID generated.
Not sure why this is so hard to implement in Python, getting the transaction ID of all the transactions in a block should be straight forward. The indexer (written in go) can do this.

Any help would be greatly appreciated.

Can you provide your code as well as an example of block for which your code does not work?

Also, have you looked at How can I decode bytes in ledger fields ledger? - #6 by fabrice

My code is basically the same as the one you posted and I can get a decoded block. I was finally able to generate a transaction ID by manually parsing each transaction inside the block. The biggest problem is that all “keys” inside the transactions of the returned block are encoded as “bytes” instead of “string”, and they need to be converted back to properly calculate a transaction id (using the code in the SDK). I was hoping there was a more “efficient” way to get the transactions back with keys already decoded as strings (where needed). Here is an example of the first transaction inside block 18417631, all keys are bytes:

{b'amt': 2000,
 b'fee': 1000,
 b'fv': 18417629,
 b'grp': b'H\xe7@~w\x82\xf2<\xa2\xd9\xcb8\xccc\xab\x16\xaez\xb6fb8\t\xe5\x19\xc5\xed$\x87=\xb9\xb8',
 b'lv': 18417633,
 b'note': b'fee',
 b'rcv': b'\xd1\xcd\x08\xd6\xd0{h\x8c\x7f\xf9\xb4\x0f\xb8,MfF\xe8z\xc1)f\x0b\x1a\xb1P\xdc\xcd\x93aJ\x0e',
 b'snd': b'\x9d\xf1\xa8\xc6\xfeGP\xd1\x0c\x12sYw+\xc2\x7f\xe6\x7f\xf4\xba\xec\xc8\xc6\x16\xc9\x9b)\xc9h\xfac\xb6',
 b'type': b'pay'}

Thank you!