Change seed file with a bip39 mnemonic (#207)

* Change seed file with a bip39 mnemonic

* Create helper for bip39 mnemonic

* Prod mode on lamassu-update-to-mnemonic script

* Fix standard styling issues
This commit is contained in:
Rafael Taranto 2018-11-07 15:28:40 -02:00 committed by Josh Harvey
parent 809bf5a2a9
commit d97a33565f
10 changed files with 98 additions and 34 deletions

View file

@ -6,6 +6,7 @@ const pify = require('pify')
const fs = pify(require('fs'))
const db = require('../db')
const mnemonicHelpers = require('../mnemonic-helpers')
const configManager = require('../config-manager')
const options = require('../options')
const logger = require('../logger')
@ -129,17 +130,19 @@ function sendRadar (data) {
function mapRecord (info) {
const timestamp = new Date().toISOString()
return Promise.all([getMachines(info), fs.readFile(options.seedPath, 'utf8')])
.then(([machines, hex]) => ({
operatorId: computeOperatorId(Buffer.from(hex.trim(), 'hex')),
operator: {
name: null,
phone: null,
email: null
},
timestamp,
machines
}))
return Promise.all([getMachines(info), fs.readFile(options.mnemonicPath, 'utf8')])
.then(([machines, mnemonic]) => {
return {
operatorId: computeOperatorId(mnemonicHelpers.toEntropyBuffer(mnemonic)),
operator: {
name: null,
phone: null,
email: null
},
timestamp,
machines
}
})
}
function update (info) {