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

What is relationship with code running on mymonero.com? #81

Closed moneroexamples closed 5 years ago

moneroexamples commented 5 years ago

I compiled mymonero-core-js using current master and wanted to use them in openmonero along with new send_coins.js. However, generated MyMoneroCoreCpp_WASM.js and MyMoneroCoreCpp_WASM.wasm are different than those used on mymonero website. And off course send_coins.js does not work with the files obtained by compilation of mymonero-core-js. So how the files on mymonero.com were compiled?

Also, is there any github repo for the files used in mymonero.com? It would simply tracking changes in the files.

paulshapiro commented 5 years ago

Hi, I'm not 100% clear on your question, but the code running on mymonero.com uses mymonero-core-js as well. It uses exactly the same Send routine as the apps do.

Here is the complete implementation necessary for using it, including all networking: https://mymonero.com/js/controllers/send_coins.js?9

Note that the entrypoint / wrapping code is the same – we've just changed the interface so that basically everything is in WASM now. This has the benefit of allowing integrators such as openmonero not to have to continuously update their parsing and request JSON construction code each time we make an API update, which was a feature request of some of our library consumers.

paulshapiro commented 5 years ago

by the way the only reason the wasm differs is that it was recompiled more recently than what was deployed on mymonero.com but the send functionality was unchanged between the two. I think it was just adding some of gutenye's accessory functions like estimate rct tx size.

moneroexamples commented 5 years ago

I think that mymonero-core.js is most different. If you compare what is on mymonero.com (https://mymonero.com/js/lib/mymonero-core.js?3) and what mymonero-core-js generates (what it generates for me can be seen here ), big differences can be seen.

Just in the first line difference are obvious. mymonero.com has

!function(i,A){"object"==typeof exports&&

and from compilation I get:

var MyMoneroCoreCpp = (function() {
  var _scriptDir = typeof document !== 'undefined' && documen

When I use the generated code with the send_coins.js?9 I get the following error:

angular.min.js:123 ReferenceError: mymonero_core_js is not defined
    at m.$scope.sendCoins (send_coins.js?9:185)

So I don't know why there are differences between what compiling mymonero-core-js produces, and what is on mymonero.com. Do I need to checkout some specific version or commit from mymonero-core-js to be in sync with mymonero.com?

paulshapiro commented 5 years ago

Mymonero-core.js which is used on mymonero.com right now is simply the product of running https://github.com/mymonero/mymonero-core-js/blob/master/bin/package_browser_js

paulshapiro commented 5 years ago

As for mymonero_core_js not being defined, you need to use a script tag to include mymonero-core.js

moneroexamples commented 5 years ago

Thanks! bin/package_browser_js solved the problem.

btw, https://github.com/mymonero/mymonero-core-js/blob/master/README.md does not contain anything about this, thus I didn't know I should use it. Maybe could something about it added to README for futuer reference?

paulshapiro commented 5 years ago

Good idea! Thought i had it in there.

moneroexamples commented 5 years ago

Closing issue. Seems to be solved.

Thanks again.