Integrate the new model

This commit is contained in:
Yemel Jardi 2014-08-29 10:50:52 -03:00
commit 862dfa72c9
5 changed files with 17 additions and 15 deletions

View file

@ -100,14 +100,14 @@ Insight.prototype.getSocket = function(url, opts) {
/** @private */
Insight.prototype.request = function(path, cb) {
preconditions.checkArgument(url).shouldBeFunction(cb);
preconditions.checkArgument(path).shouldBeFunction(cb);
request(this.url + path, cb);
}
/** @private */
Insight.prototype.requestPost = function(path, data, cb) {
preconditions.checkArgument(url).checkArgument(data).shouldBeFunction(cb);
request.post(this.url, cb).form(data);
preconditions.checkArgument(path).checkArgument(data).shouldBeFunction(cb);
request({method: "POST", url: this.url + path, json: data}, cb);
}
Insight.prototype.destroy = function() {
@ -165,7 +165,7 @@ Insight.prototype.broadcast = function(rawtx, cb) {
this.requestPost('/api/tx/send', {rawtx: rawtx}, function(err, res, body) {
if (err || res.statusCode != 200) cb(err || res);
cb(null, JSON.parse(body).txid);
cb(null, body.txid);
});
};
@ -219,7 +219,7 @@ Insight.prototype.getUnspent = function(addresses, cb) {
this.requestPost('/api/addrs/utxo', {addrs: addresses.join(',')}, function(err, res, body) {
if (err || res.statusCode != 200) return cb(err || res);
cb(null, JSON.parse(body));
cb(null, body);
});
};

View file

@ -120,7 +120,7 @@ angular.module('copayApp.services')
});
w.on('ready', function(myPeerID) {
$rootScope.wallet = w;
root.setConnectionListeners();
root.setConnectionListeners($rootScope.wallet);
if ($rootScope.pendingPayment) {
$location.path('send');
@ -196,13 +196,7 @@ angular.module('copayApp.services')
$rootScope.updatingBalance = true;
w.getBalance(function(err, balanceSat, balanceByAddrSat, safeBalanceSat) {
if (err) {
console.error('Error: ' + err.message); //TODO
root._setCommError();
return null;
} else {
root._clearCommError();
}
if (err) throw err;
var satToUnit = 1 / config.unitToSatoshi;
var COIN = bitcore.util.COIN;
@ -325,7 +319,7 @@ angular.module('copayApp.services')
if (!$rootScope.wallet) return;
root.updateAddressList();
var currentAddrs = $rootScope.wallet.blockchain.getListeners();
var currentAddrs = $rootScope.wallet.blockchain.subscribed;
var allAddrs = $rootScope.addrInfos;
var newAddrs = [];