Moonlight-io / asteroid-sdk-js

5 stars 3 forks source link

method for generation of a bip39 mnemonic #56

Closed lllwvlvwlll closed 4 years ago

lllwvlvwlll commented 4 years ago

As required by https://github.com/Moonlight-io/docs_internal/issues/461, The front-end needs the ability to generate a BIP39 mnemonic. This method will most likely be a light-wrapper around an existing package.

This the one of the more commonly used ones: https://github.com/bitcoinjs/bip39

lllwvlvwlll commented 4 years ago

example of mnemonic generation:

const sdk = require('../../dist')
const keychain = new sdk.Keychain()
console.log(keychain.mnemonic.toString())
// => beyond hen spray robot decrease surprise boss coach elevator lunar need board echo shift session window chuckle father grant punch cram clean valve gallery

example of mnemonic importing

const sdk = require('../../dist')
const mnemonic = 'online ramp onion faculty trap clerk near rabbit busy gravity prize employ exit horse found slogan effort dash siren buzz sport pig coconut element'
const keychain = new sdk.Keychain()
keychain.importMnemonic(mnemonic)
lllwvlvwlll commented 4 years ago

@rockacola could you take a look and let me know if you have any questions?

rockacola commented 4 years ago

Working as expected offline on node.js. Separate test shall be done in vega sandbox once a new asteroid-sdk-js release is available, however I don't see it been problematic.

Let's close out the ticket.

rockacola commented 4 years ago

Example usage is now in asteroid-sdk-js-examples.