0

I am trying to derive my accounts of different blockchains via BIP44 standard to have deterministic account hierarchy. I was able to generate keys for BTC,ETH and other blockchains, but not for monero yet.

I'm using the monerojs library from node.js and the only method I've found that allows me to insert a seed to derive my wallet is the following: [https://moneroecosystem.org/monero-javascript/global.html#createWalletKeys]

But when I go to insert in the parameters the 32byte "seedOffset" generated by these lines of code:

const seed = bip39.mnemonicToSeedSync(mnemonic);
const masterNode = bip32.fromSeed(seed);
const path = `m/44'/128'/0'/0/0`;
const child = masterNode.derivePath(path);
let wallet = await monerojs.createWalletKeys({
    networkType: MoneroNetworkType.STAGENET,
    seedOffset: child.privateKey  
  });

If I run the console returns me:

 if (config.getSeedOffset() !== undefined) throw new MoneroError("Cannot provide seedOffset when creating random wallet");
                                                  ^

MoneroError: Cannot provide seedOffset when creating random wallet
    at Function.createWallet (C:\Users\alexc\OneDrive\Documenti\GitHub\ECDSA-sign\node_modules\monero-javascript\src\main\js\wallet\MoneroWalletKeys.js:63:55)
    at Object.module.exports.createWalletKeys (C:\Users\alexc\OneDrive\Documenti\GitHub\ECDSA-sign\node_modules\monero-javascript\index.js:286:87)

Any advice on how to manage this thing and derive in the best way one or more Monero accounts from the same seed as MasterNode BIP44?

5
  • Firstly, a seed offset is not a seed. Have you also seen this comment and linked example code?
    – jtgrassie
    Apr 18 at 16:19
  • Yes, i seen this example code. But the thing I'm missing is how to generate Monero keys so that they are intrinsically linked to masterNode BIP32
    – AlexCav
    Apr 18 at 16:53
  • That JS lib (using createWalletKeys or createWalletFull) is allowing you to use the mnemonic seed (words) to construct a wallet, so you're going to need to get the Monero words for your key/seed. As Monero doesn't use bip39, you'll have to juggle the bip39 seed to Monero words before creating the wallet (with Monero words).
    – jtgrassie
    Apr 18 at 20:28
  • I need this "juggle" to continue. Do you have some examples or tips??
    – AlexCav
    Apr 19 at 7:08
  • Take your variable seed and convert to Monero mnumonic words, then pass those Monero words into the constructor of the wallet function.
    – jtgrassie
    Apr 19 at 12:54

1 Answer 1

1

Firstly, seedOffset is not a seed.

Secondly, Monero doesn't use BIP 39, so you'll need to convert your BIP 39 seed (the result of bip39.mnemonicToSeedSync or child.privateKey; whichever you prefer), to a Monero mnemonic seed phrase. The monero-javascript library doesn't appear to support that, but this step is fairly trivial and there's an example javascript version at mnemonic.js (mn_encode).

Lastly, pass the resulting Monero seed phrase as parameter mnemonic in the constructor of createWalletKeys (see the doc).

9
  • so you say to insert my child.privatekey as a parameter of the mn_encode method? The method requires a string and a wordset_name, the wordset_name is optional right?
    – AlexCav
    Apr 21 at 9:59
  • I also run the script and the console says that crc32 is not defined. in fact in the class this object is not defined. Advice?
    – AlexCav
    Apr 21 at 10:12
  • You obviously need to include the other scripts for it to work locally.
    – jtgrassie
    Apr 21 at 13:29
  • i found the class, but the code want a mnemonic, if i pass bip39.mnemonicToSeedSync or child.privateKey, doesn't work
    – AlexCav
    Apr 21 at 16:15
  • 1
    I fixed that error that was coming up, I can create an account and derive it through my seed. A thousand thanks!!
    – AlexCav
    Apr 26 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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