Skip to content

Commit 72bf2bb

Browse files
committed
fix(server): Fix unconfirmed utxo results
Fix unconfirmed utxo results, by better parsing getTx from Bitcore v8
1 parent 5df8632 commit 72bf2bb

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/blockchainexplorers/v8.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ V8.prototype.getUtxos = function(wallet, cb) {
182182
var client = this._getAuthClient(wallet);
183183
client.getCoins({pubKey: wallet.beAuthPublicKey, payload: {} })
184184
.then( (unspent) => {
185-
console.log('[v8.js.184:unspent:]',unspent); //TODO
185+
console.log('[v8.js.184:unspent:]',unspent.length); //TODO
186186
_.each(unspent, function(x) {
187187
if (self.addressFormat) {
188188
x.address = self.translateResultAddresses(x.address);
@@ -235,14 +235,21 @@ console.log('[v8.js.207] GET TX', txid); //TODO
235235
var client = this._getClient();
236236
client.getTx({txid: txid })
237237
.then( (tx) => {
238-
239238
if (!tx || _.isEmpty(tx)) {
240239
return cb();
241240
}
242241
self.translateTx(tx);
243242
return cb(null, tx);
244243
})
245-
.catch(cb);
244+
.catch((err) =>{
245+
// The TX was not found
246+
if (err.statusCode == '404') {
247+
return cb();
248+
} else {
249+
return cb(err);
250+
}
251+
252+
});
246253
};
247254

248255
V8.prototype.getTransactions = function(wallet, since, limit, cb) {

lib/blockchainexplorers/v8/client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Client.prototype.getAddressTxos = async function (params) {
5656
Client.prototype.getTx = async function (params) {
5757
const { txid } = params;
5858
const url = `${this.baseUrl}/tx/${txid}`;
59+
console.log('[client.js.59:url:]',url); //TODO
5960
return request.get(url, {
6061
json: true
6162
});

lib/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ WalletService.prototype._getUtxosWithGrouping = function(wallet, cb) {
12491249
return u;
12501250
});
12511251

1252-
console.log('END [server.js.1219:utxos:]',utxos); //TODO
1252+
console.log('END [server.js.1219:utxos:]', utxos.length); //TODO
12531253
return cb(null, utxos);
12541254
});
12551255
};
@@ -2661,6 +2661,8 @@ WalletService.prototype._checkTxInBlockchain = function(txp, cb) {
26612661
var bc = this._getBlockchainExplorer(txp.coin, txp.network);
26622662
if (!bc) return cb(new Error('Could not get blockchain explorer instance'));
26632663
bc.getTransaction(txp.txid, function(err, tx) {
2664+
console.log('[server.js.2639:tx:]',tx); //TODO
2665+
console.log('[server.js.2639:err:]',err); //TODO
26642666
if (err) return cb(err);
26652667
return cb(null, !!tx);
26662668
})

0 commit comments

Comments
 (0)