Skip to content

Commit

Permalink
fix v8 history downloa[Cding
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu committed Dec 12, 2018
1 parent 75b8cc5 commit 5df8632
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 116 deletions.
19 changes: 10 additions & 9 deletions lib/blockchainexplorers/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,19 @@ V8.prototype.getTransactions = function(wallet, since, limit, cb) {

txStream.on('data', (txRaw) => {
var tx = JSON.parse(txRaw.toString());

if (self.addressFormat) {
// TODO
self.translateTx(tx);
if (tx.address && self.addressFormat) {
tx.address = self.translateResultAddresses(tx.address);
}
// v8 field name differences
tx.amount = tx.value / 1e8;
if (tx.value)
tx.amount = tx.satoshis / 1e8;

txs.push(tx);
if (tx && tx.txid)
txs.push(tx);
});

txStream.on('end', () => {

console.log('[v8.js.279] GOT:' , txs.length); //TODO
return cb(null, txs);
});

Expand Down Expand Up @@ -313,18 +312,20 @@ V8.prototype.getAddressActivity = function(address, cb) {
};

V8.prototype.estimateFee = function(nbBlocks, cb) {
var self = this;
nbBlocks = nbBlocks || [1,2,6,24];

var result = {};

async.each(nbBlocks, function(x, icb) {
var url = this.apiPrefix + '/fee/' + x;
var url = self.apiPrefix + '/fee/' + x;
request.get(url, {})
.then( (ret) => {
result[x] = ret;
})
.catch(icb(err));
.catch((err) => {return icb(err)} );
}, function(err) {
console.log('[v8.js.327:err:]',err); //TODO
if (err) {
return cb(err);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/blockchainexplorers/v8/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ Client.prototype.getCoins = async function (params) {
};

Client.prototype.listTransactions = function (params) {
const { payload, pubKey, startDate, endDate } = params;
const url = `${this.baseUrl}/wallet/${pubKey}/transactions?startDate=${startDate}&endDate=${endDate}`;
const { payload, pubKey, since, limit } = params;

const sinceParam = since ? `since=${since}&` : '';
const url = `${this.baseUrl}/wallet/${pubKey}/transactions?${sinceParam}paging=_id&direction=-1&limit=${limit}`;
console.log('[client.js.68:url:]',url); //TODO
const signature = this.sign({ method: 'GET', url, payload });
return requestStream.get(url, {
Expand Down
Loading

0 comments on commit 5df8632

Please sign in to comment.