nanocurrency-js
nanocurrency-js copied to clipboard
Generate seed from mnemonic
I generate my seed with:
let seedBuffer = bip39.mnemonicToSeed(MNEMONIC_PRIVATE_SEED);
let seed = Buffer.from(seedBuffer).toString('hex');
However, in new version checkSeed() is failing. The length of my seed is 128 characters and maximum allowed for deriveSecretKey() is 64 :/
@rokanost what if you comment that line? https://github.com/marvinroger/nanocurrency-js/blob/a8d794af0242b0de64e0e7f3295a8f33106b217f/src/keys.ts#L41
If it's as simple as feeding the blake2b hash with a 128 chars seed instead of a 64 one, it would be easy to be compatible.
I did comment it out and everything seems fine, but tx now fails on publish with “bad work”
Do you generate the work against the previous block hash? If this is the first block on the account chain, you have to use the account's public key.
All good now, had a little bug in my code.
Alright, so it's a bit more complicated than that.
We can't generate a nano seed from a BIP39 mnemonic phrase. We can however derive private keys from the mnemonic phrase with the BIP39 derivation path 44'/165'/0'
, 0
being the account index.
See https://github.com/nanocurrency/nano-node/wiki/Mnemonic-Seed