Skip to content

Commit

Permalink
fix(server): Fix unconfirmed utxo results
Browse files Browse the repository at this point in the history
Fix unconfirmed utxo results, by better parsing getTx from Bitcore v8
  • Loading branch information
matiu committed Dec 12, 2018
1 parent 5df8632 commit 72bf2bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/blockchainexplorers/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ V8.prototype.getUtxos = function(wallet, cb) {
var client = this._getAuthClient(wallet);
client.getCoins({pubKey: wallet.beAuthPublicKey, payload: {} })
.then( (unspent) => {
console.log('[v8.js.184:unspent:]',unspent); //TODO
console.log('[v8.js.184:unspent:]',unspent.length); //TODO
_.each(unspent, function(x) {
if (self.addressFormat) {
x.address = self.translateResultAddresses(x.address);
Expand Down Expand Up @@ -235,14 +235,21 @@ console.log('[v8.js.207] GET TX', txid); //TODO
var client = this._getClient();
client.getTx({txid: txid })
.then( (tx) => {

if (!tx || _.isEmpty(tx)) {
return cb();
}
self.translateTx(tx);
return cb(null, tx);
})
.catch(cb);
.catch((err) =>{
// The TX was not found
if (err.statusCode == '404') {
return cb();
} else {
return cb(err);
}

});
};

V8.prototype.getTransactions = function(wallet, since, limit, cb) {
Expand Down
1 change: 1 addition & 0 deletions lib/blockchainexplorers/v8/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Client.prototype.getAddressTxos = async function (params) {
Client.prototype.getTx = async function (params) {
const { txid } = params;
const url = `${this.baseUrl}/tx/${txid}`;
console.log('[client.js.59:url:]',url); //TODO
return request.get(url, {
json: true
});
Expand Down
4 changes: 3 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ WalletService.prototype._getUtxosWithGrouping = function(wallet, cb) {
return u;
});

console.log('END [server.js.1219:utxos:]',utxos); //TODO
console.log('END [server.js.1219:utxos:]', utxos.length); //TODO
return cb(null, utxos);
});
};
Expand Down Expand Up @@ -2661,6 +2661,8 @@ WalletService.prototype._checkTxInBlockchain = function(txp, cb) {
var bc = this._getBlockchainExplorer(txp.coin, txp.network);
if (!bc) return cb(new Error('Could not get blockchain explorer instance'));
bc.getTransaction(txp.txid, function(err, tx) {
console.log('[server.js.2639:tx:]',tx); //TODO
console.log('[server.js.2639:err:]',err); //TODO
if (err) return cb(err);
return cb(null, !!tx);
})
Expand Down

0 comments on commit 72bf2bb

Please sign in to comment.