From 775618a29f6085d93c06fd1ca5cce1a78e03160f Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sat, 8 Jul 2023 16:29:35 +0200 Subject: [PATCH 1/6] Update KMD interest calculation for KIP0001 --- routes/api/electrum/balances.js | 31 +----------- routes/api/electrum/interest.js | 78 +++++++++++++++++++++++++++++- routes/api/electrum/listunspent.js | 13 +---- 3 files changed, 79 insertions(+), 43 deletions(-) diff --git a/routes/api/electrum/balances.js b/routes/api/electrum/balances.js index 370c9c47..762f230f 100644 --- a/routes/api/electrum/balances.js +++ b/routes/api/electrum/balances.js @@ -1,8 +1,6 @@ const { checkTimestamp } = require('agama-wallet-lib/src/time'); const { pubToElectrumScriptHashHex } = require('agama-wallet-lib/src/keys'); const btcnetworks = require('agama-wallet-lib/src/bitcoinjs-networks'); -const { toSats } = require('agama-wallet-lib/src/utils'); -const kmdCalcInterest = require('agama-wallet-lib/src/komodo-interest'); const UTXO_1MONTH_THRESHOLD_SECONDS = 2592000; module.exports = (api) => { @@ -64,8 +62,6 @@ module.exports = (api) => { let ecl; let _address = address; - api.log("electrum getbalance =>", "spv.getbalance"); - ecl = await api.ecl(network); _address = ecl.protocolVersion && ecl.protocolVersion === "1.4" @@ -89,13 +85,6 @@ module.exports = (api) => { let utxoIssues = false; for (let i = 0; i < utxoList.length; i++) { - api.log( - `utxo ${utxoList[i].tx_hash} sats ${utxoList[i].value} value ${ - Number(utxoList[i].value) * 0.00000001 - }`, - "spv.getbalance" - ); - if (Number(utxoList[i].value) * 0.00000001 >= 10) { _utxo.push(utxoList[i]); } else { @@ -103,9 +92,6 @@ module.exports = (api) => { } } - api.log("filtered utxo list =>", "spv.getbalance"); - api.log(_utxo, "spv.getbalance"); - if (_utxo && _utxo.length) { let interestTotal = 0; @@ -132,12 +118,6 @@ module.exports = (api) => { api .getTransaction(_utxoItem.tx_hash, network, ecl) .then((_rawtxJSON) => { - api.log("electrum gettransaction ==>", "spv.getbalance"); - api.log( - `${index} | ${_rawtxJSON.length - 1}`, - "spv.getbalance" - ); - api.log(_rawtxJSON, "spv.getbalance"); // decode tx const _network = api.getNetworkData(network); @@ -166,11 +146,10 @@ module.exports = (api) => { decodedTx.format && decodedTx.format.locktime > 0 ) { - interestTotal += kmdCalcInterest( + interestTotal += api.kmdCalcInterest( decodedTx.format.locktime, _utxoItem.value, - _utxoItem.height, - true + _utxoItem.height ); const _locktimeSec = checkTimestamp( @@ -192,9 +171,6 @@ module.exports = (api) => { ); } - api.log("decoded tx =>", "spv.getbalance"); - api.log(decodedTx, "spv.getbalance"); - resolve(true); }); }); @@ -228,9 +204,6 @@ module.exports = (api) => { }) .catch((e) => reject(e)); } else { - api.log("electrum getbalance ==>", "spv.getbalance"); - api.log(json, "spv.getbalance"); - resolve({ confirmed: Number((0.00000001 * json.confirmed).toFixed(8)), unconfirmed: Number((0.00000001 * json.unconfirmed).toFixed(8)), diff --git a/routes/api/electrum/interest.js b/routes/api/electrum/interest.js index 210f4468..4e59125f 100644 --- a/routes/api/electrum/interest.js +++ b/routes/api/electrum/interest.js @@ -1,7 +1,81 @@ -const kmdCalcInterest = require('agama-wallet-lib/src/komodo-interest'); +/* +MIT License + +Copyright (c) 2018 - 2019 Atomic Labs, Luke Childs +Copyright (c) 2019 - 2022 Komodo Platform + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +const KOMODO_ENDOFERA = 7777777; +const LOCKTIME_THRESHOLD = 500000000; +const MIN_SATOSHIS = 1000000000; +const ONE_MONTH_CAP_HARDFORK = 1000000; +const ONE_HOUR = 60; +const ONE_MONTH = 31 * 24 * 60; +const ONE_YEAR = 365 * 24 * 60; +const DEVISOR = 10512000; +const N_S7_HARDFORK_HEIGHT = 3484958; module.exports = (api) => { - api.kmdCalcInterest = kmdCalcInterest; + api.kmdCalcInterest = (locktime, value, height) => { + const tiptime = Math.floor(Date.now() / 1000) - 777; + const satoshis = value; + + // Calculate coinage + const coinage = Math.floor((tiptime - locktime) / ONE_HOUR); + + // Return early if UTXO is not eligible for rewards + if ( + (height >= KOMODO_ENDOFERA) || + (locktime < LOCKTIME_THRESHOLD) || + (satoshis < MIN_SATOSHIS) || + (coinage < ONE_HOUR) || + (!height) + ) { + return 0; + } + + // Cap reward periods + const limit = (height >= ONE_MONTH_CAP_HARDFORK) ? ONE_MONTH : ONE_YEAR; + let rewardPeriod = Math.min(coinage, limit); + + // The first hour of coinage should not accrue rewards + rewardPeriod -= 59; + + // Calculate rewards + let rewards = Math.floor(satoshis / DEVISOR) * rewardPeriod; + + // Vote-KIP0001 resulted in a reduction of the AUR from 5% to 0.01% + // https://github.com/KomodoPlatform/kips/blob/main/kip-0001.mediawiki + // https://github.com/KomodoPlatform/komodo/pull/584 + if (height >= N_S7_HARDFORK_HEIGHT) { + rewards = Math.floor(rewards / 500); + } + + // Ensure reward value is never negative + if (rewards < 0) { + throw new Error('Reward should never be negative'); + } + + return rewards; + }; return api; }; \ No newline at end of file diff --git a/routes/api/electrum/listunspent.js b/routes/api/electrum/listunspent.js index 48014947..d32592b9 100644 --- a/routes/api/electrum/listunspent.js +++ b/routes/api/electrum/listunspent.js @@ -96,10 +96,6 @@ module.exports = (api) => { return new Promise((resolve, reject) => { api.getTransaction(_utxoItem.tx_hash, network, ecl) .then((_rawtxJSON) => { - api.log('electrum gettransaction ==>', 'spv.listunspent'); - api.log(`${index} | ${(_rawtxJSON.length - 1)}`, 'spv.listunspent'); - api.log(_rawtxJSON, 'spv.listunspent'); - // decode tx const _network = api.getNetworkData(network); let decodedTx; @@ -135,8 +131,7 @@ module.exports = (api) => { interest = api.kmdCalcInterest( decodedTx.format.locktime, _utxoItem.value, - _utxoItem.height, - true + _utxoItem.height ); } @@ -255,10 +250,8 @@ module.exports = (api) => { })) .then(promiseResult => { if (!_atLeastOneDecodeTxFailed) { - api.log(promiseResult, 'spv.listunspent'); resolve(promiseResult); } else { - api.log('listunspent error, cant decode tx(s)', 'spv.listunspent'); resolve('decode error'); } }); @@ -303,8 +296,6 @@ module.exports = (api) => { req.query.verify ) .then((listunspent) => { - api.log('electrum listunspent ==>', 'spv.listunspent'); - const retObj = { msg: 'success', result: listunspent, @@ -315,8 +306,6 @@ module.exports = (api) => { } else { api.electrum.listunspent(ecl, req.query.address, network) .then((listunspent) => { - api.log('electrum listunspent ==>', 'spv.listunspent'); - const retObj = { msg: 'success', result: listunspent, From f1b161ffeabd64349a6359e3326ebcc4ddc36fb6 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sat, 8 Jul 2023 16:33:02 +0200 Subject: [PATCH 2/6] Remove unnecessary logs --- routes/api/electrum/block.js | 3 -- routes/api/electrum/cache.js | 39 ++------------------------ routes/api/electrum/coins.js | 11 +------- routes/api/electrum/merkle.js | 18 ------------ routes/api/electrum/nspv.js | 7 ----- routes/api/electrum/servers.js | 8 ------ routes/api/electrum/transactions.js | 26 ----------------- routes/api/network/fees/btc/btcFees.js | 2 -- 8 files changed, 4 insertions(+), 110 deletions(-) diff --git a/routes/api/electrum/block.js b/routes/api/electrum/block.js index 4c0ee403..fa4c78f9 100644 --- a/routes/api/electrum/block.js +++ b/routes/api/electrum/block.js @@ -46,9 +46,6 @@ module.exports = (api) => { const ecl = await api.ecl(network); ecl.blockchainHeadersSubscribe().then((json) => { - api.log("electrum currentblock (electrum >= v1.1) ==>", "spv.currentblock"); - api.log(json, "spv.currentblock"); - if (json && json.hasOwnProperty("block_height")) { resolve(json.block_height); } else if (json && json.hasOwnProperty("height")) { diff --git a/routes/api/electrum/cache.js b/routes/api/electrum/cache.js index 3fc760d3..00d57661 100644 --- a/routes/api/electrum/cache.js +++ b/routes/api/electrum/cache.js @@ -17,8 +17,7 @@ module.exports = (api) => { api.electrumCache.pendingTx && api.electrumCache.pendingTx[network] && api.electrumCache.pendingTx[network][txid]) { - api.log(`pending txs cache remove ${network} txid ${txid}`, 'spv.cache.pending'); - delete api.electrumCache.pendingTx[network][txid]; + delete api.electrumCache.pendingTx[network][txid]; if (!Object.keys(api.electrumCache.pendingTx[network]).length) { delete api.electrumCache.pendingTx[network]; @@ -40,14 +39,8 @@ module.exports = (api) => { pub: options.pub, rawtx: options.rawtx, }; - api.log(`pending txs cache add ${network} txid ${txid} pub ${options.pub}`, 'spv.cache.pending'); - } else { - api.log(`pending txs cache ${network} txid ${txid} already exists`, 'spv.cache.pending'); - } + } } - - api.log('pending txs cache', 'spv.cache.pending'); - api.log(api.electrumCache.pendingTx, 'spv.cache.pending'); }; api.findPendingTxByAddress = (network, pub) => { @@ -89,17 +82,13 @@ module.exports = (api) => { if (fs.existsSync(`${api.paths.agamaDir}/spv-cache.json`)) { const localCache = fs.readFileSync(`${api.paths.agamaDir}/spv-cache.json`, 'utf8'); - api.log('local spv cache loaded from local file', 'spv.cache'); - try { api.electrumCache = JSON.parse(localCache); } catch (e) { - api.log('local spv cache file is damaged, create new', 'spv.cache'); api.saveLocalSPVCache(); api.electrumCache = {}; } } else { - api.log('local spv cache file is not found, create new', 'spv.cache'); api.saveLocalSPVCache(); api.electrumCache = {}; } @@ -117,7 +106,6 @@ module.exports = (api) => { fsnode.chmodSync(spvCacheFileName, '0666'); setTimeout(() => { - api.log(result, 'spv.cache'); resolve(result); }, 1000); }); @@ -130,13 +118,9 @@ module.exports = (api) => { const err = fs.writeFileSync(spvCacheFileName, JSON.stringify(api.electrumCache), 'utf8'); - if (err) - return api.log(err, 'spv.cache'); - + if (err) return null; fsnode.chmodSync(spvCacheFileName, '0666'); setTimeout(() => { - api.log(result, 'spv.cache'); - api.log(`spv-cache.json file is created successfully at: ${api.paths.agamaDir}`, 'spv.cache'); resolve(result); }, 2000); }); @@ -163,15 +147,11 @@ module.exports = (api) => { const _pendingTxFromCache = api.findPendingTxRawById(network.toUpperCase(), txid); if (_pendingTxFromCache) { - api.log(`${network} ${txid} get from pending txs cache`, 'spv.cache.transaction.pending'); resolve(_pendingTxFromCache); } else { - api.log(`${network.toUpperCase()} dpow confs spv: ${api.dpowCoins.indexOf(network.toUpperCase()) > -1 ? true : false}`, 'spv.dpow.confs'); - if (api.electrum.coinData[network.toLowerCase()].nspv) { if (!api.electrumCache[network].tx[txid]) { const nspvWrapper = api.nspvWrapper(network.toLowerCase()); - api.log(`nspv raw input tx ${txid}`, 'spv.cache'); nspvWrapper.blockchainTransactionGet(txid, true) .then((nspvGetTx) => { @@ -180,12 +160,10 @@ module.exports = (api) => { api.electrumCache[network].tx[txid] = nspvGetTx.hex; resolve(api.electrumCache[network].tx[txid]); } else { - api.log(`nspv unable to get raw input tx ${txid}`, 'spv.cache'); resolve(); } }); } else { - api.log(`electrum cached raw input tx ${txid}`, 'spv.cache'); resolve(api.electrumCache[network].tx[txid]); } } else { @@ -193,11 +171,6 @@ module.exports = (api) => { !api.electrumCache[network].verboseTx[txid] || (api.electrumCache[network].verboseTx[txid] && api.electrumCache[network].verboseTx[txid].hasOwnProperty('confirmations') && api.electrumCache[network].verboseTx[txid].hasOwnProperty('rawconfirmations') && api.electrumCache[network].verboseTx[txid].confirmations < 2) || (!api.electrumCache[network].verboseTx[txid].hasOwnProperty('confirmations') || !api.electrumCache[network].verboseTx[txid].hasOwnProperty('rawconfirmations'))) { - api.log(`electrum raw input tx ${txid}`, 'spv.cache'); - - if (api.dpowCoins.indexOf(network.toUpperCase()) > -1) { - api.log(`${network.toUpperCase()} request dpow data update`, 'spv.dpow.confs'); - } ecl.blockchainTransactionGet(txid, api.dpowCoins.indexOf(network.toUpperCase()) > -1 ? true : false) .then((_rawtxJSON) => { @@ -211,7 +184,6 @@ module.exports = (api) => { resolve(api.electrumCache[network].tx[txid]); }); } else { - api.log(`electrum cached raw input tx ${txid}`, 'spv.cache'); resolve(api.electrumCache[network].tx[txid]); } } @@ -225,7 +197,6 @@ module.exports = (api) => { } if (api.electrumCache[network].txDecoded[txid]) { - api.log(`electrum raw input tx decoded ${txid}`, 'spv.cache'); return api.electrumCache[network].txDecoded[txid]; } else { if (data) { @@ -239,7 +210,6 @@ module.exports = (api) => { api.getBlockHeader = (height, network, ecl) => { return new Promise((resolve, reject) => { if (height === 'pending') { - api.log(`electrum raw block ${height} use current time`, 'spv.cache.pending'); resolve({ timestamp: Math.floor(Date.now() / 1000), }); @@ -255,8 +225,6 @@ module.exports = (api) => { !api.electrumCache[network].blockHeader[height] || !Object.keys(api.electrumCache[network].blockHeader[height]).length ) { - api.log(`electrum raw block ${height}`, "spv.cache"); - ecl.blockchainBlockGetHeader(height).then((_rawtxJSON) => { if (typeof _rawtxJSON === "string") { _rawtxJSON = parseBlock(_rawtxJSON, btcnetworks[network] || btcnetworks.kmd); @@ -266,7 +234,6 @@ module.exports = (api) => { } } api.electrumCache[network].blockHeader[height] = _rawtxJSON; - // api.log(api.electrumCache[network].blockHeader[height], 'spv.cache'); resolve(_rawtxJSON); }); } else { diff --git a/routes/api/electrum/coins.js b/routes/api/electrum/coins.js index 10192364..dd34e4b7 100644 --- a/routes/api/electrum/coins.js +++ b/routes/api/electrum/coins.js @@ -54,13 +54,7 @@ module.exports = (api) => { }; // wait for spv connection to be established - const ecl = await api.ecl(coin); - - if (randomServer) { - api.log(`random ${coin} electrum server ${randomServer.ip}:${randomServer.port}`, 'spv.coin'); - } else { - api.log(`${coin} doesnt have any backup electrum servers`, 'spv.coin'); - } + await api.ecl(coin); if (Object.keys(api.electrumKeys).length > 0) { const _keys = api.wifToWif( @@ -105,14 +99,11 @@ module.exports = (api) => { for (let key in api.electrumJSNetworks) { if (!api.electrumServers[key] || (api.electrumServers[key] && !api.electrumServers[key].serverList)) { - //api.log(`disable ${key}, coin config check not passed`, 'spv.coin'); delete api.electrumServers[key]; } else { _totalCoins++; } } - - api.log(`total supported spv coins ${_totalCoins}`, 'spv.coin'); }; return api; diff --git a/routes/api/electrum/merkle.js b/routes/api/electrum/merkle.js index 16d48f0b..58a079b0 100644 --- a/routes/api/electrum/merkle.js +++ b/routes/api/electrum/merkle.js @@ -11,11 +11,6 @@ module.exports = (api) => { let hash = txid; let serialized; - api.log(`getMerkleRoot txid ${txid}`, 'spv.merkle'); - api.log(`getMerkleRoot pos ${pos}`, 'spv.merkle'); - api.log('getMerkleRoot proof', 'spv.merkle'); - api.log(`getMerkleRoot ${proof}`, 'spv.merkle'); - for (i = 0; i < proof.length; i++) { const _hashBuff = new Buffer(hash, 'hex'); const _proofBuff = new Buffer(proof[i], 'hex'); @@ -53,24 +48,18 @@ module.exports = (api) => { let ecl = await api.ecl(network); - api.log(`main server: ${mainServer}`, 'spv.merkle'); - api.log(`verification server: ${randomServer}`, 'spv.merkle'); - ecl.blockchainTransactionGetMerkle(txid, height) .then((merkleData) => { async function __verifyMerkle() { if (merkleData && merkleData.merkle && merkleData.pos) { - api.log('electrum getmerkle =>', 'spv.merkle'); - api.log(merkleData, 'spv.merkle'); const _res = api.getMerkleRoot( txid, merkleData.merkle, merkleData.pos ); - api.log(_res, 'spv.merkle'); ecl = await api.ecl(network, { ip: _randomServer[0], @@ -85,9 +74,6 @@ module.exports = (api) => { } else { if (blockInfo && blockInfo.merkle_root) { - api.log('blockinfo =>', 'spv.merkle'); - api.log(blockInfo, 'spv.merkle'); - api.log(blockInfo.merkle_root, 'spv.merkle'); if (blockInfo && blockInfo.merkle_root) { @@ -129,10 +115,6 @@ module.exports = (api) => { }; } - api.log('verifyMerkleByCoin', 'spv.merkle'); - api.log(_server, 'spv.merkle'); - api.log(_serverList, 'spv.merkle'); - return new Promise((resolve, reject) => { if (_serverList !== 'none') { let _filteredServerList = []; diff --git a/routes/api/electrum/nspv.js b/routes/api/electrum/nspv.js index 1b01be5c..dec33cc7 100644 --- a/routes/api/electrum/nspv.js +++ b/routes/api/electrum/nspv.js @@ -60,7 +60,6 @@ module.exports = (api) => { request(options, (error, response, body) => { if (body) { - api.log(body, 'spv.nspv.req'); // TODO: proper error handling in ecl calls try { if (JSON) resolve(JSON.parse(body)); @@ -126,8 +125,6 @@ module.exports = (api) => { process: nspvProcess, pid: nspvProcess.pid, }; - - api.log(`${coin.toUpperCase()} NSPV daemon PID ${nspvProcess.pid} (restart)`, 'spv.coin'); } }, 5000); } @@ -142,7 +139,6 @@ module.exports = (api) => { if (api.electrum.coinData[key] && api.electrum.coinData[key].nspv && api.nspvProcesses[key].pid) { - api.log(`NSPV daemon ${key.toUpperCase()} PID ${api.nspvProcesses[key].pid} is stopped`, 'spv.nspv.coin'); for (let i = 0; i < nspvCheckReadyInterval[key].length; i++) { clearInterval(nspvCheckReadyInterval[key][i]); } @@ -156,7 +152,6 @@ module.exports = (api) => { if (api.electrum.coinData[coin] && api.electrum.coinData[coin].nspv && api.nspvProcesses[coin].pid) { - api.log(`NSPV daemon ${coin.toUpperCase()} PID ${api.nspvProcesses[coin].pid} is stopped`, 'spv.nspv.coin'); for (let i = 0; i < nspvCheckReadyInterval[coin].length; i++) { clearInterval(nspvCheckReadyInterval[coin][i]); @@ -276,7 +271,6 @@ module.exports = (api) => { nspvGetTx.hasOwnProperty('hex')) { resolve(nspvGetTx.hex); } else { - api.log(`nspv unable to get raw input tx ${__txid}`, 'spv.cache'); resolve('unable to get raw transaction'); } } @@ -300,7 +294,6 @@ module.exports = (api) => { nspvBroadcast.expected === nspvBroadcast.broadcast) { resolve(nspvBroadcast.broadcast); } else { - api.log(`nspv unable to push transaction ${__rawtx}`, 'spv.cache'); resolve('unable to push raw transaction'); } } diff --git a/routes/api/electrum/servers.js b/routes/api/electrum/servers.js index fc7024c7..75b75db4 100644 --- a/routes/api/electrum/servers.js +++ b/routes/api/electrum/servers.js @@ -65,8 +65,6 @@ module.exports = (api) => { if (fs.existsSync(`${api.paths.agamaDir}/electrumServers.json`)) { const localElectrumServersList = fs.readFileSync(`${api.paths.agamaDir}/electrumServers.json`, 'utf8'); - api.log('electrum servers list set from local file', 'spv.serverList'); - try { api.electrumServers = JSON.parse(localElectrumServersList); api.mergeLocalKvElectrumServers(); @@ -74,8 +72,6 @@ module.exports = (api) => { api.log(e, 'spv.serverList'); } } else { - api.log('local electrum servers list file is not found!', 'spv.serverList'); - api.saveElectrumServersList(); } }; @@ -113,8 +109,6 @@ module.exports = (api) => { fsnode.chmodSync(electrumServersListFileName, '0666'); setTimeout(() => { - api.log(result, 'spv.serverList'); - api.log(`electrumServers.json file is created successfully at: ${api.paths.agamaDir}`, 'spv.serverList'); resolve(result); }, 2000); }); @@ -155,8 +149,6 @@ module.exports = (api) => { fsnode.chmodSync(kvElectrumServersListFileName, '0666'); setTimeout(() => { - api.log(result, 'spv.serverList'); - api.log(`kvElectrumServersCache.json file is created successfully at: ${api.paths.agamaDir}`, 'spv.serverList'); resolve(result); }, 2000); }); diff --git a/routes/api/electrum/transactions.js b/routes/api/electrum/transactions.js index 6dcf0f2d..b9360619 100644 --- a/routes/api/electrum/transactions.js +++ b/routes/api/electrum/transactions.js @@ -50,14 +50,10 @@ module.exports = (api) => { walletId = ecl.protocolVersion && ecl.protocolVersion === '1.4' ? pubToElectrumScriptHashHex(api.electrumKeys[coinLc].pub, btcnetworks[network.toLowerCase()] || btcnetworks.kmd) : address; } - api.log('electrum get_transactions ==>', 'spv.get_transactions'); - if (!config.full || ecl.insight) { ecl.blockchainAddressGetHistory(walletId) .then((json) => { - api.log(json, 'spv.get_transactions'); - json = api.sortTransactions(json, 'timestamp'); const retObj = { @@ -99,7 +95,6 @@ module.exports = (api) => { if (config.txid) { if (_flatTxHistoryFull[config.txid]) { - api.log(`found txid match ${_flatTxHistoryFull[config.txid].tx_hash}`, 'spv.transactions.txid'); json = [_flatTxHistoryFull[config.txid]]; } else { json = json.length > MAX_TX ? json.slice(0, MAX_TX) : json; @@ -110,11 +105,9 @@ module.exports = (api) => { if (_pendingTxs && _pendingTxs.length) { - api.log(`found ${_pendingTxs.length} pending txs in cache`, 'spv.transactions.pending.cache'); for (let i = 0; i < _pendingTxs.length; i++) { if (_flatTxHistory.indexOf(_pendingTxs[i].txid) > -1) { - api.log(`found ${_pendingTxs[i].txid} pending txs in cache for removal at pos ${_flatTxHistory.indexOf(_pendingTxs[i].txid)}`, 'spv.transactions.pending.cache'); api.updatePendingTxCache( network, @@ -124,7 +117,6 @@ module.exports = (api) => { } ); } else { - api.log(`push ${_pendingTxs[i].txid} from pending txs in cache to transactions history`, 'spv.transactions.pending.cache'); json.unshift(api.electrum.coinData[network.toLowerCase()].nspv ? { height: 'pending', @@ -138,7 +130,6 @@ module.exports = (api) => { } } - api.log(json.length, 'spv.get_transactions'); let index = 0; // callback hell, use await? @@ -178,7 +169,6 @@ module.exports = (api) => { } callback(); - api.log(`tx history main loop ${json.length} | ${index}`, 'spv.listtransactions'); } else { api.getTransaction( transaction.tx_hash, @@ -187,10 +177,6 @@ module.exports = (api) => { ) .then((_rawtxJSON) => { if (transaction.height === 'pending') transaction.height = currentHeight; - - api.log('electrum gettransaction ==>', 'spv.get_transactions'); - api.log((index + ' | ' + (_rawtxJSON.length - 1)), 'spv.get_transactions'); - // api.log(_rawtxJSON, 'spv.get_transactions'); // decode tx const _network = api.getNetworkData(network); @@ -217,11 +203,6 @@ module.exports = (api) => { let txInputs = []; let opreturn = false; - api.log(`decodedtx network ${network}`, 'spv.get_transactions'); - - api.log('decodedtx =>', 'spv.get_transactions'); - // api.log(decodedTx.outputs, 'spv.get_transactions'); - let index2 = 0; if (decodedTx && @@ -252,7 +233,6 @@ module.exports = (api) => { if (index2 === decodedTx.inputs.length || index2 === api.appConfig.general.electrum.maxVinParseLimit) { - api.log(`tx history decode inputs ${decodedTx.inputs.length} | ${index2} => main callback`, 'spv.get_transactions'); const _parsedTx = { network: decodedTx.network, format: decodedTx.format, @@ -400,7 +380,6 @@ module.exports = (api) => { } callback(); - api.log(`tx history main loop ${json.length} | ${index}`, 'spv.get_transactions'); } else { callback2(); } @@ -420,7 +399,6 @@ module.exports = (api) => { ); if (decodedVinVout) { - api.log(decodedVinVout.outputs[_decodedInput.n], 'spv.get_transactions'); txInputs.push(decodedVinVout.outputs[_decodedInput.n]); } checkLoop(); @@ -552,12 +530,8 @@ module.exports = (api) => { ecl = await api.ecl(network); } - api.log('electrum gettransaction =>', 'spv.gettransaction'); - ecl.blockchainTransactionGet(req.query.txid) .then((json) => { - api.log(json, 'spv.gettransaction'); - const retObj = { msg: 'success', result: json, diff --git a/routes/api/network/fees/btc/btcFees.js b/routes/api/network/fees/btc/btcFees.js index 51a67443..4571bac3 100644 --- a/routes/api/network/fees/btc/btcFees.js +++ b/routes/api/network/fees/btc/btcFees.js @@ -24,8 +24,6 @@ module.exports = (api) => { reject(e) } } else { - api.log('btcfees, use cache', 'spv.btcFees'); - resolve(btcFees) } }); From 3088d3d697aea26d83cdc37e381e459e6b631110 Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sat, 8 Jul 2023 16:33:33 +0200 Subject: [PATCH 3/6] Label txid correctly in electrum send result --- routes/api/electrum/send.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/routes/api/electrum/send.js b/routes/api/electrum/send.js index 5a7704d1..5c9d4a9f 100644 --- a/routes/api/electrum/send.js +++ b/routes/api/electrum/send.js @@ -58,8 +58,6 @@ module.exports = (api) => { }; api.electrum.conditionalListunspent = (grainedControlUtxos, ecl, address, network, full, verify) => { - api.log(`verify ${verify}`, 'spv.listunspent'); - return new Promise((resolve, reject) => { if (grainedControlUtxos) { resolve(grainedControlUtxos); @@ -631,7 +629,7 @@ module.exports = (api) => { const retObj = { msg: "success", - result: { ...preflightRes, broadcastRes } + result: { ...preflightRes, txid: broadcastRes } }; res.send(JSON.stringify(retObj)); From 04aa3f98d49b4e060fbf9fe810206e7df4ffcfbc Mon Sep 17 00:00:00 2001 From: michaeltout Date: Sat, 8 Jul 2023 22:52:21 +0200 Subject: [PATCH 4/6] Change source for BTC fees --- routes/api/network/fees/btc/btcFees.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/api/network/fees/btc/btcFees.js b/routes/api/network/fees/btc/btcFees.js index 4571bac3..fd4a4a4d 100644 --- a/routes/api/network/fees/btc/btcFees.js +++ b/routes/api/network/fees/btc/btcFees.js @@ -15,10 +15,10 @@ module.exports = (api) => { try { const res = await requestJson( "GET", - "https://bitcoinfees.earn.com/api/v1/fees/recommended" + "https://www.atomicexplorer.com/api/btc/fees" ); - const { hourFee, halfHourFee, fastestFee } = res + const { hourFee, halfHourFee, fastestFee } = res.result.recommended; resolve({low: hourFee, mid: halfHourFee, max: fastestFee}); } catch(e) { reject(e) From 000e271fc1e009bced4ab7fe75c6c132f96708d0 Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Sun, 9 Jul 2023 21:09:04 -0700 Subject: [PATCH 5/6] Update dependencies and submodule --- gui/Verus-Desktop-GUI | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/Verus-Desktop-GUI b/gui/Verus-Desktop-GUI index f82d9b59..cade0414 160000 --- a/gui/Verus-Desktop-GUI +++ b/gui/Verus-Desktop-GUI @@ -1 +1 @@ -Subproject commit f82d9b59420e437916a615732f46d736a5814244 +Subproject commit cade0414ccd5078915101dd1bfaf3c05d6f22f1b diff --git a/yarn.lock b/yarn.lock index 920b14d6..a4fcf7e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7716,7 +7716,7 @@ verror@^1.10.0: "verus-typescript-primitives@git+https://github.com/VerusCoin/verus-typescript-primitives.git": version "1.0.0" - resolved "git+https://github.com/VerusCoin/verus-typescript-primitives.git#8eeb27571b7d695a1a53e1062d424744599e6ec8" + resolved "git+https://github.com/VerusCoin/verus-typescript-primitives.git#c76a26e2ffedb2dc27fb6deeef3f8942e8a65244" dependencies: base64url "3.0.1" bn.js "5.2.1" @@ -7729,7 +7729,7 @@ verror@^1.10.0: "verus_bridgekeeper@git+https://github.com/VerusCoin/verusbridgekeeper.git": version "1.0.6" - resolved "git+https://github.com/VerusCoin/verusbridgekeeper.git#9099595a639f7e7eba79b013c750811a307928fe" + resolved "git+https://github.com/VerusCoin/verusbridgekeeper.git#2ff43b4e9ada824c9c683814e6bea9e42966658f" dependencies: axios "0.25.0" base58check "^2.0.0" From d8175c40d5b3a47930361eb0dbb2261343a8b008 Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Mon, 10 Jul 2023 18:32:39 -0700 Subject: [PATCH 6/6] Update version --- .gitlab-ci.yml | 4 ++-- package.json | 2 +- version.json | 4 ++-- version_build | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a9f46f9..0ab78190 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,8 @@ stages: variables: DOCKER_DRIVER: overlay2 DEFAULT_VERUSCOIN_BRANCH: release - VERUS_VERSION: 1.0.12-2 - VERUSCOIN_VERSION: 1.0.12-2 + VERUS_VERSION: 1.0.12-4 + VERUSCOIN_VERSION: 1.0.12-4 KOMODO_VERSION: 0.8.0 KOMODO_DOWNLOAD_URL: https://github.com/KomodoPlatform/komodo/releases/download PIRATE_VERSION: 5.7.4 diff --git a/package.json b/package.json index 6ac13327..54aa6ac0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "verus-desktop", "productName": "Verus-Desktop", - "version": "1.0.12-2", + "version": "1.0.12-4", "description": "Verus Desktop Wallet App", "main": "main.js", "scripts": { diff --git a/version.json b/version.json index 59e36df4..2877c03c 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { - "version": "1.0.12-2", - "minVersion": "1.0.12-2", + "version": "1.0.12-4", + "minVersion": "1.0.12-4", "versionUrl": "https://raw.githubusercontent.com/VerusCoin/Verus-Desktop/master/version.json", "repository": "https://github.com/VerusCoin/Verus-Desktop/" } diff --git a/version_build b/version_build index de382add..c60f7155 100644 --- a/version_build +++ b/version_build @@ -1 +1 @@ -1.0.12-2 +1.0.12-4