0

I checked in public.offers from the core database. The sellingasset and buyingasset are base64 encoded.

Here's what I get from database and horizon api:

database

select buyingasset from offers where offerid=147863991;

AAAAAVNMVAAAAAAAlA8rrxQ89pexgEv3wGm0Tu9RxisitWx4ONyNc5Xn7qg=

horizon api

"buying": {
          "asset_type": "credit_alphanum4",
          "asset_code": "SLT",
          "asset_issuer": "GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP"
        },

Question: how can I decode the XDR string to a readable string like the Horizon API is doing? Hopefully in Python code.

1

get it!

xdrstr='AAAAAVNMVAAAAAAAlA8rrxQ89pexgEv3wGm0Tu9RxisitWx4ONyNc5Xn7qg='

tx_result = Xdr.StellarXDRUnpacker(base64.b64decode(xdrstr)).unpack_Asset()

| improve this answer | |
0

Thanks for the answer from Brian Mo(@brian-mo), here is the complete code, it works on 2.x version.

import base64
from stellar_sdk import Asset
from stellar_sdk.xdr import Xdr
xdr_str = 'AAAAAVNMVAAAAAAAlA8rrxQ89pexgEv3wGm0Tu9RxisitWx4ONyNc5Xn7qg='
xdr_obj = Xdr.StellarXDRUnpacker(base64.b64decode(xdr_str)).unpack_Asset()
asset = Asset.from_xdr_object(xdr_obj)

I know it looks a bit complicated, we have made some improvements and will release it some days later, here is a preview.

from stellar_sdk import Asset
xdr_str = 'AAAAAVNMVAAAAAAAlA8rrxQ89pexgEv3wGm0Tu9RxisitWx4ONyNc5Xn7qg='
asset = Asset.from_xdr(xdr_str)

You can find related improvements here (not yet released).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.