mymonero / mymonero-core-js

The JS library containing the Monero crypto plus lightwallet functions behind the official MyMonero apps
BSD 3-Clause "New" or "Revised" License
101 stars 103 forks source link

Is there a way to deserialization of tx hex data? #64

Closed gutenye closed 5 years ago

gutenye commented 5 years ago

When I get transaction data from daemon API, it returns raw hex data, so I need to decode this data.

Does mymonero-core-js supports it? If not, is there a bridge to c++ code.

I can not find any JavaScript implementation of monero serialization.

paulshapiro commented 5 years ago

Hi there,

There was a JS-native serialization (but not deserialization) implementation in the older version of mymonero-core-js before we moved that stuff into C++ for serializing a constructed transaction object. vtnerd jokingly calls this the "cryptonote special" format.

I do think it would make general sense to add that stuff to mymonero-core-js, but I'd like to check the specifics of what you want to decode, how you'd like to be able to do so, etc. and see where it leads in terms of the API and featureset.

We have plans to propose and add block streaming / scanning here so there may also be overlap there.

gutenye commented 5 years ago

Hi, Paul. Thanks for the quick reply.

Our wallet is light, and we use Monero Daemon API. Although it has decode_as_json param which returns decoded tx response, this increase the response size a lot, and download time is a major bottleneck.

So we're getting all response in raw hex format, and do deserialization in client side.

The downside is that we may need to keep updating the source code after Monero bi-annual hard forks.

paulshapiro commented 5 years ago

@gutenye what do you mean when you say "light"?

luigi1111 commented 5 years ago

@gutenye what functionality are you looking for by decoding a tx? My gut says modifying the daemon (if necessary) to return JSON without big, likely unnecessary fields such as rctsig_prunable would be the simplest and possibly best solution.

luigi1111 commented 5 years ago

I might also mention that I have some interest in writing decoding functionality in JS as a sort of educational and debug routine; it wouldn't necessarily be intended for production use.

paulshapiro commented 5 years ago

@luigi1111 if so, how would you feel about working together to write it in C++ and exposing it via the JSON "serial bridge"? The decode/encode would be able to be gotten for 'free'.

luigi1111 commented 5 years ago

I don't feel that really scratches the itch I was going for. Decode should already exist in C++ anyway; might be better to go that route for production use (though I think passing pruned is still the better option, depending on the purpose).

gutenye commented 5 years ago

Closed as I have a pure-js implementation.