From 0fd0d215991176dc09491cd70c1319a38a3a4918 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Wed, 20 Nov 2019 13:02:06 +0000 Subject: [PATCH] fix: operator id fetching on scripts --- bin/hkdf | 4 ++-- bin/lamassu-coinatmradar | 4 +--- bin/lamassu-operator | 17 ++++++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bin/hkdf b/bin/hkdf index eb700684..2e3cdb14 100755 --- a/bin/hkdf +++ b/bin/hkdf @@ -13,5 +13,5 @@ if (process.argv.length !== 4) { process.exit(3) } -const masterSeed = new Buffer(masterSeedHex, 'hex') -console.log(hkdf(masterSeed, 32, {salt: 'lamassu-server-salt', info: label}).toString('hex')) +const masterSeed = Buffer.from(masterSeedHex, 'hex') +console.log(hkdf(masterSeed, 32, { salt: 'lamassu-server-salt', info: label }).toString('hex')) diff --git a/bin/lamassu-coinatmradar b/bin/lamassu-coinatmradar index 1f2836fe..5912b71a 100644 --- a/bin/lamassu-coinatmradar +++ b/bin/lamassu-coinatmradar @@ -1,7 +1,5 @@ #!/usr/bin/env bash -SEED="$(cat ~/seeds/seed.txt)" - echo echo "Here is the 'External ID' of your paired machine(s), for use under the 'ATM / Teller details' of your CoinATMRadar listing:" echo @@ -9,5 +7,5 @@ su - postgres -c "psql \"lamassu\" -Atc \"select regexp_replace(device_id, '$', echo echo "If speaking with CoinATMRadar directly, it may be helpful to let them know your 'Operator ID':" echo -$(npm root -g)/lamassu-server/bin/hkdf operator-id "$SEED" | cut -c -32 +$(npm root -g)/lamassu-server/bin/lamassu-operator echo diff --git a/bin/lamassu-operator b/bin/lamassu-operator index b2792cdd..104a1c5e 100644 --- a/bin/lamassu-operator +++ b/bin/lamassu-operator @@ -1,9 +1,12 @@ -#!/usr/bin/env bash +#!/usr/bin/env node -SEED="$(cat ~/seeds/seed.txt)" +const fs = require('fs') +const hkdf = require('futoin-hkdf') -echo -echo "Your Operator ID for use with CoinATMRadar is:" -echo -/usr/bin/hkdf operator-id "$SEED" | cut -c -32 -echo +const options = require('../lib/options') +const mnemonicHelpers = require('../lib/mnemonic-helpers') + +const mnemonic = fs.readFileSync(options.mnemonicPath, 'utf8').trim() +const masterSeed = mnemonicHelpers.toEntropyBuffer(mnemonic) + +console.log(hkdf(masterSeed, 16, { salt: 'lamassu-server-salt', info: 'operator-id' }).toString('hex'))