From 8d4a6ded719af050b2edf242a6c25815f69f4fe4 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Thu, 1 May 2014 10:03:58 -0300 Subject: [PATCH] implementing passphrase to wallet Open/Create methods --- js/models/core/WalletFactory.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js index 0e704da06..5e6708c38 100644 --- a/js/models/core/WalletFactory.js +++ b/js/models/core/WalletFactory.js @@ -68,12 +68,13 @@ WalletFactory.prototype.fromObj = function(obj) { return w; }; -WalletFactory.prototype.read = function(walletId) { +WalletFactory.prototype.read = function(walletId, passphrase) { if (! this._checkRead(walletId)) return false; var obj = {}; var s = this.storage; + s._setPassphrase(passphrase); obj.id = walletId; obj.opts = s.get(walletId, 'opts'); @@ -86,7 +87,6 @@ WalletFactory.prototype.read = function(walletId) { }; WalletFactory.prototype.create = function(opts) { - var s = WalletFactory.storage; opts = opts || {}; this.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID') + @@ -112,6 +112,8 @@ WalletFactory.prototype.create = function(opts) { }); this.log('\t### TxProposals Initialized'); + this.storage._setPassphrase(opts.passphrase); + opts.storage = this.storage; opts.network = this.network; opts.blockchain = this.blockchain; @@ -130,7 +132,7 @@ WalletFactory.prototype.open = function(walletId, opts) { opts = opts || {}; opts.id = walletId; opts.verbose = this.verbose; - var w = this.read(walletId) || this.create(opts); + var w = this.read(walletId, opts.passphrase) || this.create(opts); w.store(); return w; };