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

[Address Creation] TypeError: monero.address_and_keys_from_seed is not a function #69

Closed ghost closed 5 years ago

ghost commented 5 years ago

Based from your tests here's what I'm trying to do and seems address_and_keys_from_seed does not exists in monero_utils that's why I encountered this error.

Error Encountered

Using wasm:  true
/Volumes/Sandisk/monero/test2.js:4
const decoded = monero.address_and_keys_from_seed('9c973aa296b79bbf452781dd3d32ad7f', nettype);
                       ^

TypeError: monero.address_and_keys_from_seed is not a function
    at Object.<anonymous> (/Volumes/Sandisk/monero/test2.js:4:24)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)

Sample Code

const monero = require('mymonero-core-js/monero_utils/monero_utils');
const nettype = require('mymonero-core-js/cryptonote_utils/nettype').network_type.MAINNET;

const decoded = monero.address_and_keys_from_seed('9c973aa296b79bbf452781dd3d32ad7f', nettype);
console.log(decoded);
ghost commented 5 years ago

My bad, just found the function on MyMoneroCoreBridge.js but how do I properly implement the address creation using address_and_keys_from_seed ?

paulshapiro commented 5 years ago

You don't need to use MyMoneroCoreBridge directly - this issue originates in improperly obtaining the 'monero_utils' (called monero in your code) object. Try something like await require() or require().then(function(monero_utils) {}).catch(function(e){}) and let me know how it goes!