mirror of https://github.com/BTCPrivate/copay.git
mv filter to Insight
This commit is contained in:
parent
78b84fc466
commit
0567714628
|
@ -5,6 +5,7 @@ var async = require('async');
|
|||
var request = require('request');
|
||||
var bitcore = require('bitcore');
|
||||
var io = require('socket.io-client');
|
||||
var _ = require('lodash');
|
||||
var log = require('../log');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
@ -310,9 +311,15 @@ Insight.prototype.getUnspent = function(addresses, cb) {
|
|||
|
||||
this.requestPost('/api/addrs/utxo', {
|
||||
addrs: addresses.join(',')
|
||||
}, function(err, res, body) {
|
||||
}, function(err, res, unspentRaw) {
|
||||
if (err || res.statusCode != 200) return cb(err || res);
|
||||
cb(null, body);
|
||||
|
||||
// This filter out possible broken unspent, as reported on
|
||||
// https://github.com/bitpay/copay/issues/1585
|
||||
// and later gitter conversation.
|
||||
|
||||
var unspent = _.filter(unspentRaw, 'scriptPubKey');
|
||||
cb(null, unspent);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1879,15 +1879,9 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
|||
|
||||
merchantData.total = merchantData.total.toString(10);
|
||||
|
||||
var b;
|
||||
try {
|
||||
b = new Builder(opts)
|
||||
.setUnspent(unspent)
|
||||
.setOutputs(outs);
|
||||
} catch (e) {
|
||||
log.debug(e.message);
|
||||
return;
|
||||
};
|
||||
var b = new Builder(opts)
|
||||
.setUnspent(unspent)
|
||||
.setOutputs(outs);
|
||||
|
||||
merchantData.pr.pd.outputs.forEach(function(output, i) {
|
||||
var script = {
|
||||
|
@ -2172,17 +2166,11 @@ Wallet.prototype.getBalance = function(cb) {
|
|||
var balanceByAddr = {};
|
||||
var COIN = coinUtil.COIN;
|
||||
|
||||
this.getUnspent(function(err, safeUnspent, unspentRaw) {
|
||||
this.getUnspent(function(err, safeUnspent, unspent) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
// This filter out possible broken unspent, as reported on
|
||||
// https://github.com/bitpay/copay/issues/1585
|
||||
// and later gitter conversation.
|
||||
|
||||
var unspent = _.filter(unspentRaw, 'scriptPubKey');
|
||||
|
||||
for (var i = 0; i < unspent.length; i++) {
|
||||
var u = unspent[i];
|
||||
var amt = u.amount * COIN;
|
||||
|
@ -2371,16 +2359,12 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
|
|||
opts[k] = Wallet.builderOpts[k];
|
||||
}
|
||||
|
||||
var b = new Builder(opts);
|
||||
|
||||
b.setUnspent(utxos);
|
||||
|
||||
console.log('[Wallet.js.2370:utxos:]',utxos); //TODO
|
||||
|
||||
b.setOutputs([{
|
||||
address: toAddress.data,
|
||||
amountSatStr: amountSatStr,
|
||||
}]);
|
||||
var b = new Builder(opts)
|
||||
.setUnspent(utxos)
|
||||
.setOutputs([{
|
||||
address: toAddress.data,
|
||||
amountSatStr: amountSatStr,
|
||||
}]);
|
||||
|
||||
var selectedUtxos = b.getSelectedUnspent();
|
||||
var inputChainPaths = selectedUtxos.map(function(utxo) {
|
||||
|
|
Loading…
Reference in New Issue