From 8e81e9108fda9e250d834302f15c40ea5c1e92ed Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Wed, 18 Jun 2014 20:12:38 -0700 Subject: [PATCH] add private key in Wallet call to network start --- js/models/core/Wallet.js | 6 ++++++ js/models/network/WebRTC.js | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 099c3cf74..aa5cd6155 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -236,6 +236,10 @@ Wallet.prototype.getMyCopayerId = function() { return this.getCopayerId(0); }; +Wallet.prototype.getMyCopayerIdPriv = function() { + return this.privateKey.getIdPriv(); +}; + Wallet.prototype.getSecret = function() { var pubkeybuf = new Buffer(this.getMyCopayerId(), 'hex'); @@ -271,8 +275,10 @@ Wallet.prototype.netStart = function() { }); var myId = self.getMyCopayerId(); + var myIdPriv = self.getMyCopayerIdPriv(); var startOpts = { copayerId: myId, + privkey: myIdPriv, token: self.token, maxPeers: self.totalCopayers }; diff --git a/js/models/network/WebRTC.js b/js/models/network/WebRTC.js index 445ed4a13..c77800274 100644 --- a/js/models/network/WebRTC.js +++ b/js/models/network/WebRTC.js @@ -153,7 +153,8 @@ Network.prototype._addConnectedCopayer = function(copayerId, isInbound) { Network.prototype._onData = function(enchex, isInbound, peerId) { var sig, payload; - var encbuf = new Buffer(enchex, 'hex'); + var encUint8Array = new Uint8Array(enchex); + var encbuf = new Buffer(encUint8Array); var privkey = this.privkey; @@ -304,7 +305,9 @@ Network.prototype.start = function(opts, openCallback) { if (this.started) return openCallback(); - this.privkey = opts.privkey; + if (!this.privkey) + this.privkey = opts.privkey; + this.maxPeers = opts.maxPeers || this.maxPeers; if (opts.token)