mirror of https://github.com/BTCPrivate/copay.git
Integrate the new model
This commit is contained in:
parent
16091bd330
commit
862dfa72c9
|
@ -100,14 +100,14 @@ Insight.prototype.getSocket = function(url, opts) {
|
||||||
|
|
||||||
/** @private */
|
/** @private */
|
||||||
Insight.prototype.request = function(path, cb) {
|
Insight.prototype.request = function(path, cb) {
|
||||||
preconditions.checkArgument(url).shouldBeFunction(cb);
|
preconditions.checkArgument(path).shouldBeFunction(cb);
|
||||||
request(this.url + path, cb);
|
request(this.url + path, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @private */
|
/** @private */
|
||||||
Insight.prototype.requestPost = function(path, data, cb) {
|
Insight.prototype.requestPost = function(path, data, cb) {
|
||||||
preconditions.checkArgument(url).checkArgument(data).shouldBeFunction(cb);
|
preconditions.checkArgument(path).checkArgument(data).shouldBeFunction(cb);
|
||||||
request.post(this.url, cb).form(data);
|
request({method: "POST", url: this.url + path, json: data}, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Insight.prototype.destroy = function() {
|
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) {
|
this.requestPost('/api/tx/send', {rawtx: rawtx}, function(err, res, body) {
|
||||||
if (err || res.statusCode != 200) cb(err || res);
|
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) {
|
this.requestPost('/api/addrs/utxo', {addrs: addresses.join(',')}, function(err, res, body) {
|
||||||
if (err || res.statusCode != 200) return cb(err || res);
|
if (err || res.statusCode != 200) return cb(err || res);
|
||||||
cb(null, JSON.parse(body));
|
cb(null, body);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
w.on('ready', function(myPeerID) {
|
w.on('ready', function(myPeerID) {
|
||||||
$rootScope.wallet = w;
|
$rootScope.wallet = w;
|
||||||
root.setConnectionListeners();
|
root.setConnectionListeners($rootScope.wallet);
|
||||||
|
|
||||||
if ($rootScope.pendingPayment) {
|
if ($rootScope.pendingPayment) {
|
||||||
$location.path('send');
|
$location.path('send');
|
||||||
|
@ -196,13 +196,7 @@ angular.module('copayApp.services')
|
||||||
$rootScope.updatingBalance = true;
|
$rootScope.updatingBalance = true;
|
||||||
|
|
||||||
w.getBalance(function(err, balanceSat, balanceByAddrSat, safeBalanceSat) {
|
w.getBalance(function(err, balanceSat, balanceByAddrSat, safeBalanceSat) {
|
||||||
if (err) {
|
if (err) throw err;
|
||||||
console.error('Error: ' + err.message); //TODO
|
|
||||||
root._setCommError();
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
root._clearCommError();
|
|
||||||
}
|
|
||||||
|
|
||||||
var satToUnit = 1 / config.unitToSatoshi;
|
var satToUnit = 1 / config.unitToSatoshi;
|
||||||
var COIN = bitcore.util.COIN;
|
var COIN = bitcore.util.COIN;
|
||||||
|
@ -325,7 +319,7 @@ angular.module('copayApp.services')
|
||||||
if (!$rootScope.wallet) return;
|
if (!$rootScope.wallet) return;
|
||||||
|
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
var currentAddrs = $rootScope.wallet.blockchain.getListeners();
|
var currentAddrs = $rootScope.wallet.blockchain.subscribed;
|
||||||
var allAddrs = $rootScope.addrInfos;
|
var allAddrs = $rootScope.addrInfos;
|
||||||
|
|
||||||
var newAddrs = [];
|
var newAddrs = [];
|
||||||
|
|
|
@ -54,6 +54,7 @@ module.exports = function(config) {
|
||||||
'test/lib/chai-should.js',
|
'test/lib/chai-should.js',
|
||||||
'test/lib/chai-expect.js',
|
'test/lib/chai-expect.js',
|
||||||
'test/mocks/FakeWallet.js',
|
'test/mocks/FakeWallet.js',
|
||||||
|
'test/mocks/FakeBlockchainSocket.js',
|
||||||
'test/mocks/FakePayProServer.js',
|
'test/mocks/FakePayProServer.js',
|
||||||
|
|
||||||
'test/mocha.conf.js',
|
'test/mocha.conf.js',
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
},
|
},
|
||||||
"version": "0.4.7",
|
"version": "0.4.7",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"browser-request": "^0.3.2",
|
||||||
"mocha": "^1.18.2",
|
"mocha": "^1.18.2",
|
||||||
"mocha-lcov-reporter": "0.0.1",
|
"mocha-lcov-reporter": "0.0.1",
|
||||||
"optimist": "^0.6.1",
|
"optimist": "^0.6.1",
|
||||||
|
@ -71,7 +72,7 @@
|
||||||
"travis-cov": "0.2.5",
|
"travis-cov": "0.2.5",
|
||||||
"uglifyify": "1.2.3",
|
"uglifyify": "1.2.3",
|
||||||
"crypto-js": "3.1.2",
|
"crypto-js": "3.1.2",
|
||||||
"shelljs":"0.3.0"
|
"shelljs": "0.3.0"
|
||||||
},
|
},
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"homepage": "https://github.com/bitpay/copay",
|
"homepage": "https://github.com/bitpay/copay",
|
||||||
|
|
|
@ -40,6 +40,9 @@ var createBundle = function(opts) {
|
||||||
b.require('bitcore/node_modules/browserify-buffertools/buffertools.js', {
|
b.require('bitcore/node_modules/browserify-buffertools/buffertools.js', {
|
||||||
expose: 'buffertools'
|
expose: 'buffertools'
|
||||||
});
|
});
|
||||||
|
b.require('browser-request', {
|
||||||
|
expose: 'request'
|
||||||
|
});
|
||||||
|
|
||||||
b.require('./copay', {
|
b.require('./copay', {
|
||||||
expose: 'copay'
|
expose: 'copay'
|
||||||
|
@ -88,6 +91,9 @@ var createBundle = function(opts) {
|
||||||
b.require('./test/mocks/FakeBlockchain', {
|
b.require('./test/mocks/FakeBlockchain', {
|
||||||
expose: './mocks/FakeBlockchain'
|
expose: './mocks/FakeBlockchain'
|
||||||
});
|
});
|
||||||
|
b.require('./test/mocks/FakeBlockchainSocket', {
|
||||||
|
expose: './mocks/FakeBlockchainSocket'
|
||||||
|
});
|
||||||
b.require('./test/mocks/FakeNetwork', {
|
b.require('./test/mocks/FakeNetwork', {
|
||||||
expose: './mocks/FakeNetwork'
|
expose: './mocks/FakeNetwork'
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue