aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/id-management.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-22 04:18:32 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-22 04:18:32 +0800
commita08c3bc01b11fbd0e3a243359befbe9fc909edf4 (patch)
treeb79b7324139945c429ca4b6c74715d8040fdf4e1 /app/scripts/lib/id-management.js
parentf7f8f8b1c50be39db22a7b10c6c6db007fe590aa (diff)
downloadtangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.gz
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.bz2
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.lz
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.xz
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.tar.zst
tangerine-wallet-browser-a08c3bc01b11fbd0e3a243359befbe9fc909edf4.zip
Auto linted
Diffstat (limited to 'app/scripts/lib/id-management.js')
-rw-r--r--app/scripts/lib/id-management.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/app/scripts/lib/id-management.js b/app/scripts/lib/id-management.js
index 30a3141f1..b9a2fc3a8 100644
--- a/app/scripts/lib/id-management.js
+++ b/app/scripts/lib/id-management.js
@@ -2,18 +2,18 @@ const ethUtil = require('ethereumjs-util')
module.exports = IdManagement
-function IdManagement(opts) {
+function IdManagement (opts) {
if (!opts) opts = {}
this.keyStore = opts.keyStore
this.derivedKey = opts.derivedKey
this.hdPathString = "m/44'/60'/0'/0"
- this.getAddresses = function(){
- return keyStore.getAddresses(this.hdPathString).map(function(address){ return '0x'+address })
+ this.getAddresses = function () {
+ return keyStore.getAddresses(this.hdPathString).map(function (address) { return '0x' + address })
}
- this.signTx = function(txParams){
+ this.signTx = function (txParams) {
// normalize values
txParams.to = ethUtil.addHexPrefix(txParams.to)
txParams.from = ethUtil.addHexPrefix(txParams.from)
@@ -41,32 +41,32 @@ function IdManagement(opts) {
this.signMsg = function (address, message) {
// sign message
- var privKeyHex = this.exportPrivateKey(address);
- var privKey = ethUtil.toBuffer(privKeyHex);
- var msgSig = ethUtil.ecsign(new Buffer(message.replace('0x',''), 'hex'), privKey);
- var rawMsgSig = ethUtil.bufferToHex(concatSig(msgSig.v, msgSig.r, msgSig.s));
- return rawMsgSig;
- };
+ var privKeyHex = this.exportPrivateKey(address)
+ var privKey = ethUtil.toBuffer(privKeyHex)
+ var msgSig = ethUtil.ecsign(new Buffer(message.replace('0x', ''), 'hex'), privKey)
+ var rawMsgSig = ethUtil.bufferToHex(concatSig(msgSig.v, msgSig.r, msgSig.s))
+ return rawMsgSig
+ }
- this.getSeed = function(){
+ this.getSeed = function () {
return this.keyStore.getSeed(this.derivedKey)
}
- this.exportPrivateKey = function(address) {
+ this.exportPrivateKey = function (address) {
var privKeyHex = ethUtil.addHexPrefix(this.keyStore.exportPrivateKey(address, this.derivedKey, this.hdPathString))
return privKeyHex
}
}
-function pad_with_zeroes(number, length){
- var my_string = '' + number;
+function pad_with_zeroes (number, length) {
+ var my_string = '' + number
while (my_string.length < length) {
- my_string = '0' + my_string;
+ my_string = '0' + my_string
}
- return my_string;
+ return my_string
}
-function concatSig(v, r, s) {
+function concatSig (v, r, s) {
r = pad_with_zeroes(ethUtil.fromSigned(r), 64)
s = pad_with_zeroes(ethUtil.fromSigned(s), 64)
r = ethUtil.stripHexPrefix(r.toString('hex'))