From b1960f83116be8e188b926ef0caca4edc2fdc6dd Mon Sep 17 00:00:00 2001 From: gaeacodes Date: Sat, 30 Jan 2021 14:11:45 +0530 Subject: [PATCH 1/5] testing --- lib/services/bitcoind.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index d50d2563..fc84a07b 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -1719,6 +1719,8 @@ Bitcoin.prototype.getAddressSummary = function (addressArg, options, callback) { if (err) { return callback(err); } + var abc = summary.txids; + console.log(abc); self.summaryCache.set(cacheKey, summary); finishWithTxids(); } @@ -2252,7 +2254,7 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { var rewardData = { tiptime: tx.blockTimestamp || self.tipTime, locktime: result.locktime, - height: result.height ? result.height : 1000001,//To satisfy getKomodoRewards constraints on unconfirmed transactions + height: result.height ? result.height : 1000001, //To satisfy getKomodoRewards constraints on unconfirmed transactions satoshis: vins[index].satoshis, }; rewards = getKomodoRewards(rewardData); From a4e55ec6c7a37b3a7ce62d2947ca8981dbe31b24 Mon Sep 17 00:00:00 2001 From: gaeacodes Date: Tue, 2 Feb 2021 13:57:45 +0530 Subject: [PATCH 2/5] removed cache part --- lib/services/bitcoind.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index fc84a07b..e10b8590 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -2164,6 +2164,7 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { }); } else { self._tryAllClients(function (client, done) { + let transactionData = {}; async.series( [ function (callback) { @@ -2230,12 +2231,17 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { } // Sapling END - self.transactionDetailedCache.set(txid, tx); + // self.transactionDetailedCache.set(txid, tx); + + transactionData.txid = txid; + transactionData.tx = tx; callback(null, tx); }); }, function (callback) { - var tx = self.transactionDetailedCache.get(txid); + // var tx = self.transactionDetailedCache.get(txid); + var tx = transactionData.tx; + var txid = transactionData.txid; var vins = tx.inputs; var functionsArray = []; for (let index = 0; index < vins.length; index++) { @@ -2279,7 +2285,7 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { //res.forEach((reward) => (totalReward = reward + totalReward)); for (let index = 0; index < res.length; index++) { tx.inputs[index].rewardClaimed = res[index].rewards - ? res[index].rewards * 1e-8 + ? (res[index].rewards * 1e-8).toFixed(8) : 0; var actualTimeRewardAccrued = res[index].prevTxnLocktime @@ -2300,16 +2306,17 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { tx.rewardClaimed = totalReward; tx.feeSatoshis = tx.inputSatoshis + tx.rewardClaimed * 1e8 - tx.outputSatoshis; - self.transactionDetailedCache.set(txid, tx); + // self.transactionDetailedCache.set(txid, tx); + transactionData.txid = txid; + transactionData.tx = tx; callback(null, tx); }); - - // self.transactionDetailedCache.set(txid, tx); - // callback(null, tx); }, ], function (err, results) { - var tx = self.transactionDetailedCache.get(txid); + // var tx = self.transactionDetailedCache.get(txid); + var tx = transactionData.tx; + var txid = transactionData.txid; done(null, tx); } From 1e90ed8bf23651ff3de661c5bd044c9e54dd42f3 Mon Sep 17 00:00:00 2001 From: gaeacodes Date: Tue, 2 Feb 2021 14:19:15 +0530 Subject: [PATCH 3/5] removed tofixed --- lib/services/bitcoind.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index e10b8590..e74c2fc7 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -2285,7 +2285,7 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { //res.forEach((reward) => (totalReward = reward + totalReward)); for (let index = 0; index < res.length; index++) { tx.inputs[index].rewardClaimed = res[index].rewards - ? (res[index].rewards * 1e-8).toFixed(8) + ? res[index].rewards * 1e-8 : 0; var actualTimeRewardAccrued = res[index].prevTxnLocktime From 4d419f7b168faa5ceffca8e7f961ec2a25e9a949 Mon Sep 17 00:00:00 2001 From: gaeacodes Date: Tue, 2 Feb 2021 16:55:40 +0530 Subject: [PATCH 4/5] Added self.tipTime --- lib/services/bitcoind.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index e74c2fc7..b6ddebb5 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -625,6 +625,7 @@ Bitcoin.prototype._updateTip = function (node, message) { self.emit("error", error); } else { self.height = response.result.height; + self.tipTime = response.result.time; $.checkState(self.height >= 0); self.emit("tip", self.height); } @@ -861,6 +862,7 @@ Bitcoin.prototype._loadTipFromNode = function (node, callback) { return callback(self._wrapRPCError(err)); } self.height = response.result.height; + self.tipTime = response.result.time; $.checkState(self.height >= 0); self.emit("tip", self.height); callback(); From c0d7204ef3c827559f56e2d14b875af03d95468f Mon Sep 17 00:00:00 2001 From: gaeacodes Date: Tue, 2 Feb 2021 21:02:39 +0530 Subject: [PATCH 5/5] cleanup --- lib/services/bitcoind.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index b6ddebb5..65e18dea 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -1721,8 +1721,6 @@ Bitcoin.prototype.getAddressSummary = function (addressArg, options, callback) { if (err) { return callback(err); } - var abc = summary.txids; - console.log(abc); self.summaryCache.set(cacheKey, summary); finishWithTxids(); } @@ -2233,15 +2231,12 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { } // Sapling END - // self.transactionDetailedCache.set(txid, tx); - transactionData.txid = txid; transactionData.tx = tx; callback(null, tx); }); }, function (callback) { - // var tx = self.transactionDetailedCache.get(txid); var tx = transactionData.tx; var txid = transactionData.txid; var vins = tx.inputs; @@ -2308,7 +2303,6 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { tx.rewardClaimed = totalReward; tx.feeSatoshis = tx.inputSatoshis + tx.rewardClaimed * 1e8 - tx.outputSatoshis; - // self.transactionDetailedCache.set(txid, tx); transactionData.txid = txid; transactionData.tx = tx; callback(null, tx); @@ -2316,10 +2310,7 @@ Bitcoin.prototype.getDetailedTransaction = function (txid, callback) { }, ], function (err, results) { - // var tx = self.transactionDetailedCache.get(txid); var tx = transactionData.tx; - var txid = transactionData.txid; - done(null, tx); } );