From 36269ca2c969b153a2249ae2e43c9b97c919246f Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 7 Mar 2020 18:33:19 +0200 Subject: [PATCH 001/132] POS implementation #2 --- .../blockchain/global/Blockchain-Genesis.js | 19 ++++++++++++++++++- src/consts/const_global.js | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index b9c1642c8..6f750f617 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -42,9 +42,12 @@ class BlockchainGenesis{ if (typeof height === "string") height = Number.parseInt(height); + // no pos activated if (height < consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) return false; - else { + + // pos 66% activated + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION){ //0..19 pos //20..29 pow @@ -56,6 +59,20 @@ class BlockchainGenesis{ } + //0..9 pos + //9..19 pos + //19..29 pos + //29..39 pos + //39..49 pos + //49..59 pos + //59..69 pos + //69..79 pos + //79..89 pos + + //89..99 pow + if (height % 100 < 90) return true; + else return false; + } } diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 0b64ae7ac..9b09e3610 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -77,6 +77,8 @@ consts.BLOCKCHAIN = { TRANSACTIONS_INCLUDING_ONLY_HEADER: 567698, // SAME AS POS POS_ACTIVATION: 567810, + POS90_ACTIVATION: 1500000, //it needs to be % 30 === 0 + } }; From 379fc16fcbab7fdb0f279c4b83b3700ed5a80f03 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 7 Mar 2020 18:55:48 +0200 Subject: [PATCH 002/132] POS implementation more comments --- .../blockchain/global/Blockchain-Genesis.js | 27 +++++++++++-------- src/consts/const_global.js | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 6f750f617..83d17be82 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -59,17 +59,22 @@ class BlockchainGenesis{ } - //0..9 pos - //9..19 pos - //19..29 pos - //29..39 pos - //39..49 pos - //49..59 pos - //59..69 pos - //69..79 pos - //79..89 pos - - //89..99 pow + //0..9 pos -10% + //9..19 pos -10% + //19..29 pos -10% + //29..39 pos -10% + //39..49 pos -10% + //49..59 pos -10% + //59..69 pos -10% + //69..79 pos -10% + //79..89 pos -10% + + //89..99 pow -10% + + // total 90 + 10 + // pos = 90 / 100 + // pow = 10 / 100 + if (height % 100 < 90) return true; else return false; diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 9b09e3610..e36474589 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -77,7 +77,7 @@ consts.BLOCKCHAIN = { TRANSACTIONS_INCLUDING_ONLY_HEADER: 567698, // SAME AS POS POS_ACTIVATION: 567810, - POS90_ACTIVATION: 1500000, //it needs to be % 30 === 0 + POS90_ACTIVATION: 1500000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 } From 41f20873b9450b521d53eab50968055734dc491f Mon Sep 17 00:00:00 2001 From: Ionut Moraru Date: Wed, 1 Apr 2020 12:20:52 +0300 Subject: [PATCH 003/132] Update Miner-Pool-Settings.js --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 2cb01e372..aa05d3a08 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -236,7 +236,7 @@ class MinerPoolSettings { await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); await this.addPoolList("/pool/1/WebDollarPoolWin/0.01/60ba45707efcf2292e1c8d4c6a16b602a58aa8bee04d7d3645198afa4f8435e0/https:$$webdollarpool.win:80", undefined, true); - await this.addPoolList("/pool/1/Timi/0.001/228f7ab63884af5e86eca38ad08353170f57125336362bbe9bd3417f3ff2bae5/https:$$pool.timi.ro:443", undefined, true); + await this.addPoolList("/pool/1/Timi/0.001/48bfe934cc6cec36c58e3f8468a24a495cd38d77cd4a9af0e9a6e9f13741fcd7/https:$$pool.timi.ro:443", undefined, true); } async _replacePoolURL(url = ''){ From 8f77e7d9ff3683be902cc026935a2cbe6a4aadf4 Mon Sep 17 00:00:00 2001 From: Ionut Moraru Date: Thu, 2 Apr 2020 15:58:19 +0300 Subject: [PATCH 004/132] Update Miner-Pool-Settings.js --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index aa05d3a08..dbc0a161b 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -235,7 +235,6 @@ class MinerPoolSettings { await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); - await this.addPoolList("/pool/1/WebDollarPoolWin/0.01/60ba45707efcf2292e1c8d4c6a16b602a58aa8bee04d7d3645198afa4f8435e0/https:$$webdollarpool.win:80", undefined, true); await this.addPoolList("/pool/1/Timi/0.001/48bfe934cc6cec36c58e3f8468a24a495cd38d77cd4a9af0e9a6e9f13741fcd7/https:$$pool.timi.ro:443", undefined, true); } From f4baff59dbccb15aaa39e14812b4dce72bf74145 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 2 May 2020 21:56:40 +0300 Subject: [PATCH 005/132] new testnet version for POS90 --- src/consts/const_global.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index e36474589..e265f041f 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -267,10 +267,10 @@ consts.SETTINGS = { NODE: { - VERSION: "1.212.0", + VERSION: "1.220.0", - VERSION_COMPATIBILITY: "1.200.3", - VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", + VERSION_COMPATIBILITY: "1.220.0", + VERSION_COMPATIBILITY_POOL_MINERS: "1.220.0", VERSION_COMPATIBILITY_UPDATE: "", From 59b79e883ca824c7b0c2c4139b72eea1d21cbefc Mon Sep 17 00:00:00 2001 From: CryptoCoinGB <45538866+CryptoCoinGB@users.noreply.github.com> Date: Sun, 3 May 2020 23:49:08 +0100 Subject: [PATCH 006/132] Update blockchain-bootstrap-locations.md Added Timi server I have just set up --- tutorials/blockchain-bootstrap-locations.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tutorials/blockchain-bootstrap-locations.md b/tutorials/blockchain-bootstrap-locations.md index 158174d60..afb098af1 100644 --- a/tutorials/blockchain-bootstrap-locations.md +++ b/tutorials/blockchain-bootstrap-locations.md @@ -2,7 +2,7 @@ ----------- -#### Primary high speed backup source provided by CryptoCoinGB: +#### High speed backup source provided by CryptoCoinGB: http://webd-blockchain.ddns.net:9001/blockchainDB3.tar.gz Backups are created at 00:00, 06:00, 12:00 and 18:00 GMT. @@ -17,16 +17,17 @@ Instructions (from within your WebDollar folder): ----------- -***PLEASE NOTE THIS SOURCE IS CURRENTLY UNAVAILABLE*** +#### High speed backup source provided by TimiDani: +http://blockchain.timi.ro/blockchainDB3.tar.gz -#### Primary high speed backup source provided by VPN Romania: -https://webdftp.vpnromania.ro/ftp/blockchainDB3.tar.gz +Backups are created at 00:00, 06:00, 12:00 and 18:00 EEST. +If your download is initiated at these times it may fail due to the file being updated. Instructions (from within your WebDollar folder): + delete the old blockchainDB3 directory if it exists (command: sudo rm -r blockchainDB3) + make a new empty blockchainDB3 directory (command: mkdir blockchainDB3) + open the new directory (command: cd blockchainDB3) -+ use 'wget' to download the file from the link above (command: wget https://webdftp.vpnromania.ro/ftp/blockchainDB3.tar.gz) ++ use 'wget' to download the file from the link above (command: wget http://blockchain.timi.ro/blockchainDB3.tar.gz) + extract the file (command: tar -zxvf blockchainDB3.tar.gz -C .) ----------- From 685638e19bccb5f00f9ea24ec3844966b515a984 Mon Sep 17 00:00:00 2001 From: Alexandru Budisteanu Date: Mon, 15 Jun 2020 14:47:47 +0300 Subject: [PATCH 007/132] Blockchain Difficulty fixed --- .../blockchain/global/Blockchain-Genesis.js | 46 ++++++++++++------- .../difficulty/Blockchain-Difficulty.js | 8 ++-- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 83d17be82..9a50e9656 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -38,6 +38,16 @@ class BlockchainGenesis{ return 0; } + PoSModulo(height){ + if (typeof height === "string") height = Number.parseInt(height); + + // no pos activated + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) return 0; + + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) return 30; + else return 100; + } + isPoSActivated(height){ if (typeof height === "string") height = Number.parseInt(height); @@ -57,26 +67,30 @@ class BlockchainGenesis{ //29,0..19 pos //20..29 pow - } + } else { + + //0..9 pos -10% + //9..19 pos -10% + //19..29 pos -10% + //29..39 pos -10% + //39..49 pos -10% + //49..59 pos -10% + //59..69 pos -10% + //69..79 pos -10% + //79..89 pos -10% + + //89..99 pow -10% - //0..9 pos -10% - //9..19 pos -10% - //19..29 pos -10% - //29..39 pos -10% - //39..49 pos -10% - //49..59 pos -10% - //59..69 pos -10% - //69..79 pos -10% - //79..89 pos -10% + // total 90 + 10 + // pos = 90 / 100 + // pow = 10 / 100 - //89..99 pow -10% + if (height % 100 < 90) return true; + else return false; + + } - // total 90 + 10 - // pos = 90 / 100 - // pow = 10 / 100 - if (height % 100 < 90) return true; - else return false; } diff --git a/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js b/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js index e4871f332..8dea84e66 100644 --- a/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js +++ b/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js @@ -68,8 +68,8 @@ class BlockchainDifficulty{ let firstBlock = (blockNumber+1) - consts.BLOCKCHAIN.DIFFICULTY.NO_BLOCKS; // blockNumber is not included //avoid first Block, because the firstBlock is correlated with the last block of the POW - if ( blockNumber >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION && (blockNumber+1) % 30 === 0) - firstBlock +=1; + const PoSModulo = BlockchainGenesis.PoSModulo(blockNumber); + if ( PoSModulo && (blockNumber+1) % PoSModulo === 0 ) firstBlock += 1 //adding blocks 0..8 for (let i = firstBlock; i < blockNumber; i++) { @@ -128,8 +128,8 @@ class BlockchainDifficulty{ let firstBlock = (blockNumber+1) - consts.BLOCKCHAIN.DIFFICULTY.NO_BLOCKS; // blockNumber is not included //avoid first Block, because the firstBlock is correlated with the last block of the POW - if ((blockNumber+1) % 30 === 10) - firstBlock +=1; + const PoSModulo = BlockchainGenesis.PoSModulo(blockNumber); + if ( PoSModulo && (blockNumber+1) % PoSModulo === 0 ) firstBlock += 1 //adding blocks 0..8 for (let i = firstBlock; i < blockNumber; i++) { From c0eb4c253b00294d795979af8335795f85e9398c Mon Sep 17 00:00:00 2001 From: Alexandru Budisteanu Date: Mon, 15 Jun 2020 15:00:22 +0300 Subject: [PATCH 008/132] getDifficultyTarget possible fixed --- .../blockchain/Interface-Blockchain.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index 558ff9382..477778a23 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -183,8 +183,13 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ if (POSRecalculation && height >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1){ - if (height % 30 === 29 ) height = height - 10; //first POS, get the last proof of Stake - else if (height % 30 === 19 ) height = height - 20; //first POW, get the last proof of Work + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { + if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake + else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work + } else { + if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake + else if (height % 100 === 89) height = height - 20; //first POW, get the last proof of work + } } From ac3e30b7588e22cbfd895e4e5091762e4db0b112 Mon Sep 17 00:00:00 2001 From: Alexandru Budisteanu Date: Mon, 15 Jun 2020 15:29:22 +0300 Subject: [PATCH 009/132] blocks/between/ API route fixes --- .../node-server/API-router/Node-API-Router.js | 4 ++-- .../API/public/Node-API-Public-Blocks.js | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/node/sockets/node-server/API-router/Node-API-Router.js b/src/node/sockets/node-server/API-router/Node-API-Router.js index f49630013..9e7871ace 100644 --- a/src/node/sockets/node-server/API-router/Node-API-Router.js +++ b/src/node/sockets/node-server/API-router/Node-API-Router.js @@ -43,8 +43,8 @@ class NodeAPIRouter{ this._addRoute('', NodeAPIPublic.info, nodeApiType, 200, app, prefix, middleWare ); // Return blocks information - this._addRoute('blocks/between/:blocks', NodeAPIPublicBlocks.blocks, nodeApiType, 20 , app, prefix, middleWare ); - + this._addRoute('blocks/between/:block_start', NodeAPIPublicBlocks.blocks, nodeApiType, 20 , app, prefix, middleWare ); + this._addRoute('blocks/between/:block_start/:block_end', NodeAPIPublicBlocks.blocks, nodeApiType, 20 , app, prefix, middleWare ); // Return block information this._addRoute( 'blocks/at/:block', NodeAPIPublicBlocks.block, nodeApiType, 20, app, prefix, middleWare ); diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js index 153e7e0f0..1658ef2e8 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js @@ -7,14 +7,21 @@ class NodeAPIPublicBlocks{ async blocks(req, res){ - let block_start = req.block_start; - try { - if (block_start >= Blockchain.blockchain.blocks.length) throw {message: "block start is not correct: " + block_start}; + const MAX_BLOCKS = 100; + + const startMin = Math.max(0, Blockchain.blockchain.blocks.length - MAX_BLOCKS); + const endMax = Blockchain.blockchain.blocks.length; + + let block_start = req.block_start || startMin; + let block_end = req.block_end || endMax; + + if (block_start < 0 || block_start >= endMax) throw {message: "block start is not correct: " + block_start}; + if (block_end < 0 || block_end >= endMax ) throw {message: "block end is not correct: " + block_start}; - let blocks_to_send = []; - for (let i=block_start; i Date: Mon, 15 Jun 2020 15:34:16 +0300 Subject: [PATCH 010/132] blocks/between/ verify LIMIT --- .../node-server/API/public/Node-API-Public-Blocks.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js index 1658ef2e8..e8fab4e83 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js @@ -9,9 +9,9 @@ class NodeAPIPublicBlocks{ try { - const MAX_BLOCKS = 100; + const LIMIT_BLOCKS = 25; - const startMin = Math.max(0, Blockchain.blockchain.blocks.length - MAX_BLOCKS); + const startMin = Math.max(0, Blockchain.blockchain.blocks.length - LIMIT_BLOCKS); const endMax = Blockchain.blockchain.blocks.length; let block_start = req.block_start || startMin; @@ -20,6 +20,8 @@ class NodeAPIPublicBlocks{ if (block_start < 0 || block_start >= endMax) throw {message: "block start is not correct: " + block_start}; if (block_end < 0 || block_end >= endMax ) throw {message: "block end is not correct: " + block_start}; + if (block_end - block_start > LIMIT_BLOCKS) throw {message: "requested too many blocks: " + block_end - block_start }; + const blocks_to_send = []; for (let i=block_start; i Date: Mon, 15 Jun 2020 18:27:23 +0300 Subject: [PATCH 011/132] blocks/between/ fix LIMIT bound --- .../sockets/node-server/API/public/Node-API-Public-Blocks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js index e8fab4e83..1cd87f940 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js @@ -17,8 +17,8 @@ class NodeAPIPublicBlocks{ let block_start = req.block_start || startMin; let block_end = req.block_end || endMax; - if (block_start < 0 || block_start >= endMax) throw {message: "block start is not correct: " + block_start}; - if (block_end < 0 || block_end >= endMax ) throw {message: "block end is not correct: " + block_start}; + if (block_start < 0 || block_start > endMax) throw {message: "block start is not correct: " + block_start}; + if (block_end < 0 || block_end > endMax ) throw {message: "block end is not correct: " + block_start}; if (block_end - block_start > LIMIT_BLOCKS) throw {message: "requested too many blocks: " + block_end - block_start }; From 92f08727496ececd45a6d6f2e1e1f1c536eaeddb Mon Sep 17 00:00:00 2001 From: Alexandru Budisteanu Date: Wed, 17 Jun 2020 01:51:53 +0300 Subject: [PATCH 012/132] getDifficultyTarget fix --- .../interface-blockchain/blockchain/Interface-Blockchain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index 477778a23..dd506626c 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -188,7 +188,7 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work } else { if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake - else if (height % 100 === 89) height = height - 20; //first POW, get the last proof of work + else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work } } From f0c145e8d1aa22ed063a98067e91324424b8e604 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 29 Jun 2020 00:36:53 +0300 Subject: [PATCH 013/132] CONCURRENCY_BLOCK_DOWNLOAD_MINERS_NUMBER increased --- src/consts/const_global.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index e265f041f..c1a0bae9f 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -287,7 +287,7 @@ consts.SETTINGS = { STATUS_INTERVAL: 40 * 1000, LATENCY_CHECK: 5*1000, MAX_ALLOWED_LATENCY: 5*1000, //miliseconds - CONCURRENCY_BLOCK_DOWNLOAD_MINERS_NUMBER: (process.env.BROWSER? 10 : 30), + CONCURRENCY_BLOCK_DOWNLOAD_MINERS_NUMBER: (process.env.BROWSER? 10 : 100), WAITLIST: { From 687f7b2b4d007376f5e2beebac435b69a2d01022 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 29 Jun 2020 00:53:29 +0300 Subject: [PATCH 014/132] POS90 forks fixed --- .../blockchain/forks/Interface-Blockchain-Fork-Basic.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js index 96980c5ff..cf51fd0d4 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js +++ b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js @@ -122,8 +122,13 @@ class InterfaceBlockchainFork { if (height >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1) { //calculating the virtualization of the POS - if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake - else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { + if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake + else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work + } else { + if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake + else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work + } forkHeight = height - this.forkStartingHeight; } From 71a036a0ce39ec52b1e993091a4c2598e4017606 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 29 Jun 2020 01:04:35 +0300 Subject: [PATCH 015/132] revert 30 back CONCURRENCY_BLOCK_DOWNLOAD_MINERS_NUMBER --- src/consts/const_global.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index c1a0bae9f..e265f041f 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -287,7 +287,7 @@ consts.SETTINGS = { STATUS_INTERVAL: 40 * 1000, LATENCY_CHECK: 5*1000, MAX_ALLOWED_LATENCY: 5*1000, //miliseconds - CONCURRENCY_BLOCK_DOWNLOAD_MINERS_NUMBER: (process.env.BROWSER? 10 : 100), + CONCURRENCY_BLOCK_DOWNLOAD_MINERS_NUMBER: (process.env.BROWSER? 10 : 30), WAITLIST: { From a543b8a54c4ee6a45c3e52cff0f72fb7883f426d Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 20 Jul 2020 16:02:05 +0300 Subject: [PATCH 016/132] POS90 merge --- .../ppow-blockchain/blocks/PPoW-Blockchain-Block.js | 2 ++ src/consts/const_global.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js b/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js index 636104965..583bea6a0 100644 --- a/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js +++ b/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js @@ -301,11 +301,13 @@ class PPoWBlockchainBlock extends InterfaceBlockchainBlock{ throw {message: "interlink has different sizes"}; for (let i = 0; i < interlink.length; i++) { + if (interlink[i].height !== this.interlink[i].height) throw {message: "interlink height is different"}; if (!BufferExtended.safeCompare(interlink[i].blockId, this.interlink[i].blockId)) throw {message: "interlink prevBlock height is different"}; + } } diff --git a/src/consts/const_global.js b/src/consts/const_global.js index e265f041f..2df1719c7 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -77,7 +77,7 @@ consts.BLOCKCHAIN = { TRANSACTIONS_INCLUDING_ONLY_HEADER: 567698, // SAME AS POS POS_ACTIVATION: 567810, - POS90_ACTIVATION: 1500000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 + POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 } @@ -267,7 +267,7 @@ consts.SETTINGS = { NODE: { - VERSION: "1.220.0", + VERSION: "1.3.0", VERSION_COMPATIBILITY: "1.220.0", VERSION_COMPATIBILITY_POOL_MINERS: "1.220.0", From f002df63d3a4e2e3202e022946a2a4ec2a534884 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 20 Jul 2020 18:04:48 +0300 Subject: [PATCH 017/132] POS90 fix for connecting with older nodes until hard fork --- src/consts/const_global.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 2df1719c7..703ab1e8f 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -267,10 +267,10 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.0", + VERSION: "1.3.01", - VERSION_COMPATIBILITY: "1.220.0", - VERSION_COMPATIBILITY_POOL_MINERS: "1.220.0", + VERSION_COMPATIBILITY: "1.200.3", + VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", VERSION_COMPATIBILITY_UPDATE: "", From dcc73e2670ea3d1494def0704488f8636798900f Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 20 Jul 2020 19:39:05 +0300 Subject: [PATCH 018/132] POS90 fix --- .../blockchain/global/difficulty/Blockchain-Difficulty.js | 4 ++-- .../ppow-blockchain/blocks/PPoW-Blockchain-Block.js | 2 +- .../ppow-blockchain/PPoW-Blockchain-Interlink.test.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js b/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js index 8dea84e66..2eb9b93a3 100644 --- a/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js +++ b/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js @@ -69,7 +69,7 @@ class BlockchainDifficulty{ //avoid first Block, because the firstBlock is correlated with the last block of the POW const PoSModulo = BlockchainGenesis.PoSModulo(blockNumber); - if ( PoSModulo && (blockNumber+1) % PoSModulo === 0 ) firstBlock += 1 + if ( PoSModulo && ((blockNumber+1) % PoSModulo === 0) ) firstBlock += 1 //adding blocks 0..8 for (let i = firstBlock; i < blockNumber; i++) { @@ -129,7 +129,7 @@ class BlockchainDifficulty{ //avoid first Block, because the firstBlock is correlated with the last block of the POW const PoSModulo = BlockchainGenesis.PoSModulo(blockNumber); - if ( PoSModulo && (blockNumber+1) % PoSModulo === 0 ) firstBlock += 1 + if ( PoSModulo && (blockNumber+1) % PoSModulo === 10 ) firstBlock += 1 //adding blocks 0..8 for (let i = firstBlock; i < blockNumber; i++) { diff --git a/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js b/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js index 636104965..8401e5e19 100644 --- a/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js +++ b/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js @@ -302,7 +302,7 @@ class PPoWBlockchainBlock extends InterfaceBlockchainBlock{ for (let i = 0; i < interlink.length; i++) { if (interlink[i].height !== this.interlink[i].height) - throw {message: "interlink height is different"}; + throw {message: "interlink height is different", interlink:i , height: this.height}; if (!BufferExtended.safeCompare(interlink[i].blockId, this.interlink[i].blockId)) throw {message: "interlink prevBlock height is different"}; diff --git a/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js b/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js index 1b535990e..5cddcc36b 100644 --- a/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js +++ b/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js @@ -37,11 +37,11 @@ describe('test PPoW-Blockchain interlink data structure', () => { let serializedBuffer = block._serializeInterlink(); block._deserializeInterlink(serializedBuffer, 0); - assert(block.interlink.length === interlink.length, "Interlink length differ: " + block.interlink.length + "!==" + interlink.length); + assert(block.interlink.length === interlink.length, "Interlink length diffent: " + block.interlink.length + "!==" + interlink.length); for (let i = 0; i < interlink.length; ++i) { - assert(block.interlink[i].height === interlink[i].height, "Interlink height differ: " + block.interlink[i].height + "!==" + interlink[i].height); - assert(block.interlink[i].blockId.equals(interlink[i].blockId), "Interlink blockId differ: " + block.interlink[i].blockId.toString("hex") + "!==" + interlink[i].blockId.toString("hex") + "i = " + i); + assert(block.interlink[i].height === interlink[i].height, "Interlink height diffent: " + block.interlink[i].height + "!==" + interlink[i].height); + assert(block.interlink[i].blockId.equals(interlink[i].blockId), "Interlink blockId diffent: " + block.interlink[i].blockId.toString("hex") + "!==" + interlink[i].blockId.toString("hex") + "i = " + i); } }); From a23e5c57cd1282a51fd51f01caa284eae3497f4c Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 20 Jul 2020 19:42:08 +0300 Subject: [PATCH 019/132] new version 1.3.02 --- src/consts/const_global.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 703ab1e8f..bc9c2deae 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -267,7 +267,7 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.01", + VERSION: "1.3.02", VERSION_COMPATIBILITY: "1.200.3", VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", From 808b90d9abae0d134fdc52249cd9df9fb27acf08 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 20 Jul 2020 20:04:39 +0300 Subject: [PATCH 020/132] code refactor Difficulty --- .../blockchain/global/difficulty/Blockchain-Difficulty.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js b/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js index 2eb9b93a3..377449083 100644 --- a/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js +++ b/src/common/blockchain/global/difficulty/Blockchain-Difficulty.js @@ -129,7 +129,7 @@ class BlockchainDifficulty{ //avoid first Block, because the firstBlock is correlated with the last block of the POW const PoSModulo = BlockchainGenesis.PoSModulo(blockNumber); - if ( PoSModulo && (blockNumber+1) % PoSModulo === 10 ) firstBlock += 1 + if ( PoSModulo && ( (blockNumber+1) % PoSModulo === 10 ) ) firstBlock += 1 //adding blocks 0..8 for (let i = firstBlock; i < blockNumber; i++) { From e3b5cc1fd0a6300a7c0daba4b2bfe25cb9e010d5 Mon Sep 17 00:00:00 2001 From: sorinmircioiu Date: Mon, 27 Jul 2020 01:03:52 +0300 Subject: [PATCH 021/132] Update fallback_nodes_list.js Updated Sorin M full node port from 3333 to 8443. --- .../service/discovery/fallbacks/fallback_nodes_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index 1774a4f9a..d734189da 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -9,7 +9,7 @@ export default { //--------------Community FallBack Nodes------------------- //--------------------------------------------------------- - {"addr": ["https://webd.5q.ro:3333"]}, // Thanks to Sorin M + {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M //{"addr": ["https://ez.cnbacolt.com:443"]}, //{"addr": ["https://server.cnbacolt.com:443"]}, From 86abdbbeb4945b151de98da205a6438243c5fdd3 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 3 Aug 2020 12:26:09 +0300 Subject: [PATCH 022/132] POS100 --- src/common/blockchain/global/Blockchain-Genesis.js | 8 +++++--- src/consts/const_global.js | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 9a50e9656..688c20bd0 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -45,7 +45,9 @@ class BlockchainGenesis{ if (height < consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) return 0; if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) return 30; - else return 100; + else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) return 100; + else return 0; + } isPoSActivated(height){ @@ -67,7 +69,7 @@ class BlockchainGenesis{ //29,0..19 pos //20..29 pow - } else { + } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { //0..9 pos -10% //9..19 pos -10% @@ -88,7 +90,7 @@ class BlockchainGenesis{ if (height % 100 < 90) return true; else return false; - } + } else return true; // pos 100% diff --git a/src/consts/const_global.js b/src/consts/const_global.js index bc9c2deae..9e0daa4d1 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,6 +79,8 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 + POS100_ACTIVATION: 1750000, //it needs to be % 100 === 0, better it should be % 100 = 0 && % 30 === 0 + } }; From 802b843c4795703d0daa1a2e3abc1a2fd864ac0c Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 3 Aug 2020 12:27:41 +0300 Subject: [PATCH 023/132] improve comment --- src/consts/const_global.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 9e0daa4d1..da84bb66b 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,7 +79,7 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 - POS100_ACTIVATION: 1750000, //it needs to be % 100 === 0, better it should be % 100 = 0 && % 30 === 0 + POS100_ACTIVATION: 1750000, //it needs to be % 100 === 0 } From bd6cd9ced78a16c1ce6b942924681591be7492d6 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 3 Aug 2020 12:45:18 +0300 Subject: [PATCH 024/132] more fixes for POS100 and prepare a new testnet --- .../interface-blockchain/blockchain/Interface-Blockchain.js | 2 +- .../blockchain/forks/Interface-Blockchain-Fork-Basic.js | 2 +- src/consts/const_global.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index dd506626c..907a6d29c 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -186,7 +186,7 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work - } else { + } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work } diff --git a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js index cf51fd0d4..02d4cd36b 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js +++ b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js @@ -125,7 +125,7 @@ class InterfaceBlockchainFork { if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work - } else { + } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work } diff --git a/src/consts/const_global.js b/src/consts/const_global.js index da84bb66b..8b4f37a5b 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.02", + VERSION: "1.3.1", - VERSION_COMPATIBILITY: "1.200.3", - VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", + VERSION_COMPATIBILITY: "1.3.1", + VERSION_COMPATIBILITY_POOL_MINERS: "1.3.1", VERSION_COMPATIBILITY_UPDATE: "", From 24a1d414a4384beb4aa2fb8cd2bb16f17734f50b Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 3 Aug 2020 13:13:04 +0300 Subject: [PATCH 025/132] POS100_POW_LOWER_DIFFICULTY_HEIGHT --- .../interface-blockchain/blockchain/Interface-Blockchain.js | 3 +++ src/consts/const_global.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index 907a6d29c..e3620832e 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -181,6 +181,9 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ if (height === -1) return BlockchainGenesis.difficultyTarget; if ( height === consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1) return BlockchainGenesis.difficultyTargetPOS; + //TODO MUST BE REMOVED FOR MAIN NET!!!! + if (height === consts.BLOCKCHAIN.HARD_FORKS.POS100_POW_LOWER_DIFFICULTY_HEIGHT ) return consts.BLOCKCHAIN.HARD_FORKS.POS100_POW_LOWER_DIFFICULTY; + if (POSRecalculation && height >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1){ if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 8b4f37a5b..f9c0d8d8e 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -81,6 +81,10 @@ consts.BLOCKCHAIN = { POS100_ACTIVATION: 1750000, //it needs to be % 100 === 0 + //TODO MUST BE REMOVED FOR MAIN NET!!!! + POS100_POW_LOWER_DIFFICULTY_HEIGHT: 1749990, // lower the difficulty of the forked chain. It must be % 90 === 0 and first POW block after the hard fork + POS100_POW_LOWER_DIFFICULTY: new Buffer ( "00000112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex" ), //hard difficulty + } }; From b832aec329ff41b6c63f23f3cccf75f140c0f54b Mon Sep 17 00:00:00 2001 From: LOFT-source <56698687+LOFT-source@users.noreply.github.com> Date: Wed, 19 Aug 2020 11:49:58 -0700 Subject: [PATCH 026/132] LOFTpool added --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index dbc0a161b..d6ebab7b6 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -228,6 +228,7 @@ class MinerPoolSettings { } async _addPoolsList(){ + await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); await this.addPoolList("/pool/1/CanadianStakePool/0/b96ebf01cefa08edae50a5bf495a8f61261bc918fa4e62c4cbbe3ebe6bacde21/https:$$webdollarpool.ca:443", undefined, true); await this.addPoolList("/pool/1/ImperiumStake/0/bf883f6f0e7c68c415e791eb77ddf55e43e352fa673fc35536937d074178dd80/https:$$webdollarpool.eu:443", undefined, true); await this.addPoolList("/pool/1/2MooNPooL/0.02/3c9456990ea9d0595f3a438e46b656063a42e6ad7f4fb1316b4a2b4086bfe9b0/https:$$2moonPool.ddns.net:3335", undefined, true); From 303fbcf462ad4fe806c806f49b18ff2d05d6b7ae Mon Sep 17 00:00:00 2001 From: CryptoCoinGB <45538866+CryptoCoinGB@users.noreply.github.com> Date: Sat, 5 Sep 2020 19:58:45 +0100 Subject: [PATCH 027/132] Add Splashpool USA Added pool on behalf of Splashpool USA owner --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index d6ebab7b6..7fe987f2b 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -228,6 +228,7 @@ class MinerPoolSettings { } async _addPoolsList(){ + await this.addPoolList("/pool/1/WEBD-Splashpool-USA/0.02/61761896b4d958b3cc9073ae3c724a127b4ee5b31f6b8dcafd29643cf20a796a/https:$$splashpool.myvnc.com:8080", undefined, true); await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); await this.addPoolList("/pool/1/CanadianStakePool/0/b96ebf01cefa08edae50a5bf495a8f61261bc918fa4e62c4cbbe3ebe6bacde21/https:$$webdollarpool.ca:443", undefined, true); await this.addPoolList("/pool/1/ImperiumStake/0/bf883f6f0e7c68c415e791eb77ddf55e43e352fa673fc35536937d074178dd80/https:$$webdollarpool.eu:443", undefined, true); From f2e6dd85f0d198dc7c8152d8ae5a8db869d9916a Mon Sep 17 00:00:00 2001 From: tomoneverde <34745293+tomonetml@users.noreply.github.com> Date: Mon, 7 Sep 2020 12:40:50 +0200 Subject: [PATCH 028/132] Remove inactive pools as per webdollar.network/#/pools --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 7fe987f2b..cf01e53c2 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -230,13 +230,9 @@ class MinerPoolSettings { async _addPoolsList(){ await this.addPoolList("/pool/1/WEBD-Splashpool-USA/0.02/61761896b4d958b3cc9073ae3c724a127b4ee5b31f6b8dcafd29643cf20a796a/https:$$splashpool.myvnc.com:8080", undefined, true); await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); - await this.addPoolList("/pool/1/CanadianStakePool/0/b96ebf01cefa08edae50a5bf495a8f61261bc918fa4e62c4cbbe3ebe6bacde21/https:$$webdollarpool.ca:443", undefined, true); - await this.addPoolList("/pool/1/ImperiumStake/0/bf883f6f0e7c68c415e791eb77ddf55e43e352fa673fc35536937d074178dd80/https:$$webdollarpool.eu:443", undefined, true); - await this.addPoolList("/pool/1/2MooNPooL/0.02/3c9456990ea9d0595f3a438e46b656063a42e6ad7f4fb1316b4a2b4086bfe9b0/https:$$2moonPool.ddns.net:3335", undefined, true); await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); - await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); await this.addPoolList("/pool/1/Timi/0.001/48bfe934cc6cec36c58e3f8468a24a495cd38d77cd4a9af0e9a6e9f13741fcd7/https:$$pool.timi.ro:443", undefined, true); } From 20b0a617449243ffd7fc16aacf8dd1d2ec82c0c6 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Thu, 10 Sep 2020 21:06:38 +0300 Subject: [PATCH 029/132] @lazypillow minor change --- .../transactions/Interface-Blockchain-Transactions-Events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions-Events.js b/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions-Events.js index 14e7ec24a..e40d4bb8b 100644 --- a/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions-Events.js +++ b/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions-Events.js @@ -59,7 +59,7 @@ class InterfaceBlockchainTransactionsEvents{ if (this._searchAddressInTransaction(unencodedAddress, transaction)) { let txId = transaction.txId.toString("hex"); - result[txId.toString("hex")] = transaction.toJSON(); + result[txId] = transaction.toJSON(); } From 02214129aaa514878ce8570338d08663e589f0d4 Mon Sep 17 00:00:00 2001 From: tomonetml <34745293+tomonetml@users.noreply.github.com> Date: Wed, 16 Sep 2020 15:37:05 +0200 Subject: [PATCH 030/132] minor update tutorial How to mine WebDollar with Windows Terminal --- tutorials/how-to-mine-webd-windows-terminal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-mine-webd-windows-terminal.md b/tutorials/how-to-mine-webd-windows-terminal.md index 5ab497450..af3081e44 100644 --- a/tutorials/how-to-mine-webd-windows-terminal.md +++ b/tutorials/how-to-mine-webd-windows-terminal.md @@ -1,7 +1,7 @@ # How to mine WebDollar with Windows Terminal Mine WebDollar with Windows Terminal -#### a. Download and install latest version of Nodejs Latest version of Node.js <- ctrl + click to open in a new window +#### a. Download and install Nodejs 8.12 Node.js 8 <- ctrl + click to open in a new window #### b. Download and install Python ##### Python 2.7 64bit <- ctrl + click to open in a new window ##### Python 2.7 32bit <- ctrl + click to open in a new window From 82478f8ffe1f6d242225bb48617931f83c4e6ad3 Mon Sep 17 00:00:00 2001 From: IonutAlexandruPanait Date: Mon, 11 Jan 2021 20:22:50 +0200 Subject: [PATCH 031/132] add pool --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index cf01e53c2..689518a55 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -234,6 +234,7 @@ class MinerPoolSettings { await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); await this.addPoolList("/pool/1/Timi/0.001/48bfe934cc6cec36c58e3f8468a24a495cd38d77cd4a9af0e9a6e9f13741fcd7/https:$$pool.timi.ro:443", undefined, true); + await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); } async _replacePoolURL(url = ''){ From cfbf2ffa58f35a85a81d68ad7bf611bcca58e43d Mon Sep 17 00:00:00 2001 From: IonutAlexandruPanait Date: Sat, 16 Jan 2021 18:22:16 +0200 Subject: [PATCH 032/132] change pool key --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 689518a55..da198ff0e 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -233,7 +233,7 @@ class MinerPoolSettings { await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); - await this.addPoolList("/pool/1/Timi/0.001/48bfe934cc6cec36c58e3f8468a24a495cd38d77cd4a9af0e9a6e9f13741fcd7/https:$$pool.timi.ro:443", undefined, true); + await this.addPoolList("/pool/1/Timi/0.001/0fc73835374ee10ae3bf7f1f404d435a18849c4ab131d8a14a85acb4a1068260/https:$$pool.timi.ro", undefined, true); await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); } From b354dee2c94d01f7221f23157879533c92b8c216 Mon Sep 17 00:00:00 2001 From: IonutAlexandruPanait Date: Sun, 17 Jan 2021 16:29:56 +0200 Subject: [PATCH 033/132] fix pool --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index da198ff0e..b7e97be68 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -233,7 +233,7 @@ class MinerPoolSettings { await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); - await this.addPoolList("/pool/1/Timi/0.001/0fc73835374ee10ae3bf7f1f404d435a18849c4ab131d8a14a85acb4a1068260/https:$$pool.timi.ro", undefined, true); + await this.addPoolList("/pool/1/Timi/0.001/0fc73835374ee10ae3bf7f1f404d435a18849c4ab131d8a14a85acb4a1068260/https:$$pool.timi.ro:443", undefined, true); await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); } From 51f5f56d807df7bd756d1c10fa671a6bc99aa7ea Mon Sep 17 00:00:00 2001 From: IonutAlexandruPanait Date: Tue, 19 Jan 2021 11:02:30 +0200 Subject: [PATCH 034/132] change pool key --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index b7e97be68..04817203e 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -233,7 +233,7 @@ class MinerPoolSettings { await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); - await this.addPoolList("/pool/1/Timi/0.001/0fc73835374ee10ae3bf7f1f404d435a18849c4ab131d8a14a85acb4a1068260/https:$$pool.timi.ro:443", undefined, true); + await this.addPoolList("/pool/1/Timi/0.001/7d863060bc5bf81695f53c5e61c79677ad6cb3b5fd48dafebbabb25f7dca8797/https:$$pool.timi.ro:443", undefined, true); await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); } From cbb8ae9d4acf6efd134081a63e0dddf95d57b612 Mon Sep 17 00:00:00 2001 From: Marius Galmati <51032446+mariusg91@users.noreply.github.com> Date: Tue, 2 Feb 2021 02:41:53 +0200 Subject: [PATCH 035/132] Add CanadianStakePool new url --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 04817203e..7f8e007be 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -228,6 +228,7 @@ class MinerPoolSettings { } async _addPoolsList(){ + await this.addPoolList("/pool/1/CanadianStakePool/0.02/cf9eb743548122226de9f4b7ed536520c2d84af146014edf49055be96e9e9988/https:$$webdollarpool.ca:443", undefined, true); await this.addPoolList("/pool/1/WEBD-Splashpool-USA/0.02/61761896b4d958b3cc9073ae3c724a127b4ee5b31f6b8dcafd29643cf20a796a/https:$$splashpool.myvnc.com:8080", undefined, true); await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); From 7f8d7c8bbf711ed39f09648c09b48b0e835d83af Mon Sep 17 00:00:00 2001 From: CryptoCoinGB <45538866+CryptoCoinGB@users.noreply.github.com> Date: Tue, 8 Sep 2020 23:28:31 +0100 Subject: [PATCH 036/132] Correct launch webserver command 'npm run dev' does not work as it is not referenced in package.json within the 'vue-Frontend' folder to start the webserver. 'npm run start' does work however and successfully starts the webserver. --- tutorials/how-to-deploy-webdollar-pool.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-deploy-webdollar-pool.md b/tutorials/how-to-deploy-webdollar-pool.md index 089c4d55c..7f5a7ee8e 100644 --- a/tutorials/how-to-deploy-webdollar-pool.md +++ b/tutorials/how-to-deploy-webdollar-pool.md @@ -46,7 +46,7 @@ npm run commands # better use screen command or open another terminal - Run this #### vue-Frontend - Running by default on PORT 9094! ```shell cd vue-Frontend -npm run dev # better use screen command or open another terminal - Run this command after step 3 +npm run start # better use screen command or open another terminal - Run this command after step 3 ``` ### 5. Configuring your WebDollar Pool (run commands in Node Window) ```shell From 188d541b6780e11ddfe126f6f2519d8e94bc388b Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Fri, 5 Feb 2021 14:18:16 +0200 Subject: [PATCH 037/132] typo --- .../wizard/Interface-Blockchain-Transactions-Wizard.js | 4 ++-- .../transactions/Mini-Blockchain-Transactions.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js b/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js index e0af35d3d..e8e7b2b32 100644 --- a/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js +++ b/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js @@ -1,6 +1,6 @@ /* eslint-disable */ import WebDollarCoins from "common/utils/coins/WebDollar-Coins" -import MiniBlockchainTransactions from "./../../../mini-blockchain/transactions/trasanction/Mini-Blockchain-Transaction" +import MiniBlockchainTransaction from "./../../../mini-blockchain/transactions/trasanction/Mini-Blockchain-Transaction" import NodesList from 'node/lists/Nodes-List'; import consts from 'consts/const_global' @@ -16,7 +16,7 @@ class InterfaceBlockchainTransactionsWizard{ async deserializeValidateTransaction(transaction){ - let myTransaction = new MiniBlockchainTransactions(this.blockchain,undefined,undefined,0,undefined,undefined,undefined,false,false,false,false,false,false); + let myTransaction = new MiniBlockchainTransaction(this.blockchain,undefined,undefined,0,undefined,undefined,undefined,false,false,false,false,false,false); await myTransaction.deserializeTransaction(transaction.data,0,true); diff --git a/src/common/blockchain/mini-blockchain/transactions/Mini-Blockchain-Transactions.js b/src/common/blockchain/mini-blockchain/transactions/Mini-Blockchain-Transactions.js index 9d0cd0003..f468ff872 100644 --- a/src/common/blockchain/mini-blockchain/transactions/Mini-Blockchain-Transactions.js +++ b/src/common/blockchain/mini-blockchain/transactions/Mini-Blockchain-Transactions.js @@ -3,7 +3,6 @@ import MiniBlockchainTransaction from "./trasanction/Mini-Blockchain-Transaction class MiniBlockchainTransactions extends InterfaceBlockchainTransactions { - _createTransaction(from, to, nonce, timeLock, version, txId, validateFrom, validateTo, validateNonce,validateTimeLock, validateVersion, validateTxId ){ return new MiniBlockchainTransaction(this.blockchain, from, to, nonce, timeLock, version, txId, validateFrom, validateTo, validateNonce,validateTimeLock, validateVersion, validateTxId); } From 9bbacaad6c965ec97a4f51238fb72c2a4a6e592a Mon Sep 17 00:00:00 2001 From: ader1990 Date: Sat, 6 Feb 2021 14:39:06 +0000 Subject: [PATCH 038/132] client: add support for creating transactions with decimals values --- src/node/sockets/node-server/API/Node-API-Private.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node/sockets/node-server/API/Node-API-Private.js b/src/node/sockets/node-server/API/Node-API-Private.js index d641e32a8..ac182015b 100644 --- a/src/node/sockets/node-server/API/Node-API-Private.js +++ b/src/node/sockets/node-server/API/Node-API-Private.js @@ -68,9 +68,10 @@ class NodeAPIPrivate{ to = req.to; } - let amount = parseInt(req.amount) ? parseInt(req.amount) * WebDollarCoins.WEBD : undefined; - let fee = parseInt(req.fee) * WebDollarCoins.WEBD; - + let amount = parseFloat(req.amount) ? parseFloat(req.amount) * WebDollarCoins.WEBD : undefined; + let fee = parseFloat(req.fee) * WebDollarCoins.WEBD; + amount = Math.round(amount) + fee = Math.round(fee) let result = await Blockchain.Transactions.wizard.createTransactionSimple(from, to, amount, fee); return result; From c50d8962ce8e1cff9a01a37fa82a044ca476411f Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 10 Feb 2021 21:12:35 +0200 Subject: [PATCH 039/132] suggestion for serialization fix from @lazipillow --- .../state/Mini-Blockchain-Accountant-Tree-Node.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js index bc1588558..8dd577090 100644 --- a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js +++ b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js @@ -158,14 +158,14 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ _serializeBalance(balance){ return Buffer.concat([ - Serialization.serializeToFixedBuffer(balance.id, consts.MINI_BLOCKCHAIN.TOKENS.OTHER_TOKENS.LENGTH), - Serialization.serializeNumber7Bytes(balance.amount) - ]); + Serialization.serializeToFixedBuffer(consts.MINI_BLOCKCHAIN.TOKENS.OTHER_TOKENS.LENGTH, balance.id), + Serialization.serializeNumber7Bytes(balance.amount) + ]); } _serializeBalanceWEBDToken(balance){ return Buffer.concat([ - Serialization.serializeToFixedBuffer(balance.id, consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH), + Serialization.serializeToFixedBuffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH, balance.id), Serialization.serializeNumber7Bytes(balance.amount) ]); } From 06f03cc2cc1ef72357375d4251e4867c8c8860a2 Mon Sep 17 00:00:00 2001 From: Marius Galmati <51032446+mariusg91@users.noreply.github.com> Date: Wed, 10 Feb 2021 22:48:04 +0200 Subject: [PATCH 040/132] Update pool link --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 7f8e007be..6b7aeb472 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -228,7 +228,7 @@ class MinerPoolSettings { } async _addPoolsList(){ - await this.addPoolList("/pool/1/CanadianStakePool/0.02/cf9eb743548122226de9f4b7ed536520c2d84af146014edf49055be96e9e9988/https:$$webdollarpool.ca:443", undefined, true); + await this.addPoolList("/pool/1/CanadianStakePool/0.02/ea115a560322c557d3617732145a837af9992d729e5f8165d3b7077b22ee12a4/https:$$webdollarpool.ca:443", undefined, true); await this.addPoolList("/pool/1/WEBD-Splashpool-USA/0.02/61761896b4d958b3cc9073ae3c724a127b4ee5b31f6b8dcafd29643cf20a796a/https:$$splashpool.myvnc.com:8080", undefined, true); await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); From edace6f803f6d88eac36938b2cb3b6e680170635 Mon Sep 17 00:00:00 2001 From: Constantin Busuioceanu <39584380+cbusuioceanu@users.noreply.github.com> Date: Sun, 14 Feb 2021 18:02:55 +0200 Subject: [PATCH 041/132] update - small updates --- install-fullnode.sh | 75 +++++++++++++++++++++++++++++++-------------- install-miner.sh | 59 ++++++++++++++++++++++++++--------- 2 files changed, 96 insertions(+), 38 deletions(-) diff --git a/install-fullnode.sh b/install-fullnode.sh index 71bc06e86..b80a9abe4 100755 --- a/install-fullnode.sh +++ b/install-fullnode.sh @@ -38,18 +38,18 @@ export whitebg export stand ### System dialog VARS -showinfo="$green[info]$stand" -showerror="$red[error]$stand" -showexecute="$yellow[running]$stand" -showok="$magenta[OK]$stand" -showdone="$blue[DONE]$stand" -showinput="$cyan[input]$stand" -showwarning="$red[warning]$stand" -showremove="$green[removing]$stand" -shownone="$magenta[none]$stand" -redhashtag="$redbg$white#$stand" -abortte="$cyan[abort to Exit]$stand" -showport="$yellow[PORT]$stand" +showinfo="${green}[info]$stand" +showerror="${red}[error]$stand" +showexecute="${yellow}[running]$stand" +showok="${magenta}[OK]$stand" +showdone="${blue}[DONE]$stand" +showinput="${cyan}[input]$stand" +showwarning="${red}[warning]$stand" +showremove="${green}[removing]$stand" +shownone="${magenta}[none]$stand" +redhashtag="${redbg}$white#$stand" +abortte="${cyan}[abort to Exit]$stand" +showport="${yellow}[PORT]$stand" ## export showinfo @@ -71,8 +71,11 @@ function install_nvm() curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash export NVM_DIR="$HOME/.nvm" +# shellcheck source=/dev/null [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +# shellcheck source=/dev/null [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +# shellcheck source=/dev/null if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then source ~/.profile; elif cat /etc/*release | grep -q -o -m 1 centos; then source ~/.bash_profile; fi nvm install 8.2.1 nvm use 8.2.1 @@ -129,6 +132,30 @@ elif cat /etc/*release | grep -q -o -m 1 centos; then fi ### +### Look after curl :) +if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then + + if [[ $(apt-cache policy curl | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y curl; else echo "$showok Curl is already installed!"; fi + +elif cat /etc/*release | grep -q -o -m 1 centos; then + + if [[ $(yum list git | grep -o "Available Packages") == "Available Packages" ]]; then yum install -y curl; else echo "$showok Curl is already installed!"; fi + +fi +### + +### Look after python2.7 - yeah, blame node-gyp for that. +if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then + + if [[ $(apt-cache policy python2.7 | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y python2.7; else echo "$showok python2.7 is already installed!"; fi + +elif cat /etc/*release | grep -q -o -m 1 centos; then + + if [[ $(yum list python2.7 | grep -o "Available Packages") == "Available Packages" ]]; then yum install -y python2.7; else echo "$showok python2.7 is already installed!"; fi + +fi +### + ### System update function sys_update(){ @@ -154,7 +181,9 @@ if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ -z $(apt-cache policy build-essential | grep Installed | grep none | awk '{print$2}' | sed s'/[()]//g') ]]; then echo "$showok build-essential is already installed"; else sudo apt-get install -y build-essential; fi elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum group install -y "Development Tools"; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ $(which clang) == "/usr/bin/clang" ]]; then echo "$showok clang is already installed"; else sudo apt-get install -y clang; fi elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum install -y clang; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then install_nvm; fi elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then install_nvm; fi fi +# shellcheck disable=SC2236 if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian || cat /etc/*release | grep -q -o -m 1 centos; then if [[ ! -z $(which node-gyp) ]]; then echo "$showok node-gyp is already installed!"; else npm install -g node-gyp; fi fi +# shellcheck disable=SC2236 if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian || cat /etc/*release | grep -q -o -m 1 centos; then if [[ ! -z $(which pm2) ]]; then echo "$showok pm2 is already installed!"; else npm install pm2 -g --unsafe-perm; fi fi if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ $(node --version) ]]; then echo "$showok NVM sourced ok!"; else echo -e "$showwarning ${red}MANDATORY$stand: execute ${yellow}source ~/.profile$stand\n$showinfo Start script again after command execution." && exit 0; fi elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ $(node --version) ]]; then echo "$showok NVM sourced ok!"; else echo -e "$showinfo ${red}MANDATORY$stand: execute ${yellow}source ~/.bash_profile$stand\n$showinfo Start script again after command execution."; fi fi @@ -187,8 +216,8 @@ read -r -e -p "$showinput How many nodes do you want to deploy? " readnrofnodes for ((nodes=1; nodes<=readnrofnodes; nodes++)); do if [[ ! -d Node-WebDollar1 ]]; then - git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar$nodes - cd Node-WebDollar$nodes && npm install && cd .. + git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar"$nodes" + cd Node-WebDollar"$nodes" && npm install && cd .. echo "$showok Node-WebDollar$nodes Deployed successfully!" else echo "$showwarning Node-WebDollar1 is already deployed!" @@ -230,8 +259,8 @@ elif [[ "$readft" == 2 ]]; then cd .. && echo "$showinfo Location changed to $(pwd)" for ((i=countcurrentnodes+1; i<=countcurrentnodes+readnrofnodesdeploy; i++)); do - git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar$i - cd Node-WebDollar$i && npm install && cd .. + git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar"$i" + cd Node-WebDollar"$i" && npm install && cd .. echo "$showok Node-WebDollar$i Deployed successfully!" done else @@ -240,8 +269,8 @@ elif [[ "$readft" == 2 ]]; then for ((i=countcurrentnodes+1; i<=countcurrentnodes+readnrofnodesdeploy; i++)); do - git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar$i - cd Node-WebDollar$i && npm install && if cd "$crnt_dir"; then echo "$showinfo Current DIR changed to $(pwd)"; else echo "$showerror Couldn't change DIR to $crnt_dir!"; fi + git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar"$i" + cd Node-WebDollar"$i" && npm install && if cd "$crnt_dir"; then echo "$showinfo Current DIR changed to $(pwd)"; else echo "$showerror Couldn't change DIR to $crnt_dir!"; fi echo "$showok Node-WebDollar$i Deployed successfully!" done fi @@ -318,8 +347,8 @@ elif [[ "$readft" == 3 ]]; then for ((i=countcurrentnodes+1; i<=countcurrentnodes+deployclones; i++)); do - cp -r "$nodewebdloc" Node-WebDollar$i - ls -la Node-WebDollar$i + cp -r "$nodewebdloc" Node-WebDollar"$i" + ls -la Node-WebDollar"$i" echo "$showok Node-WebDollar$i Deployed successfully @ $nodewebdloc/Node-WebDollar$i!" done else @@ -342,8 +371,8 @@ elif [[ "$readft" == 3 ]]; then for ((i=countcurrentnodes+1; i<=countcurrentnodes+deployclones; i++)); do - cp -r "$nodewebdloc" Node-WebDollar$i - ls -la Node-WebDollar$i + cp -r "$nodewebdloc" Node-WebDollar"$i" + ls -la Node-WebDollar"$i" echo "$showok Node-WebDollar$i Deployed successfully @ $nodewebdloc/Node-WebDollar$i!" done else @@ -403,4 +432,4 @@ elif [[ "$readft" == * ]]; then fi } # function ftconfig END -ftconfig +ftconfig \ No newline at end of file diff --git a/install-miner.sh b/install-miner.sh index a3d85aeaf..deb758eb4 100755 --- a/install-miner.sh +++ b/install-miner.sh @@ -20,18 +20,18 @@ whitebg=$(tput setab 7 && tput bold) stand=$(tput sgr0) ### System dialog VARS -showinfo="$green[info]$stand" -showerror="$red[error]$stand" -showexecute="$yellow[running]$stand" -showok="$magenta[OK]$stand" -showdone="$blue[DONE]$stand" -showinput="$cyan[input]$stand" -showwarning="$red[warning]$stand" -showremove="$green[removing]$stand" -shownone="$magenta[none]$stand" -redhashtag="$redbg$white#$stand" -abortte="$cyan[abort to Exit]$stand" -showport="$yellow[PORT]$stand" +showinfo="${green}[info]$stand" +showerror="${red}[error]$stand" +showexecute="${yellow}[running]$stand" +showok="${magenta}[OK]$stand" +showdone="${blue}[DONE]$stand" +showinput="${cyan}[input]$stand" +showwarning="${red}[warning]$stand" +showremove="${green}[removing]$stand" +shownone="${magenta}[none]$stand" +redhashtag="${redbg}$white#$stand" +abortte="${cyan}[abort to Exit]$stand" +showport="${yellow}[PORT]$stand" ### ### @@ -68,11 +68,14 @@ export showport function install_nvm() { - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash +# shellcheck source=/dev/null export NVM_DIR="$HOME/.nvm" +# shellcheck source=/dev/null [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +# shellcheck source=/dev/null [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +# shellcheck source=/dev/null if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then source ~/.profile; elif cat /etc/*release | grep -q -o -m 1 centos; then source ~/.bash_profile; fi nvm install 8.2.1 nvm use 8.2.1 @@ -80,7 +83,7 @@ nvm alias default 8.2.1 } -### Look for git :) +### Look after git :) if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ $(apt-cache policy git | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y git; else echo "$showok Git is already installed!"; fi @@ -92,6 +95,30 @@ elif cat /etc/*release | grep -q -o -m 1 centos; then fi ### +### Look after curl :) +if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then + + if [[ $(apt-cache policy curl | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y curl; else echo "$showok Curl is already installed!"; fi + +elif cat /etc/*release | grep -q -o -m 1 centos; then + + if [[ $(yum list git | grep -o "Available Packages") == "Available Packages" ]]; then yum install -y curl; else echo "$showok Curl is already installed!"; fi + +fi +### + +### Look after python2.7 - yeah, blame node-gyp for that. +if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then + + if [[ $(apt-cache policy python2.7 | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y python2.7; else echo "$showok python2.7 is already installed!"; fi + +elif cat /etc/*release | grep -q -o -m 1 centos; then + + if [[ $(yum list python2.7 | grep -o "Available Packages") == "Available Packages" ]]; then yum install -y python2.7; else echo "$showok python2.7 is already installed!"; fi + +fi +### + ### Start miner install if [[ $(grep "name" package.json | sed s'/[",]//g' | awk '{print $2}') == node-webdollar ]]; then @@ -121,7 +148,9 @@ if [[ $(grep "name" package.json | sed s'/[",]//g' | awk '{print $2}') == node-w if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ -z $(apt-cache policy build-essential | grep Installed | grep none | awk '{print$2}' | sed s'/[()]//g') ]]; then echo "$showok build-essential is already installed"; else sudo apt-get install -y build-essential; fi elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum group install -y "Development Tools"; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ $(which clang) == "/usr/bin/clang" ]]; then echo "$showok clang is already installed"; else sudo apt-get install -y clang; fi elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum install -y clang; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then install_nvm; fi elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then install_nvm; fi fi + # shellcheck disable=SC2236 if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian || cat /etc/*release | grep -q -o -m 1 centos; then if [[ ! -z $(which node-gyp) ]]; then echo "$showok node-gyp is already installed!"; else npm install -g node-gyp; fi fi + # shellcheck disable=SC2236 if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian || cat /etc/*release | grep -q -o -m 1 centos; then if [[ ! -z $(which pm2) ]]; then echo "$showok pm2 is already installed!"; else npm install pm2 -g --unsafe-perm; fi fi echo "$showexecute Running npm install..." && npm install if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ $(node --version) ]]; then echo "$showok NVM sourced ok..."; else echo "$showinfo ${red}MANDATORY$stand: execute ${yellow}source ~/.profile$stand"; fi elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ $(node --version) ]]; then echo "$showok NVM sourced ok..."; else echo "$showinfo ${red}MANDATORY$stand: execute ${yellow}source ~/.bash_profile$stand"; fi fi @@ -134,4 +163,4 @@ else echo "$showerror You are not inside the Node-WebDollar folder." echo "$showinfo To install your miner, use this script inside the Node-WebDollar folder." fi -### +### \ No newline at end of file From 7bbe038c5a2e0c1f10a2e7a1fbcc67b1f55d48f1 Mon Sep 17 00:00:00 2001 From: MartinCanto Date: Fri, 19 Feb 2021 13:03:52 -0500 Subject: [PATCH 042/132] Update start_pool_miner.sh --- start_pool_miner.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/start_pool_miner.sh b/start_pool_miner.sh index 9d29871b4..9a8ca33d3 100644 --- a/start_pool_miner.sh +++ b/start_pool_miner.sh @@ -3,5 +3,6 @@ then (sleep 60;echo 10;sleep 5;echo $MINING_POOL_URL;) | npm run commands || true else echo $WALLET > wallet.json - (sleep 60;echo 4;sleep 5;echo 'wallet.json';sleep 5;echo 7;sleep 5;echo 1;sleep 5;echo 10;sleep 5;echo $MINING_POOL_URL;) | npm run commands || true + (sleep 60;echo 4;sleep 5;echo 'wallet.json';sleep 5;echo 7;sleep 5;echo 1;sleep 5;echo exit;) | npm run commands || true + (sleep 60;echo 10;sleep 5;echo $MINING_POOL_URL;) | npm run commands || true fi From 7e2646d151365b7b9f1b572b579ea4d52a9779f2 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Sun, 28 Feb 2021 16:07:26 -0700 Subject: [PATCH 043/132] Adding .nvmrc with the version of node in the build script --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..e51c059b1 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v8.2.1 From 2442e366dbef80bd111ca774b0ec18fbd70fa574 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Sun, 28 Feb 2021 20:39:57 -0700 Subject: [PATCH 044/132] Separate out the CLI into core, interactive, and non-interactive. - Start allowing some commands to be issued non-interactively, from the compiled command line interface. - Some commands will not be allowed to be used interactively at this time due to complexity / additional refactoring required to use them. --- README.md | 27 +- dist_bundle/CPU/argon2-bench2 | Bin 18832 -> 52160 bytes src/build_terminal.js | 12 +- src/node/menu/CLI-Core.js | 764 ++++++++++++++++++++++ src/node/menu/CLI-Menu-non-interactive.js | 164 +++++ src/node/menu/CLI-Menu.js | 738 ++------------------- 6 files changed, 1004 insertions(+), 701 deletions(-) create mode 100644 src/node/menu/CLI-Core.js create mode 100644 src/node/menu/CLI-Menu-non-interactive.js diff --git a/README.md b/README.md index a158c875a..225ac83e6 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,32 @@ If you are under a **router/firewall**, you need to port forward the port used b npm run commands ``` -#### 5.2 Running Full Node +#### 5.2 Run terminal non-interactive menu + +After building the terminal project + +```shell +npm run build_terminal_menu +npm run build_terminal_worker +``` + +it is possible to run the terminal project as a non-interactive script: + +```shell +node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js -- --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here +``` + +the first part of the command (`node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js`) launches the terminal project. + +The next portion of the command (`--`) starts it in non-interactive mode. +Without `--`, the terminal menu defaults to interactive. + +The next parts are the commands to run in order. + +Mining should be the last command used, as mining stops processing additional arguments since it starts the mining process. +This is useful for programmatically executing a mining task (such as in a container). + +#### 5.3 Running Full Node Install pm2. ```shell diff --git a/dist_bundle/CPU/argon2-bench2 b/dist_bundle/CPU/argon2-bench2 index ff284fddf505ff80e940838ba1e1dd470dc5e560..9810fefabfaef54ea6642954c7ab009b85bbfda3 100755 GIT binary patch literal 52160 zcmeHQeSB2Kxt~6@GWH;SCONfF7 zl0#VIYP{DE^wvsyZ!4|Z8@&>#T37^0w5?$6wOG8Z6pNc;3$?AaevtdTGjo#7+Wz|A z?LTvV&dmEh@5jtMXXc#QC5eYV`Q4eb7;}tZjOCzAK&cqXn8jR>7@LY>pm@DC`n8^0 zJU1>Obok{MuKrDp^2|mDUhgu`ieA6Ghq_k$LUT@5d*Tx2+?0h$siG1IZ9=2`=jFS0=#z*=PP`9ZUl^Z15{?Z`I6I%KT#T3oo6d(XFG*|H1l*G&V-UcE;@a=5H4H4xjI`U54c&{xh$k=SOwb;_E$?RpM?kmU8iXHF!T$ zA}Tdjw3H_^7slVp*Esw}!8QtQ1zP(uQjl`+ta_QT(+Gsf=-yTwV2qaV$9;_T0i^Wy zTD1EhKBuE(@(Oj>m5=z+VTe%1qj8~(Lzy3sMdvq!YUc-98UoPiqBTV0csE}2FVElP zzOG|o?^AEz@M75lU@jCI10R)RESLGc9_7oq1SqXz`4%MjEQ67|KJb?L3aF#^JGxJocR6 zx3nc@1{*J1I26U$MTntsmVoC`Xy-_scvqKVKrx^gPz)#r6a$I@#eiZ!F`yVw3@8Q^ z1BwB~fMP%~pcqgLC&No9lSE=LfQ^i;G~O0z!16pVrWM(OIq z&2LpF3l6PT%JaoUdbr_!om1Io+IMlMoaO}%J{ZVU2(*hZ$Y4uJZBBkfCC8?tmYm>@+jNc5-ZaY7lssfX$my=PnIvy05x((_y1*+DErAfR_QR zE-U{lS7t!jOFzA^$Qm$L7rlxOn(Fh>Px0I6XYl@LJ-K7tx#Q!d#=yR+(nIl6CyUT! zdIImhyk{+_TnZV(?SF#O!}jM%jOlv@aP>a`sAxdHJ9n0m%$tC`Zii+)fnN2yD`z>} zIf%GtEY%HIp(j&6qBe*^=dwJ{m! z!IfkzUQ&l`lK3QD1bdyXMRI59+U)9C`9{)t1w6DlMt+@k7k25il#Yi}e0q1;J4mxL$ord}Vx0jdF zP~U>A@4ve0Mq^%RbQVvBtI>JRS-i>1rzTlG59<;;=XOL?CQch|2d1pjZ`D`p zx9Q&1`|T}1?0HnPd#3|^{2o74Y0NpW!sv7+`2z*R!ZRi5={6Ep$(d6Fy;cQk7kbAG zj}egxYX!&Gpr#+mG%#X)g&c=8*FhmnXp?Zv=yMSn|_=~0^2x1lSFRv=pvxk z+HObpT05lJYwfhbq_txJZVAf(Qk|SPIzW6{hoKdvARK{kaz^IU4$mv%cMC?mm%2`O zK_cX<#6ah?y*E+gOi^PUHQzL>l=*sfXTjqDs!9*UUN(}>KSHkVEIH$hLRjQ@AGg1i zL&YI#N_SDWT6-&>$S-!&W5Ss6vU#?V{2?E1vUnwKWBPUcP*U>h+=J~-LRsSNwtdcn z?Ri|m+IR)I>a>WXPMcjtYtCwdSDiK|*~;7XDZ(nae3w;&HeuDEUnB7tO}{$9M?o`t z2>oD{Ywcq(kk<02mt$P!B&?RXSSHnp6Ikw8GuMz;>1SHoE2D`4&SBCRVI-2>NS8En zAnoRo15yf7f*9`OeH|a7xULJq6teB>d|uEfY}-phOB^xwrSpwWo?)Aqt---504bXU zJBycLprEV-Sh_(IuaocNhvT#!K5eaMQFlq7IiaLa+cFhDlcsfCPW5!M>!1VnXJE4) z!)*q%P(aTT^pJqA7SMkabf17K1@s(2+XUnh&@O^D3+NgF^$>KsfUXtL^902NWC&rQR{d}7`!mJJ%`qRwcjFu&QGx4s%>5Q`M|(Q6LO8Vbq&e&kSn#VYe~Kp za*4JzOmYq6x!Tq^$(4{@+SZLEmq4DRZEYiYZb@HkhW)%RN>wF(S)KSJj&aqcpK4n^ z!#3%E4?jAoZ4JS>3lAAjH=Z(!GM*@NlJrEuMChTT^(5&zLv!a_tjGGAKxv!V)1St- zU@6r-R#ez&&)N3R`GVyewa1DHJ8eM9+AN|>fzlqdqk4JNaj|UU!cH5~w$p)3>)0>s z>xG?mr)}@x_Wuy}W?`qTO1(}Jy>1XF?N&SL1|HQYqFRKVwyte2;`T+te!H;K?xn2n z3G@zu(zYe^m_RoQl=iEg>oPfMw=!JoMNOzQ?zA2(M3zRmp9kr52#YNN>VW+)p+e^89xv;khJ8fs%K9$>xg}q(a zX-8A9&7xOJptPw8<@cw@+A2`m*MvSSd^-e6TbodRuY0U*0;Sze=<~uiAyC@jg!T&b zZh_Js#~5iRwrCxEqxM*x!bY1Nwvn){Zr+5odyl|r$5SS`c9H_6O)tIYH!p$ry#lBG zF7b1luLOP{0JlZEef`Lj7hyY|&$l7o&S|{Q26tmL+J6fTb?XzK4FElrK8~MI#w(Lf z5Js7E>SD&?7vMZn2*DV@3)eXrQnw>vy$28M>yvrCT*SkKElQlB6yKo~qMuG~8|+PM z`yK90drE6x@i9KSybA?W+)|5kfwuJyjG(^-B0)O^7`gq0lfy1yykGP z@py>zS4gkP9GXDTJPB>&f!itYei<0z&@O`Rl+gd4q4bwg;GZB;`qwyg13||mRLBEQ zP@qQ!P8)(2NNCIuG+jb>@?3XNt_NkV_dcN>-=tiBg-AWF;9l#uKpVj(c5CUKdKQDEE4lygH=U3D~u*W#siaDjGyJ_v#=opY%#` zuS?16=hEvU?q!l!ne=*;do3ZaXHXTTsuRcc#KG3`7p}+ZFlQQ_c}E~scRG)u!2xhF zR?6T3klu&1e0*rnp7+V2~q zEtO-mee5!qX+7gcYCR7)`P<_Sb7XX3$s5h*YCY8>9R%~&#~bFM=%poZtbY}+A$gpg z%^y`b>Mo{p???=T_6*kk0`${b{=s!Ln=3J!G0-uav(aES-T1|m!Pzv^`)yD0Vfe!I zGE6w*)&lgjf26g487rTUyikND;Fj@yz_^h{;x%L6Z*#StN$zbAcuu4HwqqKmQ@ZUQ z&mU+o*o&BA{LO<_A@(>%brX$BYrlu;JLoMIA5}bah-L?;M-f}5p zSQQvnwAaVcl{%Zz#E;`slV<%pR{hB% z7{J>Y8WO#S_bnXf@h2QJ$~=eTlW-F@AD~a58J|qB{tnRapYWL2=&BixmeFJ?7&(AzXI4KP!*QQsn%Cb#A z(~@*X)dza7@7#D|RC+YRw>jGl4#D21CEv%a7x~{`(m59&m`DqVtDfhB&0F($x#`T}76SKwhR`Z}IDQ5S5+c6{2L&J#HL$H5OI zzD0q47`2|_jn`5a<&+C|k+PxxQv`Mv0^ca`ksL4YSeDQ5&E{liRw_Ob_FV$W<%oGH zko}aL{9i<81N}PPAABu?#Z+_@J-h_He=e%la)w@*xe=f2pI_sm?;R^n;We2o_ag(o zjHKWHDLQ)c^5OTB7VA!g^RNEW-H>qd)q0%IU4ymX_R1)ubbo9PZUue)_+inj=@sz6 z4eLwvrs>csm-;vmLx1(cI7fLuSHYgzj8-wq7m>sqs5cz=7xV328p`spl7j~7ny zeoX0cOesALhP{2{QUIy7d@hE8hjGzSOy`)_#k#6Guli;BCjiAT^I*piqiGRz8iv;L zzj)BZuSU*`mg4K0XUIEQehbOphFo+MAEAeT+XM4cSY!R)#V&;WJjstiE*eNTBBE=c z;6E!F8z}e=uXpnLd%S*%*Wc%LH?N=N^>e)L;q`7_zrgF4c)f?$DPF(K>jS(#$m>2{ zzsBny^ZIpOALjK>dHpk9zs2h#sH>CHj-k<)4it>e#faFGTy+YCkl7323 zn51JQ1xPwY(k&!?PErj?V{w1`uOVqBNmr3XN9O(oBrPUsHc1U6T|iO?Ns~zW7D;1B zqGj99Ncu5JAK{+WA0_Dnl0G2m*O1WbuxnNYS1ayATX;1Jt(c69FuDpo(OOo}5N8GT z^>IeOaq7C!qgT$DF~bFPu#90#eP$$9AM%D`-fKePaIl3nMI-)TEQa6A&2aNXqmigf z=fAfX$aL`(6%{S6^i&S|hQc8;G0=G3W|5 z_?lwDfGZSs#oVrfI^f29TWV%^xMrFyO~ILN*UZ?=xvrV@zF0je1zZb9!hW*R^vNj2 zO_^b}6jmFInZ~eCLKgqM@KuAq#kktV=GC!C+-!=QtT7}goLA?NRAgJF}+3$S^$ zLzc!2i+>3A55fLOG#GOg5COG5(_b&dF@9h8V$Vyjt=e&f=r z#n-wR?$ml$voGf2Mz)MQ#a#99tPKXkE;ATy422ONaIrBiVU`&Ku2|epE1)ipy9jGz z9KY!f(nBWVW3D=1s392Ozax4+Uu%qIws_z(`d#-c&{Cn_Q>Tk$Je~0SojGh0|2~*G zT+rWG;lyI+>CmW4F`yVw3@8Q^1BwB~fMP%~pcqgLCbqVlI=m+9+vGdWc!|Me=pmQWt)Tl$v6E$gK@I` zdz=;)Ex7!O;xAuWQmQY!y3%t^E(NJeF`yVw3@8Q^1BwB~fMP%~pcqgLCO*LrJ1VSubljz1>wKXG!t*5__4`bUB5cYa*3@ESE?_>tKNyRV$LtBvqH81J1zx|ofsn!>Bo=H4 z`b}@Bv5EIkLXl=9L|zq;{S6U6@5X>q2Q3yPQw?dsNFB*5NRBiG`N-Fh(i9DaO>V0v zHRkt)xz+@&G1%yDYN5Cd(1tu)9i*D|(V#EjMSwrZ$Fpr145P{W@5+RO8$u=}+@1+G z#?9acZy*>mqY>WSjxSn6VG+3Viza*8-Cs1t!?tlZH^xoQa*7o6=5NG3XR$u1Vhu#- zj>irY5RWwkgJc(%!^@m(thce=8{81|W5nKiOdl&`U0tXl=-Cj8A$No*sq~pXX4VG7 z{`y8=bRBDH^kJ#o>5E2Ln`5n)B^)OEG$#jIw3?&tM(?o$&Du4m8Zuph#@gX24S-OcOW z+y{5tz^K@-b9|=1o;@&v{0ZV;=X;{x1}k_wvE6fe+|Q7Zg`j1+uEq> zE?%d2oo>rm!&`9pn1iXu7UJ%vc5NB_YZ*JL zTwSBPr?K6jWBh2w-fb0se}it0=E&!3f}AIl4*Tg=VW($}21Csp`FBT1AH&$1%|c%w z?K@@({a>Vgo3vjm^)9I|m3oEL1EixrCiOuSHq9H%pIZ z>6^0j&Mf_rEd858M=h?Wv-Evg{=HfH>sk6+S^7I!`tdCNgDm||S^8&LdM=m&G|11S zEPYm%z937l%F0iszJF@g-mi}Ot{&<%DM3z1sG`mnPM8T3^1t=GxT#Pas1>2Tg zf^sR!T$Fhzm!Zr@DMTqkp*?&#$`vTZC|^do5(P_;m7=&&%1~yY%tXPT@L~U-{h~X} z(fc>vRXAHjnRn>b~0_ zvyXG)ASaJ-gNHZ!*k&Kt?4w%t8Er@xhqFPQpUMWc;m5Hon4iP4Fu|~WAQa*92t__@y$ZJVquASkR(C-qqEf8Z+}}HAX7}vLu1}wP zpXdI?N{muKnGxN@znK`rP%{QyO3$sinCPNmxnh~{qf{R1iow37iP717yjbbi# zF`LRp0I}e5@f?b^l#I^`)iTZzd}hSixXQ9Lpe)P96EdEv!6-osvW65>dCA}sNiBY< zP$Ol`n8E>)qq+_ha}seaPsrFt6{29XX|a%_>XF=8A$L~D$(V`y%UHIL+D2E6$gjzA zfg;*P5%chSGA3RMOa2yWr1Z8+IEmQB6Ed#RU?yWJcRl2&p8sl)tz0U~%VZZt)L+JA zM+!4rn(ODxn%UA=+|t|@-dMb`Y)OqELpb9M_e&uEKRSt_8SUxF|e*>F(V-V=W~mDl^kjAL)9 zdn=Fr*V_-T8&&z*s|S}JD?i;cb?m$!j2``>>5DNFjz4_c=kq?>)Nq`zx>AG(|xcRXUr!3!j)P2vJ-&isAxwpT&`M)Q8yzB9=zuoV3UAm;S{^$pl zJ2zV&nDK+nBX&Q$xw7g{?_cxF?$P#F@)uor`OiLirTD?kKRz=5@!#}*l&95j_TnAj(>CpJOr6^{L?b%G9c0}MHdDsm8@hp#RpXlQBWHI6H<>gx0tZ5p~ zGjaQ)D7SxhEr;a%{5sb^g$;=MlnQ|xg#LcT#Sy>23xL~DpMFsv0kg$i|73R9P*0!G z&kXIggI`Ib=Ps^i3d=X}Kh4{f$4W%Iz{bO5B*+e16&I&z98hrL~+- z+M!9{B?kVt1U?|_#&Wct86j}hpr=#Rb8wuC>wgq{6#51K5}_Y#Jj@ihVkr09V6b7F z3>xhG3it^hnBO5ZXwgCN)3~Y?dWuBu0@oY3(Vbk;rHH=|huM4bcZ!4v>+{t{^HH&u& z)GVrOX>aq_)YZ56na{VTwY|+34AlifJ|FX4yWY1{@Kv_d1%v*eCZ1MUE5z3j+Q>vQ z=x^~ignZ4d9W7Lgj?mhGzpjz0QNje_YYm6|8-2}f%^?HS(%!Hx0X0A{AP`Hir zKyw4>oP+8ILmdqrn|uvx*MaB=G`EGCIMLMJ;csId;Sd@?&1+aku&=4ExrH@wEx}MA z)ZW6H{OwI(Y0}C1e9gi3hVpV>Q?Q|~t%kZOrFytP9m4qdpkaa5i&od#itDU5kI?%p3jnp7xfOy1-1$c2Yq@FzjoB zbr@Chx^M_hV4+PNezpd1i@&X|)h|#Yt2UxfgUD-W51_Bs`0D+^kXjd9i)4uRDiRyo z1M8aG)-dV|k5(nBnW$4zW^sF41BOKPb;xOKZu5nM{ziy5`s>4M^wr~ix5kIctO-#; zjm=F>%?;s}&?Z*zZ);fFS{GOccrB{o57xAY>RLd_%E(5rP;(=OO+aQX3Ha9|4N$AF zKM-85mG5sOtiCSPK!tT|Xk^!Tt1BvfrH(5cvl3}%GMP-3I%X#r=F;{fuhro&d?Iw{aQ)_cqYk$wxEYJ+aM>4>-L1pN>G-$m z@bNl)n+~UUE*ZA#@be{z_)#4`Nr&&$;rTlJ867@ZhpV0M=cqlF?_aDibxVK95(}dD z)y@}k_UV|A9GZP6ScVF_aJOFULW=0M#1tPGLMXhAXc{{4!<-HfO^;%{pVPMzO+zTY zlhgG?)6j`;=k(1)(~ya8<@8dbX{f{_oW7Q58Y1xyPFE03LnB_x>3KxckccngbScp^ z6yh#UPbZolg?I_43y7v65mz`pg=iWIaT}+{6HP-P&N!V*G_cdM`cbYENil&Yl6x3eT28sB@o5jn1B=ppZX9^|M%) z*g@8g73zR%1Z#>e$p(kJ{H<@^zvmQ{KM_pUT@z=bR()Rr*h2%r*&o{tTiLpSAZ%s>+MbGtbgHh#EZ=Q~yZ?hIj7igreBZpib`T zo1m-RNGNdj)97Eh%6*G_)xOAQjbR5_%(^8TeGaSL{<7M$d14N<($GT5u{)us+cE=% z@_`WftUlbXi5!7CZs_lU)hPCLh^gDusO9)HNIpVUzt}@;7d}A7d>zJAqkoNc5gQ&% zn+hwu{sjntPhgnuX@t_)Q`CsxM?Pz?ZfSrDtz0q;RduehOp@=m+&L8m&IV6kQ9-h2 zMnjXcKR!hGRXY4*$N+y2_?{)eV+8=7p>B@<0hsmTE+k>-52~X_R;$tDYUewHOKPeQ z_S2h?dT=kjps5EB()&hiE<`_R;_ZCq@0gI5tHpze)XuYcYV>dGFQCmapN7V*+Cv#b z17Ozlui8hmPLo5@eU!gkz2if!VDFb^C{Uw=>fYD_)pS5T@?~gZLfdGm&3Z9gwNEQQ zGXKd76fB$LmP0VshR$7e!16F4)5pA|J%czvR67^2u;t|UAeT_~5eW<(UKPI$GRgY5 zZ*<>4&+PJLcnI%!f1An18r7cc!Xj!>w9DQNz}fHZecry4klrqP1U5YAv6rD1Fp$T- z!~=sNUO{t+H@ewgLTD`rLitQfK!*S}ikM!s*+HlynpAe#$zlTS)<6`{WtVdcrMD3` z0+QQ#f+z1m@;qE>)MIyP52@#KdXS4BpQ4~+KCpJZfFfwU;B>#W>(`tf%jxn%YSe4D zS?~HWf#$I}m?6O%1#iUCgS$yB-$%NOh%ZNtj$IAV+C>$Mo`|;C?dq0SL*rE#iHy@n z@3gTi{y`P6+=8y@+@DQ#r&hxDLzK?ZrRk_i;`t&Cr7D^KFtw`3auKu;`G!VL66AnJ z+5{N`skQ#y&rnR~W_u25X~$X=nO`|sVVDi>GLybr(1`L|(BjSwShzsiy*(kj&C|Qi z?CEXD>Ro3_j9+hbaAEhaXHdI(W-ovejMN;p7rk83t&Ih60JC*>aVCw*@9vsPBC+|X z2+ftRqF=qe_i-CI`!O!v)?Kqky31x|g|Y)`HKWd%z!=|Kmvt^-%{JmQ)kFjTkO(wA&)ZLtrrB zX*3n?MoN>i#0gCF7wSDBt86R1zK3!GHtXFtLtCQe$0GCRX@%@Z9U`BbLiWh~$28=8 zAg(SvDr1pQJLflZxN8V?wE)Vk$y>VZ36ps7_`p53e6zI`;Pu`$9^ z2rV~AE#BxyYV^;sIlS~Yyyb(|J6B=x;ZK0K2ZO-*f%B+*km4`WB8#zO^Y)B=ZX#CS zHws)B7M49ot38;iucAevq~xGvb@pRbE&+jr3Ch@?y0~8X(`r{Sp6;2wPZe$mmwM71hLcBTlT8- zSW<}a{-}2DjjzRX#Jh7AESjb}7hoGrgXJ>BT6YdYUUuh`6Hp7;ojIx9X`zPBplPDd z@*D6qS&I%+0e$yMYn;YFEL*X;AJYaYf_5_68}$7O&BBhp^Zhd2-T=!X zM$kiGReLc6vCqSk+4mG!0q;1i!TA{61kt1P9m0An)6at)%RN|qx?V>C{Nds=Vr(nv z!m5?e!snk{ug$}>PUWk;m8SK6HHvqH8vB^O-)IU^%+*lY2VT0@UW6xe41Y2`(E;n0pJSw9<6I^-&Rd_OgG~4C2<|7xV4YI2 zRjw}oOXx;p(fdA17Hy6d@?zc57eX(e?4lhX8tNRcH8kJ4WfIv}tI_Wv7Z1`}!S|ET z(!sAZ5n9xO>}To61Rb^l7!|MRjOiilj?H#u(sDD_jF(_Zyf~p74qA4gT<9NiKTq=# zfQJNty-_4L4}TU6~+&KwW9eEsg`VQ)~a6Iq~Lft z-0E)&u>{td25U%Sxe7mRN9CJC3J!4ga4rtRFAFK!$-JT+?JM(E76wotX2S~g+S^Psb6mDB0eOeRcAWi{70BMtkETtO>L?K7^%d1>&=aI}jJ) zSvib&8{&LyawtsDB4)a6DKl-fnJySJGH0u4q>b>YxVGX!lfQitYkGd|jF3_FaK>bS*|Bht~am5e5=V&Fx6VKffw>ipx;kG(hgM# zJE&v_mF%!6&lN~#0^T3@LC;3$5nW2!&V_RpIA?)#7C2{ta~3#ffpZo}SfFE~i>H@} zSZ2_cje;@0TZ0q$F+t1Urhg~|#t2+~KO}$amfzn^7Wwk~>I(#ogFYUnh&YCyLnzQ* zl7h_t^vj`kqPJzaD8d&ETCnB1cmhW?Je)PVcr1ULpKR7}ZMVl*zDBZ%B9@V0!-oa6 z9Flvfv!Z=+-;0wh9wv#nHqXUV5-$<7tapjvqkTICSw3Eld3$z_b#WZ;|D2ZPV%yE> z=^~#q{Xg6i-?1CYy5HvF$Ri@&CE^1jeoe&hiujC(M~u_t&KL2eBAz4Sg(AK|#7!bz zFXFpIe7}ev5%De&9}w|tA~sZ;nX*%n5@+cZvu4kkTUPF_sPt4Vyr!~po>H{DKHL@x zE3+N59M0m>FsGciJLfn`W_?XVmC_RDoRadAS*hyMQf53YWm&Fad1jmq)TG7DER+_{ zPK6kaYN@#CKA988giWCF%Hwe^*R$W_-`doay-GY)V{OplK_c zeMG+or39L%O_=?R^{4qc3-&)e!Ii>KnhCcV)(eNgjq3=#+nZ3&98pg(eX?a7A8yav zgdVvrf#l&X+)ZivWe4zd?fNBfs%QU&E~FUaX90*a*`bf;jc11nT}UOvOGu`(4{@X` z_YE$3-mq~J=XxfyLx%o6!|~zcMC+*G<8VAT;PCNW2;7A4#_6*JeV`xnOlii|HNffn zVdHn>H*#FBK}*x;S;}yjJ%|M=-S_JBo%Z-N{B&NQ?tAQ~GVsgqw~gORza;d~7d;e; z_?@vM8T7m(_y+`kso?(_^w9y} z)bEP0zuXVKmO;;n4ER5}p5#0)m-8{$u%)x}qzt$dIQ8RU@w~w7Jd|hPU&(RICyI;n z@iRK4)^R;kSc#!sD^am@{so(i^}PumxO+!pUCSO_)iG_?V`O3XbK-9R(LA)mIb>} zztFb`6m0yC?}<4++&^f%z>R(ulYpli52e5rp;I4ug`Op%ALV$sS>W_D9|bvXYcuFy zFZhlAM7L+)_j9`q-!DBZ^cekX{xgG~7c$^)2t9J2AnVT>0{DbK+|=Y~z}NTJRxb5< ztC!WlOC#ya;S06;;FZwkCohM_cHf$o_WHUOUt_2}5cJiBH{#bJxMKK2{zk{#*=1$v znYg=w51-=KZSvuFq5wP{0`M~MHHKSTH$g;4akq^WR{p_%DQYO43mhGAC4sw#&$n=? zdr_4SKi!aH39r9Q)2}@VEsa#GU_0Ce+8W6t#dFhQ_oC`bpgK0qd%)*|uc@y}6{=Ow zQgFeaMHX_6_qqzV*LU5*h0CgHd^PS0Zxt2I9WxSs719qy`yI>WlFkI=EAZ8>GAUjm zNx`{#R}JzwNoJ8w?!3W0PBcdkpWaDkm{W&v8cE~Z!M#>eRcjt8saVpT11(Q=d`U9S zf+NLOxrZ2BS(1X>NIsqS2)WM~vr}A(lJ(KtOEkBeR1wX=CW*n9!{CJ?Oh>LpdY_-9 z2)TktR~6aAdZ(czr`CkTn4m!h$^VTri{7(G^Z3zuASDabs+RD3;hss!Ts}nL^^(r@ zDy@4=imy^q50%1)Z(3KabUroGbt$QX>LNXDQjJJfGV+lpPAV6T@>DL(ODYx99H>$; z<_Kf%t{8bPgT3p?t=&2V9d1sz1ukG{;& zxTy{Lv^W&da@ND6sJXo@h43LSfFJ8gK%_caLd?Mjg#$^)ns$(ISi_xrWjO-v+^fss zUn?fYwT)0BDNR(H+cXK8zO?~tD5kEpxdC-(50QEx zS{t!l;X$5jlnFqd(}`@(E7KHTf{V_^q`W-;kpBlkL7qNf`AP{+P`= { + console.error(`Caught exception: ${err}`); }); // light-node -Blockchain.createBlockchain('full-node', ()=>{}, async ()=>{ +Blockchain.createBlockchain('full-node', () => {}, async () => { await Node.NodeExpress.startExpress(); @@ -22,14 +22,10 @@ Blockchain.createBlockchain('full-node', ()=>{}, async ()=>{ Node.NodeClientsService.startService(); Node.NodeServer.startServer(); - - -}, ()=>{ +}, () => { }); process.on('SIGINT', async () => { - await termination(Blockchain); - }); diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js new file mode 100644 index 000000000..91e18051f --- /dev/null +++ b/src/node/menu/CLI-Core.js @@ -0,0 +1,764 @@ +/* eslint-disable */ +import CONNECTION_TYPE from '../lists/types/Connection-Type'; +import NODES_CONSENSUS_TYPE from '../lists/types/Node-Consensus-Type'; +import consts from 'consts/const_global'; +import { Node } from '../../index.js'; +import AdvancedMessages from './Advanced-Messages'; +import WebDollarCoins from 'common/utils/coins/WebDollar-Coins'; +import InterfaceBlockchainAddressHelper from 'common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper'; +import Blockchain from 'main-blockchain/Blockchain'; +import StatusEvents from 'common/events/Status-Events'; +import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; +import Log from 'common/utils/logging/Log'; +import AddressBanList from 'common/utils/bans/AddressBanList'; + + +const FileSystem = require('fs'); +const readline = require('readline'); + +let NodeExpress, NodeServer; + +if (!process.env.BROWSER) { + NodeExpress = require('node/sockets/node-server/express/Node-Express').default; + NodeServer = require('node/sockets/node-server/sockets/Node-Server').default; +} + + +export class CLICore { + + static get INSTANCE() { + return new CLICore(); + } + + constructor() {} + + signTransaction() { + + console.info('Sign Transaction'); + + return new Promise(async (resolve) => { + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + resolve(false); + return; + } + + let toAddress = await AdvancedMessages.input('Enter the recipient address: '); + let amountToSend = await AdvancedMessages.input('Enter the transaction amount: '); + let nonce = await AdvancedMessages.input('Enter the address current nonce: '); + let timelock = await AdvancedMessages.input('Enter the current block: '); + let addressPath = await AdvancedMessages.input('Enter path for saving the transaction:'); + let wantToPropagate = await AdvancedMessages.input('Do you want to propagate now y/n?:'); + + if (wantToPropagate.toUpperCase().trim() === 'Y' ? true : false) + wantToPropagate = true; + else + wantToPropagate = false; + + let feeToSend = Blockchain.Transactions.wizard.calculateFeeSimple(amountToSend); + + let addressString = Blockchain.Wallet.addresses[addressId].address; + let answer = null; + + //Trick for blocks length and address nonce + Blockchain.blockchain.blocks._length = timelock + 1; + + for (let i = 0; i < Blockchain.Wallet.addresses.length; i++) + if (addressString === Blockchain.Wallet.addresses[i].address) + answer = await Blockchain.Transactions.wizard.validateTransaction(Blockchain.Wallet.addresses[i].address, toAddress, amountToSend * WebDollarCoins.WEBD, feeToSend, undefined, undefined, timelock - 1, nonce, true); + + let data = {}; + + if (answer.result) { + + data.transaction = answer.transaction.serializeTransaction(); + data.signature = answer.signature; + + if (wantToPropagate) + await Blockchain.blockchain.transactions.pendingQueue.includePendingTransaction(answer.transaction, undefined, true); + + } else { + + console.log("Transaction was not created. " + answer.message); + resolve(false); + return; + + } + + FileSystem.writeFile(addressPath + "transaction.tx", JSON.stringify(data), 'utf8', (err) => { + + if (err) { + console.error(err); + resolve(false); + return; + } + + console.log("Transaction successfully exported to ," + addressPath + "transaction.tx"); + + resolve(true); + + }); + + resolve(true); + + }); + + } + + async processRemainingPayment() { + + await this._callCallbackBlockchainSync(undefined, undefined, undefined, async () => { + await Blockchain.PoolManagement.poolRemainingRewards.doPayout(); + }, true); + + } + + async _chooseAddress(id = undefined) { + + await this.listAddresses(); + + let addressId = !!id ? id : await AdvancedMessages.readNumber('Choose the address number: '); + + if (isNaN(addressId) || addressId < 0 || Blockchain.Wallet.addresses.length <= addressId) + return -1; + + return addressId; + } + + async _chooseAddressNonInteractive(pos) { + console.log(`Choosing Address ${pos} from addresses:`) + await this.listAddresses(); + + if (isNaN(pos) || pos < 0 || Blockchain.Wallet.addresses.length <= pos) + return -1; + + return pos; + } + + async AddAddressBanList() { + + let addressWIF = await AdvancedMessages.input('Please input miner address: '); + if (addressWIF.length == 40) { + let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); + if (unencodedAddress) { + let duration = await AdvancedMessages.readNumber('Ban duration (hours): '); + let reason = await AdvancedMessages.input('Please input ban reason: '); + reason = reason.replace(';', '.,'); + AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); + AddressBanList.listBans(); + } + } + + } + + async LoadAddressBanList() { + + try { + + const file = FileSystem.createReadStream('address-ban-list.txt'); + + const rl = readline.createInterface({ + input: file, + crlfDelay: Infinity + }); + + rl.on('error', (err) => { + console.error('Address ban list was not found'); + }); + + file.on('error', (err) => { + console.error('Address ban list was not found'); + }); + + rl.on('line', (line) => { + let triplet = line.split(';'); + if (triplet.length === 3) { + + let duration = parseFloat(triplet[0]); + let addressWIF = triplet[1]; + let reason = triplet[2]; + + if (addressWIF && addressWIF.length == 40) { + let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); + if (unencodedAddress) + AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); + } + } else console.log("Invalid line in address-ban-list.txt", line); + }); + + rl.on('close', () => { + AddressBanList.listBans(); + }); + + } catch (exception) { + console.error("Error loading banlist: ", exception); + } + } + + async SaveAddressBanList() { + AddressBanList.saveBans(); + } + + async listAddresses() { + + + console.warn("INFO: YOU NEED TO BE SYNC TO SEE THE VALUE OF YOUR WALLET!!!"); + console.info('\nWallet addresses:'); + + let miningAddress = Blockchain.blockchain.mining.minerAddress; + if ( !miningAddress ) + miningAddress = 'not specified'; + + console.log(addressHeader); + for (let i = 0; i < Blockchain.Wallet.addresses.length; ++i) { + + let address = Blockchain.Wallet.addresses[i].address; + + let balance = Blockchain.blockchain.accountantTree.getBalance(address, undefined); + + balance = (balance === null) ? 0 : (balance / WebDollarCoins.WEBD); + + if (address === miningAddress) + console.log(((i < 10) ? "| *" : "| *") + i + " | " + address + " | " + balance + lineSeparator); + else + console.log(((i < 10) ? "| " : "| ") + i + " | " + address + " | " + balance + lineSeparator); + + } + + let balance = 0; + if (miningAddress !== 'not specified') { + balance = Blockchain.blockchain.accountantTree.getBalance(miningAddress, undefined); + balance = (balance === null) ? 0 : balance; + + if (Blockchain.MinerPoolManagement && Blockchain.MinerPoolManagement.minerPoolStarted) + balance += Blockchain.MinerPoolManagement.minerPoolReward.total; + + balance /= WebDollarCoins.WEBD; + + + } + console.log("| MINING| " + miningAddress + " | " + balance + lineSeparator); + + return true; + + } + + async createNewAddress() { + + console.info('Create new address.'); + try { + let address = await Blockchain.Wallet.createNewAddress(); + console.info("Address was created: " + address.address); + return true; + } catch (err) { + console.err(err); + return false; + } + + } + + async deleteAddress(id) { + + console.info('Delete address.'); + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + return false; + } + + let response = await Blockchain.Wallet.deleteAddress(Blockchain.Wallet.addresses[addressId].address); + + return response.result; + } + + importAddress(path) { + + console.info('Import address.'); + + return new Promise(async (resolve) => { + path = !!path ? path : AdvancedMessages.input('Enter address path: '); + + FileSystem.readFile(path, 'utf8', async (err, content) => { + + if (err) { + console.error(err); + resolve(false); + return; + } + + try { + + let answer = await Blockchain.Wallet.importAddressFromJSON(JSON.parse(content)); + + if (answer.result === true) { + console.log("Address successfully imported", answer.address); + await Blockchain.Wallet.saveWallet(); + + if (Blockchain.Wallet.addresses.length === 1) Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[0].address; + + resolve(true); + } else { + console.error(answer.message); + resolve(false); + } + + } catch (err) { + console.error(err.message); + resolve(false); + } + }); + }); + + } + + exportAddress(id) { + + console.info('Export address.'); + + return new Promise(async (resolve) => { + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + resolve(false); + return; + } + + let addressPath = await AdvancedMessages.input('Enter path for saving address: '); + + let addressString = Blockchain.Wallet.addresses[addressId].address; + let fileName = "WEBD$" + Blockchain.Wallet.addresses[addressId].unencodedAddress.toString("hex") + ".webd"; + + let answer = await Blockchain.Wallet.exportAddressToJSON(addressString); + + if (answer.result === false) { + console.log("Address was not exported. :(. " + answer.message); + resolve(false); + return; + } + + let jsonAddress = JSON.stringify(answer.data); + + FileSystem.writeFile(addressPath + fileName, jsonAddress, 'utf8', (err) => { + + if (err) { + console.error(err); + resolve(false); + return; + } + + console.log("Address successfully exported", addressString, ' to ', addressPath + fileName); + + resolve(true); + return; + + }); + + resolve(true); + return; + + }); + + } + + async encryptAddress(id) { + + console.info('Encrypt address.'); + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + return false; + } + + let addressString = Blockchain.Wallet.addresses[addressId].address; + let newPassword = await InterfaceBlockchainAddressHelper.askForPassword("Please enter a password(12 words separated by space):"); + let response = await Blockchain.Wallet.encryptAddress(addressString, newPassword); + + if (response === true) + console.info("Address was encrypted:", addressString); + else + console.error("Address couldn't be encrypted:", addressString); + + return response.result; + } + + async setMiningAddress(id) { + + console.info('Set mining address.'); + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + return false; + } + + Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[addressId].address; + + return true; + } + + async startMining(instantly) { + + + await this._callCallbackBlockchainSync(undefined, () => Blockchain.MinerPoolManagement.minerPoolSettings.setMinerPoolActivated(false), async () => { + + if (instantly) + await Blockchain.startMiningInstantly(); + else + Blockchain.startMiningNextTimeSynchronized = true; + + }, undefined, undefined); + + } + + async startMiningInsidePool(url, isInteractive = true) { + + Log.info('Mining inside a POOL', Log.LOG_TYPE.POOLS); + + consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; + + await this._callCallbackBlockchainSync(undefined, async () => { + + try { + + let getNewLink = true; + + if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '' && isInteractive) { + + Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); + let response = await AdvancedMessages.confirm('Do you want to continue mining in the same pool: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolURL); + + if (response === true) getNewLink = false; + } + + let miningPoolLink = undefined; + + if (getNewLink) { + + miningPoolLink = !!url ? url : await AdvancedMessages.input('Enter the new mining pool link: '); + Log.info('Your new MiningPool is : ' + miningPoolLink, Log.LOG_TYPE.info); + + } + + StatusEvents.on("miner-pool/connection-established", (data) => { + if (data.connected) + Blockchain.Mining.startMining(); + else + Blockchain.Mining.stopMining(); + }); + + Blockchain.MinerPoolManagement.startMinerPool(miningPoolLink, true); + + } catch (exception) { + + Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); + + } + + }, undefined, undefined, false); + + } + + async nonInteractiveMineInPool(url) { + Log.info('Mining inside a POOL: ' + url, Log.LOG_TYPE.POOLS); + + consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; + + await this._callCallbackBlockchainSync(undefined, async () => { + + try { + + let getNewLink = !!url; + + if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '') { + + Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); + + if (!getNewLink) { + console.log('A new link was not provided. This will be used.'); + url = Blockchain.MinerPoolManagement.minerPoolSettings.poolURL + } else { + console.log('A new link was provided. It will overwrite the old link.'); + } + } + + StatusEvents.on("miner-pool/connection-established", (data) => { + if (data.connected) + Blockchain.Mining.startMining(); + else + Blockchain.Mining.stopMining(); + }); + + Blockchain.MinerPoolManagement.startMinerPool(url, true); + + } catch (exception) { + + Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); + + } + + }, undefined, undefined, false); + + let mining = true; + + process.on('SIGTERM', () => { + console.log('SIGTERM received. Shutting down.'); + mining = false; + }); + + process.on('SIGINT', () => { + console.log('SIGINT received. Shutting down.'); + mining = false; + }); + + while (mining) { + // still mining, no sigterm received + await new Promise(resolve => setTimeout(resolve, 10000)); + } + } + + async createMiningPool() { + + Log.info('Create Mining Pool', Log.LOG_TYPE.info); + + await this._callCallbackBlockchainSync(async () => { + + try { + + await Blockchain.PoolManagement.setPoolStarted(false); + + let getNewLink = true; + + Log.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.', Log.LOG_TYPE.info); + + if (typeof Blockchain.PoolManagement.poolSettings.poolURL === "string" && Blockchain.PoolManagement.poolSettings.poolURL !== '') { + + console.info('You have some settings for a pool: ', Blockchain.PoolManagement.poolSettings.poolName, " ", Blockchain.PoolManagement.poolSettings.poolWebsite); + let response = await AdvancedMessages.confirm('Do you want to continue using the settings for : ' + Blockchain.PoolManagement.poolSettings.poolURL); + + if (response === true) getNewLink = false; + } + + if (getNewLink) { + + let poolFee, poolReferralFee, poolName, poolWebsite, poolServers; + + + poolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); + + if (isNaN(poolFee) || poolFee < 0 || 100 < poolFee) { + Log.error("You have entered an invalid number: " + poolFee, Log.LOG_TYPE.POOLS); + return false; + } else + Log.info("Your fee is " + poolFee, Log.LOG_TYPE.POOLS); + + poolName = await AdvancedMessages.input('Pool Name: '); + poolWebsite = await AdvancedMessages.input('Pool Website: '); + + poolReferralFee = await AdvancedMessages.readNumber("Choose a Referral fee (0...100): ", true); + if (isNaN(poolReferralFee) || poolReferralFee < 0 || 100 < poolReferralFee) { + Log.error("You have entered an invalid number:" + poolReferralFee, Log.LOG_TYPE.POOLS); + return false; + } else + Log.warn("Your Referral fee is: " + poolReferralFee, Log.LOG_TYPE.POOLS); + + let response = await AdvancedMessages.confirm('Do you want to use external pool servers?: '); + + if (response) + poolServers = await AdvancedMessages.input('Pool Servers (separated by comma): '); + else + poolServers = await NodeServer.getServerHTTPAddress(true); + + console.info("Pool Servers:", poolServers); + + if (response) { + await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(true); + } else { + await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(false); + await Blockchain.PoolManagement.poolSettings.setPoolUseSignatures(false); + } + + + if (poolFee) await Blockchain.PoolManagement.poolSettings.setPoolFee(poolFee / 100); + if (poolName) await Blockchain.PoolManagement.poolSettings.setPoolName(poolName); + if (poolWebsite) await Blockchain.PoolManagement.poolSettings.setPoolWebsite(poolWebsite); + if (poolServers) await Blockchain.PoolManagement.poolSettings.setPoolServers(poolServers); + if (poolReferralFee) await Blockchain.PoolManagement.poolSettings.setPoolReferralFee(poolReferralFee / 100); + + } + + } catch (exception) { + + Log.error("Error starting your pool", Log.LOG_TYPE.POOLS, exception); + + } + + }, async () => { + + await Blockchain.PoolManagement.startPool(true); + + }, undefined, undefined, true); + + } + + async createServerForMiningPool() { + + await this._callCallbackBlockchainSync(async () => { + + console.info('Create Server Pool'); + console.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.'); + + let serverPoolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); + + if (isNaN(serverPoolFee) || serverPoolFee < 0 || 100 < serverPoolFee) { + console.log("You have entered an invalid number:", serverPoolFee); + return false; + } else + console.log("your fee is", serverPoolFee); + + await Blockchain.ServerPoolManagement.serverPoolSettings.setServerPoolFee(serverPoolFee / 100); + + }, + async () => { + + await Blockchain.ServerPoolManagement.startServerPool(); + + }, undefined, undefined, true, + ); + + + } + + async _callCallbackBlockchainSync(callbackBeforeBlockchainLoaded, callbackBeforeServerInitialization, callbackAfterServerInitialization, afterSynchronizationCallback, synchronize = true) { + + if (!Blockchain._blockchainInitiated) { + + await Blockchain.createBlockchain("full-node", callbackBeforeBlockchainLoaded, async () => { + + if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); + + await Node.NodeServer.startServer(); + + await Node.NodeClientsService.startService(); + + if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); + + }, afterSynchronizationCallback, synchronize); + + } else { + + if (callbackBeforeBlockchainLoaded) await callbackBeforeBlockchainLoaded(); + + if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); + + if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); + + if (afterSynchronizationCallback) await afterSynchronizationCallback(); + + } + + } + + + disableForksImmutability() { + + consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH += 10000; + + setTimeout(() => { + + consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH -= 10000; + + }, 10 * 60 * 1000); + + } + + disconnectFromAllConnectedNodes() { + + let NodesList = require('node/lists/Nodes-List').default; + NodesList.disconnectAllNodes(CONNECTION_TYPE.CONNECTION_CLIENT_SOCKET); + + } + + disconnectAllMinersNodes() { + + let NodesList = require('node/lists/Nodes-List').default; + NodesList.disconnectAllNodesByConsensusType(NODES_CONSENSUS_TYPE.NODE_CONSENSUS_MINER_POOL); + + } + + async setIntervalDisconnectAllMinersNodes(interval) { + + let intervalTime = !!interval || interval === 0 ? interval : await AdvancedMessages.readNumber('Enter the interval time: \n 0 - disable interval \n x - minutes'); + + if (this._intervalDisconnectingMiners) + clearTimeout(this._intervalDisconnectingMiners); + + if (intervalTime > 0) { + + this._intervalDisconnectingMiners = setInterval(() => { + this.disconnectAllMinersNodes(); + }, intervalTime * 60 * 1000); + + } + + } + + showCommands() { + + console.info('\nChoose one of the following commands:'); + + console.info("\nflagged arguments (example: -l, --list-addresses) can only be used in non-interactive mode.\nUse numbers for interactive mode.\n") + for (let i = 0; i < commands.length; ++i) { + console.info(commands[i]); + } + console.log(); + + return true; + } + +} + +const commands = [ + '1. List addresses (-l --list-addresses)', + '2. Create new address (--create-address)', + '3. Delete address (--delete-address {position in wallet list})', + '4. Import address (--import-address {path to wallet})', + '5. Export address (--export-address {position in wallet list})', + '6. Encrypt address (--encrypt-address {position in wallet list})', + '7. Set mining address (--mining-address {position in wallet list})', + '8. Solo: Start Mining (--mine)', + '9. Solo: Start Mining Instantly Even Unsynchronized (--mine-now)', + '10. Mining Pool: Start Mining (--mine-in-pool {pool url})', + '11. Mining Pool: Create a New Pool', + '11-1. Mining Pool: Process Remaining Payment', + '12. Server for Mining Pool: Create a new Server for Mining Pool (Optional and Advanced)', + '13. Create Offline Transaction', + '20. HTTPS Express Start', + '21. Disable Node Immutability', + '22. Disconnect from all consensus nodes', + '23. Disconnect all miner nodes', + '24. Set Interval to disconnect all miner nodes', + '30. Set Password for Mining Address', + '53. Add address to banlist', + '54. Load address banlist', + '55. Save address banlist', +]; + +const lineSeparator = + "\n|_______|____________________________________________|_________________|"; + +const addressHeader = + "\n ______________________________________________________________________" + + "\n| NUM | ADDRESS | WEBD |" + + lineSeparator; + +export default CLICore; diff --git a/src/node/menu/CLI-Menu-non-interactive.js b/src/node/menu/CLI-Menu-non-interactive.js new file mode 100644 index 000000000..69dcbc7e3 --- /dev/null +++ b/src/node/menu/CLI-Menu-non-interactive.js @@ -0,0 +1,164 @@ +/* eslint-disable */ +import CLICore from './CLI-Core'; + +class CLIRunner { + + static get CORE() { + return CLICore.INSTANCE; + } + + /** + * + * @param args - string array of arguments. + */ + constructor(args) { + console.log("Running %o", args); + this.args = args; + } + + async run() { + while (this.args.length > 0) { + this.args = await this.runCommand(this.args); + } + } + + async runCommand(args) { + + let [command, ...rest] = args; + + switch (command.trim()) { + case '1': // List addresses' + case '-l': + case '--list-addresses': + await CLIRunner.CORE.listAddresses(); + break; + case '2': // Create new address', + case '--create-address': + await CLIRunner.CORE.createNewAddress(); + break; + case '3': // Delete Address + case '--delete-address': + let deleteId = rest.shift(); + await CLIRunner.CORE.deleteAddress(deleteId); + break; + case '4': // Import Address + case '--import-address': + let walletPath = rest.shift(); + await CLIRunner.CORE.importAddress(walletPath); + break; + case '5': // Export Address + case '--export-address': + let exportId = rest.shift(); + await CLIRunner.CORE.exportAddress(exportId); + break; + case '6': // Encrypt Address + case '--encrypt-address': + let encryptId = rest.shift(); + await CLIRunner.CORE.encryptAddress(encryptId); + break; + case '7': // Set Mining Address + case '--mining-address': + let pos = rest.shift(); + await CLIRunner.CORE.setMiningAddress(pos); + break; + case '8': // Start Mining + case '--mine': + await CLIRunner.CORE.startMining(); + await this.waitForMiningToStop(); + break; + case '9': // Start Mining Instantly + case '--mine-now': + await CLIRunner.CORE.startMining(true); + await this.waitForMiningToStop(); + break; + case '10': // Mining Pool: Start Mining in a Pool + case '--mine-in-pool': + let url = rest.shift(); + await CLIRunner.CORE.startMiningInsidePool(url, false); + await this.waitForMiningToStop(); + break; + case '11-1': // Mining Pool: Create a New Pool + case '--process-payments': + console.error('Remaining payments can\'t be processed non-interactively at this time!'); + break; + case '11': // Mining Pool: Create a New Pool + case '--create-pool': + console.error('Mining pools cannot be made non-interactively at this time!'); + break; + case '12': // Server Mining Pool Create a new Server for Mining Pool + case '--create-server-for-pool': + console.error('Mining pools cannot be made non-interactively at this time!'); + break; + case '13': // Import Address + case '--sign-transaction': + console.error('Transactions cannot be signed non-interactively at this time!'); + break; + case '20': // Server Mining Pool: Create a new Server for Mining Pool + case '--start-pool-server': + console.error('Mining Pool Servers cannot be started non-interactively at this time!'); + break; + case '21': // Disable Forks Immutability + case '--disable-forks-immutability': + await CLIRunner.CORE.disableForksImmutability(); + break; + case '22': // Disable Forks Immutability + case '--disconnect-from-all-nodes': + await CLIRunner.CORE.disconnectFromAllConnectedNodes(); + break; + case '23': + case '--disconnect-all-miners-nodes': + await CLIRunner.CORE.disconnectAllMinersNodes(); + break; + case '24': + case '--set-disconnect-interval': + await CLIRunner.CORE.setIntervalDisconnectAllMinersNodes(); + break; + case '30': // Set Password + case '--set-password': + await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(); + break; + case '53': // add banlist + case '--add-to-banlist': + console.error('The ban list cannot be modified non-interactively at this time.'); + break; + case '54': // load banlist + case '--load-banlist': + console.error('The ban list cannot be modified non-interactively at this time.'); + break; + case '55': // save banlist + case '--save-banlist': + console.error('The ban list cannot be modified non-interactively at this time.'); + break; + default: // show usage. + CLIRunner.CORE.showCommands(); + break; + } + + return rest; + }; + + async waitForMiningToStop() { + console.log("Mining will continue until the SIGINT or SIGTERM signal is received."); + + let isMining = true; + + process.on('SIGINT', () => isMining = false); + process.on('SIGTERM', () => isMining = false); + + const snooze = ms => new Promise(resolve => setTimeout(resolve, ms)); + return new Promise(async (resolve) => { + + const waitForMining = async () => { + await snooze(10000); + }; + + while (isMining) { + await waitForMining(); + } + resolve(); + }) + } + +} + +export default CLIRunner; diff --git a/src/node/menu/CLI-Menu.js b/src/node/menu/CLI-Menu.js index addfd3e4b..e459cad3e 100644 --- a/src/node/menu/CLI-Menu.js +++ b/src/node/menu/CLI-Menu.js @@ -1,10 +1,4 @@ /* eslint-disable */ -import CONNECTION_TYPE from "../lists/types/Connection-Type"; -import NODES_CONSENSUS_TYPE from "../lists/types/Node-Consensus-Type"; - - -const FileSystem = require('fs'); -const readline = require('readline'); import {JsonRpcServer} from './../jsonRpc'; let NodeExpress, NodeServer; @@ -16,18 +10,19 @@ if (!process.env.BROWSER) { import consts from 'consts/const_global'; -import {Node} from '../../index.js'; import AdvancedMessages from './Advanced-Messages'; -import WebDollarCoins from "common/utils/coins/WebDollar-Coins"; -import InterfaceBlockchainAddressHelper from "common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper"; import Blockchain from "main-blockchain/Blockchain" -import StatusEvents from "common/events/Status-Events"; import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; import Log from 'common/utils/logging/Log'; -import AddressBanList from "common/utils/bans/AddressBanList"; +import CLICore from "./CLI-Core"; +import CLIRunner from './CLI-Menu-non-interactive'; class CLI { + static get CORE() { + return CLICore.INSTANCE; + } + constructor() { if (process.env.BROWSER) @@ -35,7 +30,22 @@ class CLI { this._exitMenu = undefined; - this._start(); + // parse cli args + this.cliArgs = process.argv; + + if (!this.cliArgs.includes('--')) { + this._startInteractive(); + } else { + console.log("Non-interactive activated. Args will be read from left to right."); + this.cliArgs = this.cliArgs.splice(this.cliArgs.indexOf('--')); + if (this.cliArgs.length <= 0) { + CLI.CORE.showCommands(); + } + console.log('Working with args: %o', this.cliArgs); + this.runner = new CLIRunner(this.cliArgs); + this.runner.run() + .then(() => process.exit()); + } } @@ -51,166 +61,90 @@ class CLI { switch (answer.trim()) { case '1': // List addresses' - await this.listAddresses(); + await CLI.CORE.listAddresses(); break; case '2': // Create new address', - await this.createNewAddress(); + await CLI.CORE.createNewAddress(); break; case '3': // Delete Address - await this.deleteAddress(); + await CLI.CORE.deleteAddress(); break; case '4': // Import Address - await this.importAddress(); + await CLI.CORE.importAddress(); break; case '5': // Export Address - await this.exportAddress(); + await CLI.CORE.exportAddress(); break; case '6': // Encrypt Address - await this.encryptAddress(); + await CLI.CORE.encryptAddress(); break; case '7': // Set Mining Address - await this.setMiningAddress(); + await CLI.CORE.setMiningAddress(); break; case '8': // Start Mining - await this.startMining(); + await CLI.CORE.startMining(); break; case '9': // Start Mining Instantly - await this.startMining(true); + await CLI.CORE.startMining(true); break; case '10': // Mining Pool: Start Mining in a Pool - await this.startMiningInsidePool(); + await CLI.CORE.startMiningInsidePool(); break; case '11-1': // Mining Pool: Create a New Pool - await this.processRemainingPayment(); + await CLI.CORE.processRemainingPayment(); break; case '11': // Mining Pool: Create a New Pool - await this.createMiningPool(); + await CLI.CORE.createMiningPool(); break; case '12': // Server Mining Pool: Create a new Server for Mining Pool - await this.createServerForMiningPool(); + await CLI.CORE.createServerForMiningPool(); break; case '13': // Import Address - await this.signTransaction(); + await CLI.CORE.signTransaction(); break; case '20': // Server Mining Pool: Create a new Server for Mining Pool await NodeServer.startServer(); break; case '21': // Disable Forks Immutability - await this.disableForksImmutability(); + await CLI.CORE.disableForksImmutability(); break; case '22': // Disable Forks Immutability - await this.disconnectFromAllConnectedNodes(); + await CLI.CORE.disconnectFromAllConnectedNodes(); break; case '23': - await this.disconnectAllMinersNodes(); + await CLI.CORE.disconnectAllMinersNodes(); break; case '24': - await this.setIntervalDisconnectAllMinersNodes(); + await CLI.CORE.setIntervalDisconnectAllMinersNodes(); break; case '30': // Set Password await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(); break; case '53': // add banlist - await this.AddAddressBanList(); + await CLI.CORE.AddAddressBanList(); break; case '54': // add banlist - await this.LoadAddressBanList(); + await CLI.CORE.LoadAddressBanList(); break; case '55': // add banlist - await this.SaveAddressBanList(); + await CLI.CORE.SaveAddressBanList(); break; case 'exit': this._exitMenu = true; break; default: - this._showCommands(); + CLI.CORE.showCommands(); break; } await this._runMenu(); }; - signTransaction() { - - console.info('Sign Transaction'); - - return new Promise(async (resolve) => { - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - resolve(false); - return; - } - - let toAddress = await AdvancedMessages.input('Enter the recipient address: '); - let amountToSend = await AdvancedMessages.input('Enter the transaction amount: '); - let nonce = await AdvancedMessages.input('Enter the address current nonce: '); - let timelock = await AdvancedMessages.input('Enter the current block: '); - let addressPath = await AdvancedMessages.input('Enter path for saving the transaction:'); - let wantToPropagate = await AdvancedMessages.input('Do you want to propagate now y/n?:'); - - if (wantToPropagate.toUpperCase().trim() === 'Y' ? true : false) - wantToPropagate = true; - else - wantToPropagate = false; - - let feeToSend = Blockchain.Transactions.wizard.calculateFeeSimple(amountToSend); - - let addressString = Blockchain.Wallet.addresses[addressId].address; - let answer = null; - - //Trick for blocks length and address nonce - Blockchain.blockchain.blocks._length = timelock + 1; - - for (let i = 0; i < Blockchain.Wallet.addresses.length; i++) - if (addressString === Blockchain.Wallet.addresses[i].address) - answer = await Blockchain.Transactions.wizard.validateTransaction(Blockchain.Wallet.addresses[i].address, toAddress, amountToSend * WebDollarCoins.WEBD, feeToSend, undefined, undefined, timelock - 1, nonce, true); - - let data = {}; - - if (answer.result) { - - data.transaction = answer.transaction.serializeTransaction(); - data.signature = answer.signature; - - if (wantToPropagate) - await Blockchain.blockchain.transactions.pendingQueue.includePendingTransaction(answer.transaction, undefined, true); - - } else { - - console.log("Transaction was not created. " + answer.message); - resolve(false); - return; - - } - - FileSystem.writeFile(addressPath + "transaction.tx", JSON.stringify(data), 'utf8', (err) => { - - if (err) { - console.error(err); - resolve(false); - return; - } - - console.log("Transaction successfully exported to ," + addressPath + "transaction.tx"); - - resolve(true); - - }); - - resolve(true); - - }); - - } - - async _start() { + async _startInteractive() { Log.info('CLI menu started', Log.LOG_TYPE.CLI_MENU); - if (Blockchain ) + if (Blockchain) await Blockchain.loadWallet(); this._showCommands(); @@ -222,588 +156,8 @@ class CLI { await this._runMenu(); } - async processRemainingPayment() { - - await this._callCallbackBlockchainSync(undefined, undefined, undefined, async () => { - await Blockchain.PoolManagement.poolRemainingRewards.doPayout(); - }, true); - - } - - async _chooseAddress() { - - await this.listAddresses(); - - let addressId = await AdvancedMessages.readNumber('Choose the address number: '); - - if (isNaN(addressId) || addressId < 0 || Blockchain.Wallet.addresses.length <= addressId) - return -1; - - return addressId; - } - - async AddAddressBanList() { - - let addressWIF = await AdvancedMessages.input('Please input miner address: '); - if (addressWIF.length == 40) { - let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); - if (unencodedAddress) { - let duration = await AdvancedMessages.readNumber('Ban duration (hours): '); - let reason = await AdvancedMessages.input('Please input ban reason: '); - reason = reason.replace(';', '.,'); - AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); - AddressBanList.listBans(); - } - } - - } - - async LoadAddressBanList() { - - try { - - const file = FileSystem.createReadStream('address-ban-list.txt'); - - const rl = readline.createInterface({ - input: file, - crlfDelay: Infinity - }); - - rl.on('error', (err) => { - console.error('Address ban list was not found'); - }); - - file.on('error', (err) => { - console.error('Address ban list was not found'); - }); - - rl.on('line', (line) => { - let triplet = line.split(';'); - if (triplet.length === 3) { - - let duration = parseFloat(triplet[0]); - let addressWIF = triplet[1]; - let reason = triplet[2]; - - if (addressWIF && addressWIF.length == 40) { - let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); - if (unencodedAddress) - AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); - } - } else console.log("Invalid line in address-ban-list.txt", line); - }); - - rl.on('close', () => { - AddressBanList.listBans(); - }); - - } catch (exception) { - console.error("Error loading banlist: ", exception); - } - } - - async SaveAddressBanList() { - AddressBanList.saveBans(); - } - - _showCommands() { - - console.info('\nChoose one of the following commands:'); - - for (let i = 0; i < commands.length; ++i) { - console.info(commands[i]); - } - console.log(); - - return true; - } - - async listAddresses() { - - - console.warn("INFO: YOU NEED TO BE SYNC TO SEE THE VALUE OF YOUR WALLET!!!"); - console.info('\nWallet addresses:'); - - let miningAddress = Blockchain.blockchain.mining.minerAddress; - if ( !miningAddress ) - miningAddress = 'not specified'; - - console.log(addressHeader); - for (let i = 0; i < Blockchain.Wallet.addresses.length; ++i) { - - let address = Blockchain.Wallet.addresses[i].address; - - let balance = Blockchain.blockchain.accountantTree.getBalance(address, undefined); - - balance = (balance === null) ? 0 : (balance / WebDollarCoins.WEBD); - - if (address === miningAddress) - console.log(((i < 10) ? "| *" : "| *") + i + " | " + address + " | " + balance + lineSeparator); - else - console.log(((i < 10) ? "| " : "| ") + i + " | " + address + " | " + balance + lineSeparator); - - } - - let balance = 0; - if (miningAddress !== 'not specified') { - balance = Blockchain.blockchain.accountantTree.getBalance(miningAddress, undefined); - balance = (balance === null) ? 0 : balance; - - if (Blockchain.MinerPoolManagement && Blockchain.MinerPoolManagement.minerPoolStarted) - balance += Blockchain.MinerPoolManagement.minerPoolReward.total; - - balance /= WebDollarCoins.WEBD; - - - } - console.log("| MINING| " + miningAddress + " | " + balance + lineSeparator); - - return true; - - } - - async createNewAddress() { - - console.info('Create new address.'); - try { - let address = await Blockchain.Wallet.createNewAddress(); - console.info("Address was created: " + address.address); - return true; - } catch (err) { - console.err(err); - return false; - } - - } - - async deleteAddress() { - - console.info('Delete address.'); - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - return false; - } - - let response = await Blockchain.Wallet.deleteAddress(Blockchain.Wallet.addresses[addressId].address); - - return response.result; - } - - importAddress() { - - console.info('Import address.'); - - return new Promise(async (resolve) => { - - let addressPath = await AdvancedMessages.input('Enter address path: '); - - FileSystem.readFile(addressPath, 'utf8', async (err, content) => { - - if (err) { - console.error(err); - resolve(false); - return; - } - - try { - - let answer = await Blockchain.Wallet.importAddressFromJSON(JSON.parse(content)); - - if (answer.result === true) { - console.log("Address successfully imported", answer.address); - await Blockchain.Wallet.saveWallet(); - - if (Blockchain.Wallet.addresses.length === 1) Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[0].address; - - resolve(true); - } else { - console.error(answer.message); - resolve(false); - } - - } catch (err) { - console.error(err.message); - resolve(false); - } - - - }); - - }); - - } - - exportAddress() { - - console.info('Export address.'); - - return new Promise(async (resolve) => { - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - resolve(false); - return; - } - - let addressPath = await AdvancedMessages.input('Enter path for saving address: '); - - let addressString = Blockchain.Wallet.addresses[addressId].address; - let fileName = "WEBD$" + Blockchain.Wallet.addresses[addressId].unencodedAddress.toString("hex") + ".webd"; - - let answer = await Blockchain.Wallet.exportAddressToJSON(addressString); - - if (answer.result === false) { - console.log("Address was not exported. :(. " + answer.message); - resolve(false); - return; - } - - let jsonAddress = JSON.stringify(answer.data); - - FileSystem.writeFile(addressPath + fileName, jsonAddress, 'utf8', (err) => { - - if (err) { - console.error(err); - resolve(false); - return; - } - - console.log("Address successfully exported", addressString, ' to ', addressPath + fileName); - - resolve(true); - return; - - }); - - resolve(true); - return; - - }); - - } - - async encryptAddress() { - - console.info('Encrypt address.'); - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - return false; - } - - let addressString = Blockchain.Wallet.addresses[addressId].address; - let newPassword = await InterfaceBlockchainAddressHelper.askForPassword("Please enter a password(12 words separated by space):"); - let response = await Blockchain.Wallet.encryptAddress(addressString, newPassword); - - if (response === true) - console.info("Address was encrypted:", addressString); - else - console.error("Address couldn't be encrypted:", addressString); - - return response.result; - } - - async setMiningAddress() { - - console.info('Set mining address.'); - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - return false; - } - - Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[addressId].address; - - return true; - } - - async startMining(instantly) { - - - await this._callCallbackBlockchainSync(undefined, () => Blockchain.MinerPoolManagement.minerPoolSettings.setMinerPoolActivated(false), async () => { - - if (instantly) - await Blockchain.startMiningInstantly(); - else - Blockchain.startMiningNextTimeSynchronized = true; - - }, undefined, undefined); - - } - - async startMiningInsidePool() { - - Log.info('Mining inside a POOL', Log.LOG_TYPE.POOLS); - - consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; - - await this._callCallbackBlockchainSync(undefined, async () => { - - try { - - let getNewLink = true; - - if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '') { - - Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); - let response = await AdvancedMessages.confirm('Do you want to continue mining in the same pool: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolURL); - - if (response === true) getNewLink = false; - 7 - } - - let miningPoolLink = undefined; - - if (getNewLink) { - - miningPoolLink = await AdvancedMessages.input('Enter the new mining pool link: '); - Log.info('Your new MiningPool is : ' + miningPoolLink, Log.LOG_TYPE.info); - - } - - StatusEvents.on("miner-pool/connection-established", (data) => { - if (data.connected) - Blockchain.Mining.startMining(); - else - Blockchain.Mining.stopMining(); - }); - - Blockchain.MinerPoolManagement.startMinerPool(miningPoolLink, true); - - } catch (exception) { - - Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); - - } - - }, undefined, undefined, false); - - } - - async createMiningPool() { - - Log.info('Create Mining Pool', Log.LOG_TYPE.info); - - await this._callCallbackBlockchainSync(async () => { - - try { - - await Blockchain.PoolManagement.setPoolStarted(false); - - let getNewLink = true; - - Log.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.', Log.LOG_TYPE.info); - - if (typeof Blockchain.PoolManagement.poolSettings.poolURL === "string" && Blockchain.PoolManagement.poolSettings.poolURL !== '') { - - console.info('You have some settings for a pool: ', Blockchain.PoolManagement.poolSettings.poolName, " ", Blockchain.PoolManagement.poolSettings.poolWebsite); - let response = await AdvancedMessages.confirm('Do you want to continue using the settings for : ' + Blockchain.PoolManagement.poolSettings.poolURL); - - if (response === true) getNewLink = false; - } - - if (getNewLink) { - - let poolFee, poolReferralFee, poolName, poolWebsite, poolServers; - - - poolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); - - if (isNaN(poolFee) || poolFee < 0 || 100 < poolFee) { - Log.error("You have entered an invalid number: " + poolFee, Log.LOG_TYPE.POOLS); - return false; - } else - Log.info("Your fee is " + poolFee, Log.LOG_TYPE.POOLS); - - poolName = await AdvancedMessages.input('Pool Name: '); - poolWebsite = await AdvancedMessages.input('Pool Website: '); - - poolReferralFee = await AdvancedMessages.readNumber("Choose a Referral fee (0...100): ", true); - if (isNaN(poolReferralFee) || poolReferralFee < 0 || 100 < poolReferralFee) { - Log.error("You have entered an invalid number:" + poolReferralFee, Log.LOG_TYPE.POOLS); - return false; - } else - Log.warn("Your Referral fee is: " + poolReferralFee, Log.LOG_TYPE.POOLS); - - let response = await AdvancedMessages.confirm('Do you want to use external pool servers?: '); - - if (response) - poolServers = await AdvancedMessages.input('Pool Servers (separated by comma): '); - else - poolServers = await NodeServer.getServerHTTPAddress(true); - - console.info("Pool Servers:", poolServers); - - if (response) { - await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(true); - } else { - await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(false); - await Blockchain.PoolManagement.poolSettings.setPoolUseSignatures(false); - } - - - if (poolFee) await Blockchain.PoolManagement.poolSettings.setPoolFee(poolFee / 100); - if (poolName) await Blockchain.PoolManagement.poolSettings.setPoolName(poolName); - if (poolWebsite) await Blockchain.PoolManagement.poolSettings.setPoolWebsite(poolWebsite); - if (poolServers) await Blockchain.PoolManagement.poolSettings.setPoolServers(poolServers); - if (poolReferralFee) await Blockchain.PoolManagement.poolSettings.setPoolReferralFee(poolReferralFee / 100); - - } - - } catch (exception) { - - Log.error("Error starting your pool", Log.LOG_TYPE.POOLS, exception); - - } - - }, async () => { - - await Blockchain.PoolManagement.startPool(true); - - }, undefined, undefined, true); - - } - - async createServerForMiningPool() { - - await this._callCallbackBlockchainSync(async () => { - - console.info('Create Server Pool'); - console.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.'); - - let serverPoolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); - - if (isNaN(serverPoolFee) || serverPoolFee < 0 || 100 < serverPoolFee) { - console.log("You have entered an invalid number:", serverPoolFee); - return false; - } else - console.log("your fee is", serverPoolFee); - - await Blockchain.ServerPoolManagement.serverPoolSettings.setServerPoolFee(serverPoolFee / 100); - - }, - async () => { - - await Blockchain.ServerPoolManagement.startServerPool(); - - }, undefined, undefined, true, - ); - - - } - - async _callCallbackBlockchainSync(callbackBeforeBlockchainLoaded, callbackBeforeServerInitialization, callbackAfterServerInitialization, afterSynchronizationCallback, synchronize = true) { - - if (!Blockchain._blockchainInitiated) { - - await Blockchain.createBlockchain("full-node", callbackBeforeBlockchainLoaded, async () => { - - if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); - - await Node.NodeServer.startServer(); - - await Node.NodeClientsService.startService(); - - if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); - - }, afterSynchronizationCallback, synchronize); - - } else { - - if (callbackBeforeBlockchainLoaded) await callbackBeforeBlockchainLoaded(); - - if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); - - if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); - - if (afterSynchronizationCallback) await afterSynchronizationCallback(); - - } - - } - - - disableForksImmutability() { - - consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH += 10000; - - setTimeout(() => { - - consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH -= 10000; - - }, 10 * 60 * 1000); - - } - - disconnectFromAllConnectedNodes() { - - let NodesList = require('node/lists/Nodes-List').default; - NodesList.disconnectAllNodes(CONNECTION_TYPE.CONNECTION_CLIENT_SOCKET); - - } - - disconnectAllMinersNodes() { - - let NodesList = require('node/lists/Nodes-List').default; - NodesList.disconnectAllNodesByConsensusType(NODES_CONSENSUS_TYPE.NODE_CONSENSUS_MINER_POOL); - - } - - async setIntervalDisconnectAllMinersNodes() { - - let intervalTime = await AdvancedMessages.readNumber('Enter the interval time: \n 0 - disable interval \n x - minutes'); - - if (this._intervalDisconnectingMiners) - clearTimeout(this._intervalDisconnectingMiners); - - if (intervalTime > 0) { - - this._intervalDisconnectingMiners = setInterval(() => { - this.disconnectAllMinersNodes(); - }, intervalTime * 60 * 1000); - - } - - } - } -const commands = [ - '1. List addresses', - '2. Create new address', - '3. Delete address', - '4. Import address', - '5. Export address', - '6. Encrypt address', - '7. Set mining address', - '8. Solo: Start Mining', - '9. Solo: Start Mining Instantly Even Unsynchronized', - '10. Mining Pool: Start Mining', - '11. Mining Pool: Create a New Pool', - '11-1. Mining Pool: Process Remaining Payment', - '12. Server for Mining Pool: Create a new Server for Mining Pool (Optional and Advanced)', - '13. Create Offline Transaction', - '20. HTTPS Express Start', - '21. Disable Node Immutability', - '22. Disconnect from all consensus nodes', - '23. Disconnect all miner nodes', - '24. Set Interval to disconnect all miner nodes', - '30. Set Password for Mining Address', - '53. Add address to banlist', - '54. Load address banlist', - '55. Save address banlist', -]; - - const lineSeparator = "\n|_______|____________________________________________|_________________|"; From 046806ff26ea5485313cccbb0c4bd01451e042a8 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Sun, 28 Feb 2021 16:07:26 -0700 Subject: [PATCH 045/132] Adding .nvmrc with the version of node in the build script --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..e51c059b1 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v8.2.1 From 522bd6ba3c45638bad4f27a0b5cc5ac22a377103 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Sun, 28 Feb 2021 20:39:57 -0700 Subject: [PATCH 046/132] Separate out the CLI into core, interactive, and non-interactive. - Start allowing some commands to be issued non-interactively, from the compiled command line interface. - Some commands will not be allowed to be used interactively at this time due to complexity / additional refactoring required to use them. --- README.md | 27 +- dist_bundle/CPU/argon2-bench2 | Bin 18832 -> 52160 bytes src/build_terminal.js | 12 +- src/node/menu/CLI-Core.js | 764 ++++++++++++++++++++++ src/node/menu/CLI-Menu-non-interactive.js | 164 +++++ src/node/menu/CLI-Menu.js | 738 ++------------------- 6 files changed, 1004 insertions(+), 701 deletions(-) create mode 100644 src/node/menu/CLI-Core.js create mode 100644 src/node/menu/CLI-Menu-non-interactive.js diff --git a/README.md b/README.md index a158c875a..225ac83e6 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,32 @@ If you are under a **router/firewall**, you need to port forward the port used b npm run commands ``` -#### 5.2 Running Full Node +#### 5.2 Run terminal non-interactive menu + +After building the terminal project + +```shell +npm run build_terminal_menu +npm run build_terminal_worker +``` + +it is possible to run the terminal project as a non-interactive script: + +```shell +node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js -- --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here +``` + +the first part of the command (`node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js`) launches the terminal project. + +The next portion of the command (`--`) starts it in non-interactive mode. +Without `--`, the terminal menu defaults to interactive. + +The next parts are the commands to run in order. + +Mining should be the last command used, as mining stops processing additional arguments since it starts the mining process. +This is useful for programmatically executing a mining task (such as in a container). + +#### 5.3 Running Full Node Install pm2. ```shell diff --git a/dist_bundle/CPU/argon2-bench2 b/dist_bundle/CPU/argon2-bench2 index ff284fddf505ff80e940838ba1e1dd470dc5e560..9810fefabfaef54ea6642954c7ab009b85bbfda3 100755 GIT binary patch literal 52160 zcmeHQeSB2Kxt~6@GWH;SCONfF7 zl0#VIYP{DE^wvsyZ!4|Z8@&>#T37^0w5?$6wOG8Z6pNc;3$?AaevtdTGjo#7+Wz|A z?LTvV&dmEh@5jtMXXc#QC5eYV`Q4eb7;}tZjOCzAK&cqXn8jR>7@LY>pm@DC`n8^0 zJU1>Obok{MuKrDp^2|mDUhgu`ieA6Ghq_k$LUT@5d*Tx2+?0h$siG1IZ9=2`=jFS0=#z*=PP`9ZUl^Z15{?Z`I6I%KT#T3oo6d(XFG*|H1l*G&V-UcE;@a=5H4H4xjI`U54c&{xh$k=SOwb;_E$?RpM?kmU8iXHF!T$ zA}Tdjw3H_^7slVp*Esw}!8QtQ1zP(uQjl`+ta_QT(+Gsf=-yTwV2qaV$9;_T0i^Wy zTD1EhKBuE(@(Oj>m5=z+VTe%1qj8~(Lzy3sMdvq!YUc-98UoPiqBTV0csE}2FVElP zzOG|o?^AEz@M75lU@jCI10R)RESLGc9_7oq1SqXz`4%MjEQ67|KJb?L3aF#^JGxJocR6 zx3nc@1{*J1I26U$MTntsmVoC`Xy-_scvqKVKrx^gPz)#r6a$I@#eiZ!F`yVw3@8Q^ z1BwB~fMP%~pcqgLC&No9lSE=LfQ^i;G~O0z!16pVrWM(OIq z&2LpF3l6PT%JaoUdbr_!om1Io+IMlMoaO}%J{ZVU2(*hZ$Y4uJZBBkfCC8?tmYm>@+jNc5-ZaY7lssfX$my=PnIvy05x((_y1*+DErAfR_QR zE-U{lS7t!jOFzA^$Qm$L7rlxOn(Fh>Px0I6XYl@LJ-K7tx#Q!d#=yR+(nIl6CyUT! zdIImhyk{+_TnZV(?SF#O!}jM%jOlv@aP>a`sAxdHJ9n0m%$tC`Zii+)fnN2yD`z>} zIf%GtEY%HIp(j&6qBe*^=dwJ{m! z!IfkzUQ&l`lK3QD1bdyXMRI59+U)9C`9{)t1w6DlMt+@k7k25il#Yi}e0q1;J4mxL$ord}Vx0jdF zP~U>A@4ve0Mq^%RbQVvBtI>JRS-i>1rzTlG59<;;=XOL?CQch|2d1pjZ`D`p zx9Q&1`|T}1?0HnPd#3|^{2o74Y0NpW!sv7+`2z*R!ZRi5={6Ep$(d6Fy;cQk7kbAG zj}egxYX!&Gpr#+mG%#X)g&c=8*FhmnXp?Zv=yMSn|_=~0^2x1lSFRv=pvxk z+HObpT05lJYwfhbq_txJZVAf(Qk|SPIzW6{hoKdvARK{kaz^IU4$mv%cMC?mm%2`O zK_cX<#6ah?y*E+gOi^PUHQzL>l=*sfXTjqDs!9*UUN(}>KSHkVEIH$hLRjQ@AGg1i zL&YI#N_SDWT6-&>$S-!&W5Ss6vU#?V{2?E1vUnwKWBPUcP*U>h+=J~-LRsSNwtdcn z?Ri|m+IR)I>a>WXPMcjtYtCwdSDiK|*~;7XDZ(nae3w;&HeuDEUnB7tO}{$9M?o`t z2>oD{Ywcq(kk<02mt$P!B&?RXSSHnp6Ikw8GuMz;>1SHoE2D`4&SBCRVI-2>NS8En zAnoRo15yf7f*9`OeH|a7xULJq6teB>d|uEfY}-phOB^xwrSpwWo?)Aqt---504bXU zJBycLprEV-Sh_(IuaocNhvT#!K5eaMQFlq7IiaLa+cFhDlcsfCPW5!M>!1VnXJE4) z!)*q%P(aTT^pJqA7SMkabf17K1@s(2+XUnh&@O^D3+NgF^$>KsfUXtL^902NWC&rQR{d}7`!mJJ%`qRwcjFu&QGx4s%>5Q`M|(Q6LO8Vbq&e&kSn#VYe~Kp za*4JzOmYq6x!Tq^$(4{@+SZLEmq4DRZEYiYZb@HkhW)%RN>wF(S)KSJj&aqcpK4n^ z!#3%E4?jAoZ4JS>3lAAjH=Z(!GM*@NlJrEuMChTT^(5&zLv!a_tjGGAKxv!V)1St- zU@6r-R#ez&&)N3R`GVyewa1DHJ8eM9+AN|>fzlqdqk4JNaj|UU!cH5~w$p)3>)0>s z>xG?mr)}@x_Wuy}W?`qTO1(}Jy>1XF?N&SL1|HQYqFRKVwyte2;`T+te!H;K?xn2n z3G@zu(zYe^m_RoQl=iEg>oPfMw=!JoMNOzQ?zA2(M3zRmp9kr52#YNN>VW+)p+e^89xv;khJ8fs%K9$>xg}q(a zX-8A9&7xOJptPw8<@cw@+A2`m*MvSSd^-e6TbodRuY0U*0;Sze=<~uiAyC@jg!T&b zZh_Js#~5iRwrCxEqxM*x!bY1Nwvn){Zr+5odyl|r$5SS`c9H_6O)tIYH!p$ry#lBG zF7b1luLOP{0JlZEef`Lj7hyY|&$l7o&S|{Q26tmL+J6fTb?XzK4FElrK8~MI#w(Lf z5Js7E>SD&?7vMZn2*DV@3)eXrQnw>vy$28M>yvrCT*SkKElQlB6yKo~qMuG~8|+PM z`yK90drE6x@i9KSybA?W+)|5kfwuJyjG(^-B0)O^7`gq0lfy1yykGP z@py>zS4gkP9GXDTJPB>&f!itYei<0z&@O`Rl+gd4q4bwg;GZB;`qwyg13||mRLBEQ zP@qQ!P8)(2NNCIuG+jb>@?3XNt_NkV_dcN>-=tiBg-AWF;9l#uKpVj(c5CUKdKQDEE4lygH=U3D~u*W#siaDjGyJ_v#=opY%#` zuS?16=hEvU?q!l!ne=*;do3ZaXHXTTsuRcc#KG3`7p}+ZFlQQ_c}E~scRG)u!2xhF zR?6T3klu&1e0*rnp7+V2~q zEtO-mee5!qX+7gcYCR7)`P<_Sb7XX3$s5h*YCY8>9R%~&#~bFM=%poZtbY}+A$gpg z%^y`b>Mo{p???=T_6*kk0`${b{=s!Ln=3J!G0-uav(aES-T1|m!Pzv^`)yD0Vfe!I zGE6w*)&lgjf26g487rTUyikND;Fj@yz_^h{;x%L6Z*#StN$zbAcuu4HwqqKmQ@ZUQ z&mU+o*o&BA{LO<_A@(>%brX$BYrlu;JLoMIA5}bah-L?;M-f}5p zSQQvnwAaVcl{%Zz#E;`slV<%pR{hB% z7{J>Y8WO#S_bnXf@h2QJ$~=eTlW-F@AD~a58J|qB{tnRapYWL2=&BixmeFJ?7&(AzXI4KP!*QQsn%Cb#A z(~@*X)dza7@7#D|RC+YRw>jGl4#D21CEv%a7x~{`(m59&m`DqVtDfhB&0F($x#`T}76SKwhR`Z}IDQ5S5+c6{2L&J#HL$H5OI zzD0q47`2|_jn`5a<&+C|k+PxxQv`Mv0^ca`ksL4YSeDQ5&E{liRw_Ob_FV$W<%oGH zko}aL{9i<81N}PPAABu?#Z+_@J-h_He=e%la)w@*xe=f2pI_sm?;R^n;We2o_ag(o zjHKWHDLQ)c^5OTB7VA!g^RNEW-H>qd)q0%IU4ymX_R1)ubbo9PZUue)_+inj=@sz6 z4eLwvrs>csm-;vmLx1(cI7fLuSHYgzj8-wq7m>sqs5cz=7xV328p`spl7j~7ny zeoX0cOesALhP{2{QUIy7d@hE8hjGzSOy`)_#k#6Guli;BCjiAT^I*piqiGRz8iv;L zzj)BZuSU*`mg4K0XUIEQehbOphFo+MAEAeT+XM4cSY!R)#V&;WJjstiE*eNTBBE=c z;6E!F8z}e=uXpnLd%S*%*Wc%LH?N=N^>e)L;q`7_zrgF4c)f?$DPF(K>jS(#$m>2{ zzsBny^ZIpOALjK>dHpk9zs2h#sH>CHj-k<)4it>e#faFGTy+YCkl7323 zn51JQ1xPwY(k&!?PErj?V{w1`uOVqBNmr3XN9O(oBrPUsHc1U6T|iO?Ns~zW7D;1B zqGj99Ncu5JAK{+WA0_Dnl0G2m*O1WbuxnNYS1ayATX;1Jt(c69FuDpo(OOo}5N8GT z^>IeOaq7C!qgT$DF~bFPu#90#eP$$9AM%D`-fKePaIl3nMI-)TEQa6A&2aNXqmigf z=fAfX$aL`(6%{S6^i&S|hQc8;G0=G3W|5 z_?lwDfGZSs#oVrfI^f29TWV%^xMrFyO~ILN*UZ?=xvrV@zF0je1zZb9!hW*R^vNj2 zO_^b}6jmFInZ~eCLKgqM@KuAq#kktV=GC!C+-!=QtT7}goLA?NRAgJF}+3$S^$ zLzc!2i+>3A55fLOG#GOg5COG5(_b&dF@9h8V$Vyjt=e&f=r z#n-wR?$ml$voGf2Mz)MQ#a#99tPKXkE;ATy422ONaIrBiVU`&Ku2|epE1)ipy9jGz z9KY!f(nBWVW3D=1s392Ozax4+Uu%qIws_z(`d#-c&{Cn_Q>Tk$Je~0SojGh0|2~*G zT+rWG;lyI+>CmW4F`yVw3@8Q^1BwB~fMP%~pcqgLCbqVlI=m+9+vGdWc!|Me=pmQWt)Tl$v6E$gK@I` zdz=;)Ex7!O;xAuWQmQY!y3%t^E(NJeF`yVw3@8Q^1BwB~fMP%~pcqgLCO*LrJ1VSubljz1>wKXG!t*5__4`bUB5cYa*3@ESE?_>tKNyRV$LtBvqH81J1zx|ofsn!>Bo=H4 z`b}@Bv5EIkLXl=9L|zq;{S6U6@5X>q2Q3yPQw?dsNFB*5NRBiG`N-Fh(i9DaO>V0v zHRkt)xz+@&G1%yDYN5Cd(1tu)9i*D|(V#EjMSwrZ$Fpr145P{W@5+RO8$u=}+@1+G z#?9acZy*>mqY>WSjxSn6VG+3Viza*8-Cs1t!?tlZH^xoQa*7o6=5NG3XR$u1Vhu#- zj>irY5RWwkgJc(%!^@m(thce=8{81|W5nKiOdl&`U0tXl=-Cj8A$No*sq~pXX4VG7 z{`y8=bRBDH^kJ#o>5E2Ln`5n)B^)OEG$#jIw3?&tM(?o$&Du4m8Zuph#@gX24S-OcOW z+y{5tz^K@-b9|=1o;@&v{0ZV;=X;{x1}k_wvE6fe+|Q7Zg`j1+uEq> zE?%d2oo>rm!&`9pn1iXu7UJ%vc5NB_YZ*JL zTwSBPr?K6jWBh2w-fb0se}it0=E&!3f}AIl4*Tg=VW($}21Csp`FBT1AH&$1%|c%w z?K@@({a>Vgo3vjm^)9I|m3oEL1EixrCiOuSHq9H%pIZ z>6^0j&Mf_rEd858M=h?Wv-Evg{=HfH>sk6+S^7I!`tdCNgDm||S^8&LdM=m&G|11S zEPYm%z937l%F0iszJF@g-mi}Ot{&<%DM3z1sG`mnPM8T3^1t=GxT#Pas1>2Tg zf^sR!T$Fhzm!Zr@DMTqkp*?&#$`vTZC|^do5(P_;m7=&&%1~yY%tXPT@L~U-{h~X} z(fc>vRXAHjnRn>b~0_ zvyXG)ASaJ-gNHZ!*k&Kt?4w%t8Er@xhqFPQpUMWc;m5Hon4iP4Fu|~WAQa*92t__@y$ZJVquASkR(C-qqEf8Z+}}HAX7}vLu1}wP zpXdI?N{muKnGxN@znK`rP%{QyO3$sinCPNmxnh~{qf{R1iow37iP717yjbbi# zF`LRp0I}e5@f?b^l#I^`)iTZzd}hSixXQ9Lpe)P96EdEv!6-osvW65>dCA}sNiBY< zP$Ol`n8E>)qq+_ha}seaPsrFt6{29XX|a%_>XF=8A$L~D$(V`y%UHIL+D2E6$gjzA zfg;*P5%chSGA3RMOa2yWr1Z8+IEmQB6Ed#RU?yWJcRl2&p8sl)tz0U~%VZZt)L+JA zM+!4rn(ODxn%UA=+|t|@-dMb`Y)OqELpb9M_e&uEKRSt_8SUxF|e*>F(V-V=W~mDl^kjAL)9 zdn=Fr*V_-T8&&z*s|S}JD?i;cb?m$!j2``>>5DNFjz4_c=kq?>)Nq`zx>AG(|xcRXUr!3!j)P2vJ-&isAxwpT&`M)Q8yzB9=zuoV3UAm;S{^$pl zJ2zV&nDK+nBX&Q$xw7g{?_cxF?$P#F@)uor`OiLirTD?kKRz=5@!#}*l&95j_TnAj(>CpJOr6^{L?b%G9c0}MHdDsm8@hp#RpXlQBWHI6H<>gx0tZ5p~ zGjaQ)D7SxhEr;a%{5sb^g$;=MlnQ|xg#LcT#Sy>23xL~DpMFsv0kg$i|73R9P*0!G z&kXIggI`Ib=Ps^i3d=X}Kh4{f$4W%Iz{bO5B*+e16&I&z98hrL~+- z+M!9{B?kVt1U?|_#&Wct86j}hpr=#Rb8wuC>wgq{6#51K5}_Y#Jj@ihVkr09V6b7F z3>xhG3it^hnBO5ZXwgCN)3~Y?dWuBu0@oY3(Vbk;rHH=|huM4bcZ!4v>+{t{^HH&u& z)GVrOX>aq_)YZ56na{VTwY|+34AlifJ|FX4yWY1{@Kv_d1%v*eCZ1MUE5z3j+Q>vQ z=x^~ignZ4d9W7Lgj?mhGzpjz0QNje_YYm6|8-2}f%^?HS(%!Hx0X0A{AP`Hir zKyw4>oP+8ILmdqrn|uvx*MaB=G`EGCIMLMJ;csId;Sd@?&1+aku&=4ExrH@wEx}MA z)ZW6H{OwI(Y0}C1e9gi3hVpV>Q?Q|~t%kZOrFytP9m4qdpkaa5i&od#itDU5kI?%p3jnp7xfOy1-1$c2Yq@FzjoB zbr@Chx^M_hV4+PNezpd1i@&X|)h|#Yt2UxfgUD-W51_Bs`0D+^kXjd9i)4uRDiRyo z1M8aG)-dV|k5(nBnW$4zW^sF41BOKPb;xOKZu5nM{ziy5`s>4M^wr~ix5kIctO-#; zjm=F>%?;s}&?Z*zZ);fFS{GOccrB{o57xAY>RLd_%E(5rP;(=OO+aQX3Ha9|4N$AF zKM-85mG5sOtiCSPK!tT|Xk^!Tt1BvfrH(5cvl3}%GMP-3I%X#r=F;{fuhro&d?Iw{aQ)_cqYk$wxEYJ+aM>4>-L1pN>G-$m z@bNl)n+~UUE*ZA#@be{z_)#4`Nr&&$;rTlJ867@ZhpV0M=cqlF?_aDibxVK95(}dD z)y@}k_UV|A9GZP6ScVF_aJOFULW=0M#1tPGLMXhAXc{{4!<-HfO^;%{pVPMzO+zTY zlhgG?)6j`;=k(1)(~ya8<@8dbX{f{_oW7Q58Y1xyPFE03LnB_x>3KxckccngbScp^ z6yh#UPbZolg?I_43y7v65mz`pg=iWIaT}+{6HP-P&N!V*G_cdM`cbYENil&Yl6x3eT28sB@o5jn1B=ppZX9^|M%) z*g@8g73zR%1Z#>e$p(kJ{H<@^zvmQ{KM_pUT@z=bR()Rr*h2%r*&o{tTiLpSAZ%s>+MbGtbgHh#EZ=Q~yZ?hIj7igreBZpib`T zo1m-RNGNdj)97Eh%6*G_)xOAQjbR5_%(^8TeGaSL{<7M$d14N<($GT5u{)us+cE=% z@_`WftUlbXi5!7CZs_lU)hPCLh^gDusO9)HNIpVUzt}@;7d}A7d>zJAqkoNc5gQ&% zn+hwu{sjntPhgnuX@t_)Q`CsxM?Pz?ZfSrDtz0q;RduehOp@=m+&L8m&IV6kQ9-h2 zMnjXcKR!hGRXY4*$N+y2_?{)eV+8=7p>B@<0hsmTE+k>-52~X_R;$tDYUewHOKPeQ z_S2h?dT=kjps5EB()&hiE<`_R;_ZCq@0gI5tHpze)XuYcYV>dGFQCmapN7V*+Cv#b z17Ozlui8hmPLo5@eU!gkz2if!VDFb^C{Uw=>fYD_)pS5T@?~gZLfdGm&3Z9gwNEQQ zGXKd76fB$LmP0VshR$7e!16F4)5pA|J%czvR67^2u;t|UAeT_~5eW<(UKPI$GRgY5 zZ*<>4&+PJLcnI%!f1An18r7cc!Xj!>w9DQNz}fHZecry4klrqP1U5YAv6rD1Fp$T- z!~=sNUO{t+H@ewgLTD`rLitQfK!*S}ikM!s*+HlynpAe#$zlTS)<6`{WtVdcrMD3` z0+QQ#f+z1m@;qE>)MIyP52@#KdXS4BpQ4~+KCpJZfFfwU;B>#W>(`tf%jxn%YSe4D zS?~HWf#$I}m?6O%1#iUCgS$yB-$%NOh%ZNtj$IAV+C>$Mo`|;C?dq0SL*rE#iHy@n z@3gTi{y`P6+=8y@+@DQ#r&hxDLzK?ZrRk_i;`t&Cr7D^KFtw`3auKu;`G!VL66AnJ z+5{N`skQ#y&rnR~W_u25X~$X=nO`|sVVDi>GLybr(1`L|(BjSwShzsiy*(kj&C|Qi z?CEXD>Ro3_j9+hbaAEhaXHdI(W-ovejMN;p7rk83t&Ih60JC*>aVCw*@9vsPBC+|X z2+ftRqF=qe_i-CI`!O!v)?Kqky31x|g|Y)`HKWd%z!=|Kmvt^-%{JmQ)kFjTkO(wA&)ZLtrrB zX*3n?MoN>i#0gCF7wSDBt86R1zK3!GHtXFtLtCQe$0GCRX@%@Z9U`BbLiWh~$28=8 zAg(SvDr1pQJLflZxN8V?wE)Vk$y>VZ36ps7_`p53e6zI`;Pu`$9^ z2rV~AE#BxyYV^;sIlS~Yyyb(|J6B=x;ZK0K2ZO-*f%B+*km4`WB8#zO^Y)B=ZX#CS zHws)B7M49ot38;iucAevq~xGvb@pRbE&+jr3Ch@?y0~8X(`r{Sp6;2wPZe$mmwM71hLcBTlT8- zSW<}a{-}2DjjzRX#Jh7AESjb}7hoGrgXJ>BT6YdYUUuh`6Hp7;ojIx9X`zPBplPDd z@*D6qS&I%+0e$yMYn;YFEL*X;AJYaYf_5_68}$7O&BBhp^Zhd2-T=!X zM$kiGReLc6vCqSk+4mG!0q;1i!TA{61kt1P9m0An)6at)%RN|qx?V>C{Nds=Vr(nv z!m5?e!snk{ug$}>PUWk;m8SK6HHvqH8vB^O-)IU^%+*lY2VT0@UW6xe41Y2`(E;n0pJSw9<6I^-&Rd_OgG~4C2<|7xV4YI2 zRjw}oOXx;p(fdA17Hy6d@?zc57eX(e?4lhX8tNRcH8kJ4WfIv}tI_Wv7Z1`}!S|ET z(!sAZ5n9xO>}To61Rb^l7!|MRjOiilj?H#u(sDD_jF(_Zyf~p74qA4gT<9NiKTq=# zfQJNty-_4L4}TU6~+&KwW9eEsg`VQ)~a6Iq~Lft z-0E)&u>{td25U%Sxe7mRN9CJC3J!4ga4rtRFAFK!$-JT+?JM(E76wotX2S~g+S^Psb6mDB0eOeRcAWi{70BMtkETtO>L?K7^%d1>&=aI}jJ) zSvib&8{&LyawtsDB4)a6DKl-fnJySJGH0u4q>b>YxVGX!lfQitYkGd|jF3_FaK>bS*|Bht~am5e5=V&Fx6VKffw>ipx;kG(hgM# zJE&v_mF%!6&lN~#0^T3@LC;3$5nW2!&V_RpIA?)#7C2{ta~3#ffpZo}SfFE~i>H@} zSZ2_cje;@0TZ0q$F+t1Urhg~|#t2+~KO}$amfzn^7Wwk~>I(#ogFYUnh&YCyLnzQ* zl7h_t^vj`kqPJzaD8d&ETCnB1cmhW?Je)PVcr1ULpKR7}ZMVl*zDBZ%B9@V0!-oa6 z9Flvfv!Z=+-;0wh9wv#nHqXUV5-$<7tapjvqkTICSw3Eld3$z_b#WZ;|D2ZPV%yE> z=^~#q{Xg6i-?1CYy5HvF$Ri@&CE^1jeoe&hiujC(M~u_t&KL2eBAz4Sg(AK|#7!bz zFXFpIe7}ev5%De&9}w|tA~sZ;nX*%n5@+cZvu4kkTUPF_sPt4Vyr!~po>H{DKHL@x zE3+N59M0m>FsGciJLfn`W_?XVmC_RDoRadAS*hyMQf53YWm&Fad1jmq)TG7DER+_{ zPK6kaYN@#CKA988giWCF%Hwe^*R$W_-`doay-GY)V{OplK_c zeMG+or39L%O_=?R^{4qc3-&)e!Ii>KnhCcV)(eNgjq3=#+nZ3&98pg(eX?a7A8yav zgdVvrf#l&X+)ZivWe4zd?fNBfs%QU&E~FUaX90*a*`bf;jc11nT}UOvOGu`(4{@X` z_YE$3-mq~J=XxfyLx%o6!|~zcMC+*G<8VAT;PCNW2;7A4#_6*JeV`xnOlii|HNffn zVdHn>H*#FBK}*x;S;}yjJ%|M=-S_JBo%Z-N{B&NQ?tAQ~GVsgqw~gORza;d~7d;e; z_?@vM8T7m(_y+`kso?(_^w9y} z)bEP0zuXVKmO;;n4ER5}p5#0)m-8{$u%)x}qzt$dIQ8RU@w~w7Jd|hPU&(RICyI;n z@iRK4)^R;kSc#!sD^am@{so(i^}PumxO+!pUCSO_)iG_?V`O3XbK-9R(LA)mIb>} zztFb`6m0yC?}<4++&^f%z>R(ulYpli52e5rp;I4ug`Op%ALV$sS>W_D9|bvXYcuFy zFZhlAM7L+)_j9`q-!DBZ^cekX{xgG~7c$^)2t9J2AnVT>0{DbK+|=Y~z}NTJRxb5< ztC!WlOC#ya;S06;;FZwkCohM_cHf$o_WHUOUt_2}5cJiBH{#bJxMKK2{zk{#*=1$v znYg=w51-=KZSvuFq5wP{0`M~MHHKSTH$g;4akq^WR{p_%DQYO43mhGAC4sw#&$n=? zdr_4SKi!aH39r9Q)2}@VEsa#GU_0Ce+8W6t#dFhQ_oC`bpgK0qd%)*|uc@y}6{=Ow zQgFeaMHX_6_qqzV*LU5*h0CgHd^PS0Zxt2I9WxSs719qy`yI>WlFkI=EAZ8>GAUjm zNx`{#R}JzwNoJ8w?!3W0PBcdkpWaDkm{W&v8cE~Z!M#>eRcjt8saVpT11(Q=d`U9S zf+NLOxrZ2BS(1X>NIsqS2)WM~vr}A(lJ(KtOEkBeR1wX=CW*n9!{CJ?Oh>LpdY_-9 z2)TktR~6aAdZ(czr`CkTn4m!h$^VTri{7(G^Z3zuASDabs+RD3;hss!Ts}nL^^(r@ zDy@4=imy^q50%1)Z(3KabUroGbt$QX>LNXDQjJJfGV+lpPAV6T@>DL(ODYx99H>$; z<_Kf%t{8bPgT3p?t=&2V9d1sz1ukG{;& zxTy{Lv^W&da@ND6sJXo@h43LSfFJ8gK%_caLd?Mjg#$^)ns$(ISi_xrWjO-v+^fss zUn?fYwT)0BDNR(H+cXK8zO?~tD5kEpxdC-(50QEx zS{t!l;X$5jlnFqd(}`@(E7KHTf{V_^q`W-;kpBlkL7qNf`AP{+P`= { + console.error(`Caught exception: ${err}`); }); // light-node -Blockchain.createBlockchain('full-node', ()=>{}, async ()=>{ +Blockchain.createBlockchain('full-node', () => {}, async () => { await Node.NodeExpress.startExpress(); @@ -22,14 +22,10 @@ Blockchain.createBlockchain('full-node', ()=>{}, async ()=>{ Node.NodeClientsService.startService(); Node.NodeServer.startServer(); - - -}, ()=>{ +}, () => { }); process.on('SIGINT', async () => { - await termination(Blockchain); - }); diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js new file mode 100644 index 000000000..91e18051f --- /dev/null +++ b/src/node/menu/CLI-Core.js @@ -0,0 +1,764 @@ +/* eslint-disable */ +import CONNECTION_TYPE from '../lists/types/Connection-Type'; +import NODES_CONSENSUS_TYPE from '../lists/types/Node-Consensus-Type'; +import consts from 'consts/const_global'; +import { Node } from '../../index.js'; +import AdvancedMessages from './Advanced-Messages'; +import WebDollarCoins from 'common/utils/coins/WebDollar-Coins'; +import InterfaceBlockchainAddressHelper from 'common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper'; +import Blockchain from 'main-blockchain/Blockchain'; +import StatusEvents from 'common/events/Status-Events'; +import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; +import Log from 'common/utils/logging/Log'; +import AddressBanList from 'common/utils/bans/AddressBanList'; + + +const FileSystem = require('fs'); +const readline = require('readline'); + +let NodeExpress, NodeServer; + +if (!process.env.BROWSER) { + NodeExpress = require('node/sockets/node-server/express/Node-Express').default; + NodeServer = require('node/sockets/node-server/sockets/Node-Server').default; +} + + +export class CLICore { + + static get INSTANCE() { + return new CLICore(); + } + + constructor() {} + + signTransaction() { + + console.info('Sign Transaction'); + + return new Promise(async (resolve) => { + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + resolve(false); + return; + } + + let toAddress = await AdvancedMessages.input('Enter the recipient address: '); + let amountToSend = await AdvancedMessages.input('Enter the transaction amount: '); + let nonce = await AdvancedMessages.input('Enter the address current nonce: '); + let timelock = await AdvancedMessages.input('Enter the current block: '); + let addressPath = await AdvancedMessages.input('Enter path for saving the transaction:'); + let wantToPropagate = await AdvancedMessages.input('Do you want to propagate now y/n?:'); + + if (wantToPropagate.toUpperCase().trim() === 'Y' ? true : false) + wantToPropagate = true; + else + wantToPropagate = false; + + let feeToSend = Blockchain.Transactions.wizard.calculateFeeSimple(amountToSend); + + let addressString = Blockchain.Wallet.addresses[addressId].address; + let answer = null; + + //Trick for blocks length and address nonce + Blockchain.blockchain.blocks._length = timelock + 1; + + for (let i = 0; i < Blockchain.Wallet.addresses.length; i++) + if (addressString === Blockchain.Wallet.addresses[i].address) + answer = await Blockchain.Transactions.wizard.validateTransaction(Blockchain.Wallet.addresses[i].address, toAddress, amountToSend * WebDollarCoins.WEBD, feeToSend, undefined, undefined, timelock - 1, nonce, true); + + let data = {}; + + if (answer.result) { + + data.transaction = answer.transaction.serializeTransaction(); + data.signature = answer.signature; + + if (wantToPropagate) + await Blockchain.blockchain.transactions.pendingQueue.includePendingTransaction(answer.transaction, undefined, true); + + } else { + + console.log("Transaction was not created. " + answer.message); + resolve(false); + return; + + } + + FileSystem.writeFile(addressPath + "transaction.tx", JSON.stringify(data), 'utf8', (err) => { + + if (err) { + console.error(err); + resolve(false); + return; + } + + console.log("Transaction successfully exported to ," + addressPath + "transaction.tx"); + + resolve(true); + + }); + + resolve(true); + + }); + + } + + async processRemainingPayment() { + + await this._callCallbackBlockchainSync(undefined, undefined, undefined, async () => { + await Blockchain.PoolManagement.poolRemainingRewards.doPayout(); + }, true); + + } + + async _chooseAddress(id = undefined) { + + await this.listAddresses(); + + let addressId = !!id ? id : await AdvancedMessages.readNumber('Choose the address number: '); + + if (isNaN(addressId) || addressId < 0 || Blockchain.Wallet.addresses.length <= addressId) + return -1; + + return addressId; + } + + async _chooseAddressNonInteractive(pos) { + console.log(`Choosing Address ${pos} from addresses:`) + await this.listAddresses(); + + if (isNaN(pos) || pos < 0 || Blockchain.Wallet.addresses.length <= pos) + return -1; + + return pos; + } + + async AddAddressBanList() { + + let addressWIF = await AdvancedMessages.input('Please input miner address: '); + if (addressWIF.length == 40) { + let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); + if (unencodedAddress) { + let duration = await AdvancedMessages.readNumber('Ban duration (hours): '); + let reason = await AdvancedMessages.input('Please input ban reason: '); + reason = reason.replace(';', '.,'); + AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); + AddressBanList.listBans(); + } + } + + } + + async LoadAddressBanList() { + + try { + + const file = FileSystem.createReadStream('address-ban-list.txt'); + + const rl = readline.createInterface({ + input: file, + crlfDelay: Infinity + }); + + rl.on('error', (err) => { + console.error('Address ban list was not found'); + }); + + file.on('error', (err) => { + console.error('Address ban list was not found'); + }); + + rl.on('line', (line) => { + let triplet = line.split(';'); + if (triplet.length === 3) { + + let duration = parseFloat(triplet[0]); + let addressWIF = triplet[1]; + let reason = triplet[2]; + + if (addressWIF && addressWIF.length == 40) { + let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); + if (unencodedAddress) + AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); + } + } else console.log("Invalid line in address-ban-list.txt", line); + }); + + rl.on('close', () => { + AddressBanList.listBans(); + }); + + } catch (exception) { + console.error("Error loading banlist: ", exception); + } + } + + async SaveAddressBanList() { + AddressBanList.saveBans(); + } + + async listAddresses() { + + + console.warn("INFO: YOU NEED TO BE SYNC TO SEE THE VALUE OF YOUR WALLET!!!"); + console.info('\nWallet addresses:'); + + let miningAddress = Blockchain.blockchain.mining.minerAddress; + if ( !miningAddress ) + miningAddress = 'not specified'; + + console.log(addressHeader); + for (let i = 0; i < Blockchain.Wallet.addresses.length; ++i) { + + let address = Blockchain.Wallet.addresses[i].address; + + let balance = Blockchain.blockchain.accountantTree.getBalance(address, undefined); + + balance = (balance === null) ? 0 : (balance / WebDollarCoins.WEBD); + + if (address === miningAddress) + console.log(((i < 10) ? "| *" : "| *") + i + " | " + address + " | " + balance + lineSeparator); + else + console.log(((i < 10) ? "| " : "| ") + i + " | " + address + " | " + balance + lineSeparator); + + } + + let balance = 0; + if (miningAddress !== 'not specified') { + balance = Blockchain.blockchain.accountantTree.getBalance(miningAddress, undefined); + balance = (balance === null) ? 0 : balance; + + if (Blockchain.MinerPoolManagement && Blockchain.MinerPoolManagement.minerPoolStarted) + balance += Blockchain.MinerPoolManagement.minerPoolReward.total; + + balance /= WebDollarCoins.WEBD; + + + } + console.log("| MINING| " + miningAddress + " | " + balance + lineSeparator); + + return true; + + } + + async createNewAddress() { + + console.info('Create new address.'); + try { + let address = await Blockchain.Wallet.createNewAddress(); + console.info("Address was created: " + address.address); + return true; + } catch (err) { + console.err(err); + return false; + } + + } + + async deleteAddress(id) { + + console.info('Delete address.'); + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + return false; + } + + let response = await Blockchain.Wallet.deleteAddress(Blockchain.Wallet.addresses[addressId].address); + + return response.result; + } + + importAddress(path) { + + console.info('Import address.'); + + return new Promise(async (resolve) => { + path = !!path ? path : AdvancedMessages.input('Enter address path: '); + + FileSystem.readFile(path, 'utf8', async (err, content) => { + + if (err) { + console.error(err); + resolve(false); + return; + } + + try { + + let answer = await Blockchain.Wallet.importAddressFromJSON(JSON.parse(content)); + + if (answer.result === true) { + console.log("Address successfully imported", answer.address); + await Blockchain.Wallet.saveWallet(); + + if (Blockchain.Wallet.addresses.length === 1) Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[0].address; + + resolve(true); + } else { + console.error(answer.message); + resolve(false); + } + + } catch (err) { + console.error(err.message); + resolve(false); + } + }); + }); + + } + + exportAddress(id) { + + console.info('Export address.'); + + return new Promise(async (resolve) => { + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + resolve(false); + return; + } + + let addressPath = await AdvancedMessages.input('Enter path for saving address: '); + + let addressString = Blockchain.Wallet.addresses[addressId].address; + let fileName = "WEBD$" + Blockchain.Wallet.addresses[addressId].unencodedAddress.toString("hex") + ".webd"; + + let answer = await Blockchain.Wallet.exportAddressToJSON(addressString); + + if (answer.result === false) { + console.log("Address was not exported. :(. " + answer.message); + resolve(false); + return; + } + + let jsonAddress = JSON.stringify(answer.data); + + FileSystem.writeFile(addressPath + fileName, jsonAddress, 'utf8', (err) => { + + if (err) { + console.error(err); + resolve(false); + return; + } + + console.log("Address successfully exported", addressString, ' to ', addressPath + fileName); + + resolve(true); + return; + + }); + + resolve(true); + return; + + }); + + } + + async encryptAddress(id) { + + console.info('Encrypt address.'); + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + return false; + } + + let addressString = Blockchain.Wallet.addresses[addressId].address; + let newPassword = await InterfaceBlockchainAddressHelper.askForPassword("Please enter a password(12 words separated by space):"); + let response = await Blockchain.Wallet.encryptAddress(addressString, newPassword); + + if (response === true) + console.info("Address was encrypted:", addressString); + else + console.error("Address couldn't be encrypted:", addressString); + + return response.result; + } + + async setMiningAddress(id) { + + console.info('Set mining address.'); + + let addressId = await this._chooseAddress(id); + + if (addressId < 0) { + console.warn("You must enter a valid number."); + return false; + } + + Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[addressId].address; + + return true; + } + + async startMining(instantly) { + + + await this._callCallbackBlockchainSync(undefined, () => Blockchain.MinerPoolManagement.minerPoolSettings.setMinerPoolActivated(false), async () => { + + if (instantly) + await Blockchain.startMiningInstantly(); + else + Blockchain.startMiningNextTimeSynchronized = true; + + }, undefined, undefined); + + } + + async startMiningInsidePool(url, isInteractive = true) { + + Log.info('Mining inside a POOL', Log.LOG_TYPE.POOLS); + + consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; + + await this._callCallbackBlockchainSync(undefined, async () => { + + try { + + let getNewLink = true; + + if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '' && isInteractive) { + + Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); + let response = await AdvancedMessages.confirm('Do you want to continue mining in the same pool: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolURL); + + if (response === true) getNewLink = false; + } + + let miningPoolLink = undefined; + + if (getNewLink) { + + miningPoolLink = !!url ? url : await AdvancedMessages.input('Enter the new mining pool link: '); + Log.info('Your new MiningPool is : ' + miningPoolLink, Log.LOG_TYPE.info); + + } + + StatusEvents.on("miner-pool/connection-established", (data) => { + if (data.connected) + Blockchain.Mining.startMining(); + else + Blockchain.Mining.stopMining(); + }); + + Blockchain.MinerPoolManagement.startMinerPool(miningPoolLink, true); + + } catch (exception) { + + Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); + + } + + }, undefined, undefined, false); + + } + + async nonInteractiveMineInPool(url) { + Log.info('Mining inside a POOL: ' + url, Log.LOG_TYPE.POOLS); + + consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; + + await this._callCallbackBlockchainSync(undefined, async () => { + + try { + + let getNewLink = !!url; + + if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '') { + + Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); + + if (!getNewLink) { + console.log('A new link was not provided. This will be used.'); + url = Blockchain.MinerPoolManagement.minerPoolSettings.poolURL + } else { + console.log('A new link was provided. It will overwrite the old link.'); + } + } + + StatusEvents.on("miner-pool/connection-established", (data) => { + if (data.connected) + Blockchain.Mining.startMining(); + else + Blockchain.Mining.stopMining(); + }); + + Blockchain.MinerPoolManagement.startMinerPool(url, true); + + } catch (exception) { + + Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); + + } + + }, undefined, undefined, false); + + let mining = true; + + process.on('SIGTERM', () => { + console.log('SIGTERM received. Shutting down.'); + mining = false; + }); + + process.on('SIGINT', () => { + console.log('SIGINT received. Shutting down.'); + mining = false; + }); + + while (mining) { + // still mining, no sigterm received + await new Promise(resolve => setTimeout(resolve, 10000)); + } + } + + async createMiningPool() { + + Log.info('Create Mining Pool', Log.LOG_TYPE.info); + + await this._callCallbackBlockchainSync(async () => { + + try { + + await Blockchain.PoolManagement.setPoolStarted(false); + + let getNewLink = true; + + Log.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.', Log.LOG_TYPE.info); + + if (typeof Blockchain.PoolManagement.poolSettings.poolURL === "string" && Blockchain.PoolManagement.poolSettings.poolURL !== '') { + + console.info('You have some settings for a pool: ', Blockchain.PoolManagement.poolSettings.poolName, " ", Blockchain.PoolManagement.poolSettings.poolWebsite); + let response = await AdvancedMessages.confirm('Do you want to continue using the settings for : ' + Blockchain.PoolManagement.poolSettings.poolURL); + + if (response === true) getNewLink = false; + } + + if (getNewLink) { + + let poolFee, poolReferralFee, poolName, poolWebsite, poolServers; + + + poolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); + + if (isNaN(poolFee) || poolFee < 0 || 100 < poolFee) { + Log.error("You have entered an invalid number: " + poolFee, Log.LOG_TYPE.POOLS); + return false; + } else + Log.info("Your fee is " + poolFee, Log.LOG_TYPE.POOLS); + + poolName = await AdvancedMessages.input('Pool Name: '); + poolWebsite = await AdvancedMessages.input('Pool Website: '); + + poolReferralFee = await AdvancedMessages.readNumber("Choose a Referral fee (0...100): ", true); + if (isNaN(poolReferralFee) || poolReferralFee < 0 || 100 < poolReferralFee) { + Log.error("You have entered an invalid number:" + poolReferralFee, Log.LOG_TYPE.POOLS); + return false; + } else + Log.warn("Your Referral fee is: " + poolReferralFee, Log.LOG_TYPE.POOLS); + + let response = await AdvancedMessages.confirm('Do you want to use external pool servers?: '); + + if (response) + poolServers = await AdvancedMessages.input('Pool Servers (separated by comma): '); + else + poolServers = await NodeServer.getServerHTTPAddress(true); + + console.info("Pool Servers:", poolServers); + + if (response) { + await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(true); + } else { + await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(false); + await Blockchain.PoolManagement.poolSettings.setPoolUseSignatures(false); + } + + + if (poolFee) await Blockchain.PoolManagement.poolSettings.setPoolFee(poolFee / 100); + if (poolName) await Blockchain.PoolManagement.poolSettings.setPoolName(poolName); + if (poolWebsite) await Blockchain.PoolManagement.poolSettings.setPoolWebsite(poolWebsite); + if (poolServers) await Blockchain.PoolManagement.poolSettings.setPoolServers(poolServers); + if (poolReferralFee) await Blockchain.PoolManagement.poolSettings.setPoolReferralFee(poolReferralFee / 100); + + } + + } catch (exception) { + + Log.error("Error starting your pool", Log.LOG_TYPE.POOLS, exception); + + } + + }, async () => { + + await Blockchain.PoolManagement.startPool(true); + + }, undefined, undefined, true); + + } + + async createServerForMiningPool() { + + await this._callCallbackBlockchainSync(async () => { + + console.info('Create Server Pool'); + console.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.'); + + let serverPoolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); + + if (isNaN(serverPoolFee) || serverPoolFee < 0 || 100 < serverPoolFee) { + console.log("You have entered an invalid number:", serverPoolFee); + return false; + } else + console.log("your fee is", serverPoolFee); + + await Blockchain.ServerPoolManagement.serverPoolSettings.setServerPoolFee(serverPoolFee / 100); + + }, + async () => { + + await Blockchain.ServerPoolManagement.startServerPool(); + + }, undefined, undefined, true, + ); + + + } + + async _callCallbackBlockchainSync(callbackBeforeBlockchainLoaded, callbackBeforeServerInitialization, callbackAfterServerInitialization, afterSynchronizationCallback, synchronize = true) { + + if (!Blockchain._blockchainInitiated) { + + await Blockchain.createBlockchain("full-node", callbackBeforeBlockchainLoaded, async () => { + + if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); + + await Node.NodeServer.startServer(); + + await Node.NodeClientsService.startService(); + + if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); + + }, afterSynchronizationCallback, synchronize); + + } else { + + if (callbackBeforeBlockchainLoaded) await callbackBeforeBlockchainLoaded(); + + if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); + + if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); + + if (afterSynchronizationCallback) await afterSynchronizationCallback(); + + } + + } + + + disableForksImmutability() { + + consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH += 10000; + + setTimeout(() => { + + consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH -= 10000; + + }, 10 * 60 * 1000); + + } + + disconnectFromAllConnectedNodes() { + + let NodesList = require('node/lists/Nodes-List').default; + NodesList.disconnectAllNodes(CONNECTION_TYPE.CONNECTION_CLIENT_SOCKET); + + } + + disconnectAllMinersNodes() { + + let NodesList = require('node/lists/Nodes-List').default; + NodesList.disconnectAllNodesByConsensusType(NODES_CONSENSUS_TYPE.NODE_CONSENSUS_MINER_POOL); + + } + + async setIntervalDisconnectAllMinersNodes(interval) { + + let intervalTime = !!interval || interval === 0 ? interval : await AdvancedMessages.readNumber('Enter the interval time: \n 0 - disable interval \n x - minutes'); + + if (this._intervalDisconnectingMiners) + clearTimeout(this._intervalDisconnectingMiners); + + if (intervalTime > 0) { + + this._intervalDisconnectingMiners = setInterval(() => { + this.disconnectAllMinersNodes(); + }, intervalTime * 60 * 1000); + + } + + } + + showCommands() { + + console.info('\nChoose one of the following commands:'); + + console.info("\nflagged arguments (example: -l, --list-addresses) can only be used in non-interactive mode.\nUse numbers for interactive mode.\n") + for (let i = 0; i < commands.length; ++i) { + console.info(commands[i]); + } + console.log(); + + return true; + } + +} + +const commands = [ + '1. List addresses (-l --list-addresses)', + '2. Create new address (--create-address)', + '3. Delete address (--delete-address {position in wallet list})', + '4. Import address (--import-address {path to wallet})', + '5. Export address (--export-address {position in wallet list})', + '6. Encrypt address (--encrypt-address {position in wallet list})', + '7. Set mining address (--mining-address {position in wallet list})', + '8. Solo: Start Mining (--mine)', + '9. Solo: Start Mining Instantly Even Unsynchronized (--mine-now)', + '10. Mining Pool: Start Mining (--mine-in-pool {pool url})', + '11. Mining Pool: Create a New Pool', + '11-1. Mining Pool: Process Remaining Payment', + '12. Server for Mining Pool: Create a new Server for Mining Pool (Optional and Advanced)', + '13. Create Offline Transaction', + '20. HTTPS Express Start', + '21. Disable Node Immutability', + '22. Disconnect from all consensus nodes', + '23. Disconnect all miner nodes', + '24. Set Interval to disconnect all miner nodes', + '30. Set Password for Mining Address', + '53. Add address to banlist', + '54. Load address banlist', + '55. Save address banlist', +]; + +const lineSeparator = + "\n|_______|____________________________________________|_________________|"; + +const addressHeader = + "\n ______________________________________________________________________" + + "\n| NUM | ADDRESS | WEBD |" + + lineSeparator; + +export default CLICore; diff --git a/src/node/menu/CLI-Menu-non-interactive.js b/src/node/menu/CLI-Menu-non-interactive.js new file mode 100644 index 000000000..69dcbc7e3 --- /dev/null +++ b/src/node/menu/CLI-Menu-non-interactive.js @@ -0,0 +1,164 @@ +/* eslint-disable */ +import CLICore from './CLI-Core'; + +class CLIRunner { + + static get CORE() { + return CLICore.INSTANCE; + } + + /** + * + * @param args - string array of arguments. + */ + constructor(args) { + console.log("Running %o", args); + this.args = args; + } + + async run() { + while (this.args.length > 0) { + this.args = await this.runCommand(this.args); + } + } + + async runCommand(args) { + + let [command, ...rest] = args; + + switch (command.trim()) { + case '1': // List addresses' + case '-l': + case '--list-addresses': + await CLIRunner.CORE.listAddresses(); + break; + case '2': // Create new address', + case '--create-address': + await CLIRunner.CORE.createNewAddress(); + break; + case '3': // Delete Address + case '--delete-address': + let deleteId = rest.shift(); + await CLIRunner.CORE.deleteAddress(deleteId); + break; + case '4': // Import Address + case '--import-address': + let walletPath = rest.shift(); + await CLIRunner.CORE.importAddress(walletPath); + break; + case '5': // Export Address + case '--export-address': + let exportId = rest.shift(); + await CLIRunner.CORE.exportAddress(exportId); + break; + case '6': // Encrypt Address + case '--encrypt-address': + let encryptId = rest.shift(); + await CLIRunner.CORE.encryptAddress(encryptId); + break; + case '7': // Set Mining Address + case '--mining-address': + let pos = rest.shift(); + await CLIRunner.CORE.setMiningAddress(pos); + break; + case '8': // Start Mining + case '--mine': + await CLIRunner.CORE.startMining(); + await this.waitForMiningToStop(); + break; + case '9': // Start Mining Instantly + case '--mine-now': + await CLIRunner.CORE.startMining(true); + await this.waitForMiningToStop(); + break; + case '10': // Mining Pool: Start Mining in a Pool + case '--mine-in-pool': + let url = rest.shift(); + await CLIRunner.CORE.startMiningInsidePool(url, false); + await this.waitForMiningToStop(); + break; + case '11-1': // Mining Pool: Create a New Pool + case '--process-payments': + console.error('Remaining payments can\'t be processed non-interactively at this time!'); + break; + case '11': // Mining Pool: Create a New Pool + case '--create-pool': + console.error('Mining pools cannot be made non-interactively at this time!'); + break; + case '12': // Server Mining Pool Create a new Server for Mining Pool + case '--create-server-for-pool': + console.error('Mining pools cannot be made non-interactively at this time!'); + break; + case '13': // Import Address + case '--sign-transaction': + console.error('Transactions cannot be signed non-interactively at this time!'); + break; + case '20': // Server Mining Pool: Create a new Server for Mining Pool + case '--start-pool-server': + console.error('Mining Pool Servers cannot be started non-interactively at this time!'); + break; + case '21': // Disable Forks Immutability + case '--disable-forks-immutability': + await CLIRunner.CORE.disableForksImmutability(); + break; + case '22': // Disable Forks Immutability + case '--disconnect-from-all-nodes': + await CLIRunner.CORE.disconnectFromAllConnectedNodes(); + break; + case '23': + case '--disconnect-all-miners-nodes': + await CLIRunner.CORE.disconnectAllMinersNodes(); + break; + case '24': + case '--set-disconnect-interval': + await CLIRunner.CORE.setIntervalDisconnectAllMinersNodes(); + break; + case '30': // Set Password + case '--set-password': + await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(); + break; + case '53': // add banlist + case '--add-to-banlist': + console.error('The ban list cannot be modified non-interactively at this time.'); + break; + case '54': // load banlist + case '--load-banlist': + console.error('The ban list cannot be modified non-interactively at this time.'); + break; + case '55': // save banlist + case '--save-banlist': + console.error('The ban list cannot be modified non-interactively at this time.'); + break; + default: // show usage. + CLIRunner.CORE.showCommands(); + break; + } + + return rest; + }; + + async waitForMiningToStop() { + console.log("Mining will continue until the SIGINT or SIGTERM signal is received."); + + let isMining = true; + + process.on('SIGINT', () => isMining = false); + process.on('SIGTERM', () => isMining = false); + + const snooze = ms => new Promise(resolve => setTimeout(resolve, ms)); + return new Promise(async (resolve) => { + + const waitForMining = async () => { + await snooze(10000); + }; + + while (isMining) { + await waitForMining(); + } + resolve(); + }) + } + +} + +export default CLIRunner; diff --git a/src/node/menu/CLI-Menu.js b/src/node/menu/CLI-Menu.js index addfd3e4b..e459cad3e 100644 --- a/src/node/menu/CLI-Menu.js +++ b/src/node/menu/CLI-Menu.js @@ -1,10 +1,4 @@ /* eslint-disable */ -import CONNECTION_TYPE from "../lists/types/Connection-Type"; -import NODES_CONSENSUS_TYPE from "../lists/types/Node-Consensus-Type"; - - -const FileSystem = require('fs'); -const readline = require('readline'); import {JsonRpcServer} from './../jsonRpc'; let NodeExpress, NodeServer; @@ -16,18 +10,19 @@ if (!process.env.BROWSER) { import consts from 'consts/const_global'; -import {Node} from '../../index.js'; import AdvancedMessages from './Advanced-Messages'; -import WebDollarCoins from "common/utils/coins/WebDollar-Coins"; -import InterfaceBlockchainAddressHelper from "common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper"; import Blockchain from "main-blockchain/Blockchain" -import StatusEvents from "common/events/Status-Events"; import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; import Log from 'common/utils/logging/Log'; -import AddressBanList from "common/utils/bans/AddressBanList"; +import CLICore from "./CLI-Core"; +import CLIRunner from './CLI-Menu-non-interactive'; class CLI { + static get CORE() { + return CLICore.INSTANCE; + } + constructor() { if (process.env.BROWSER) @@ -35,7 +30,22 @@ class CLI { this._exitMenu = undefined; - this._start(); + // parse cli args + this.cliArgs = process.argv; + + if (!this.cliArgs.includes('--')) { + this._startInteractive(); + } else { + console.log("Non-interactive activated. Args will be read from left to right."); + this.cliArgs = this.cliArgs.splice(this.cliArgs.indexOf('--')); + if (this.cliArgs.length <= 0) { + CLI.CORE.showCommands(); + } + console.log('Working with args: %o', this.cliArgs); + this.runner = new CLIRunner(this.cliArgs); + this.runner.run() + .then(() => process.exit()); + } } @@ -51,166 +61,90 @@ class CLI { switch (answer.trim()) { case '1': // List addresses' - await this.listAddresses(); + await CLI.CORE.listAddresses(); break; case '2': // Create new address', - await this.createNewAddress(); + await CLI.CORE.createNewAddress(); break; case '3': // Delete Address - await this.deleteAddress(); + await CLI.CORE.deleteAddress(); break; case '4': // Import Address - await this.importAddress(); + await CLI.CORE.importAddress(); break; case '5': // Export Address - await this.exportAddress(); + await CLI.CORE.exportAddress(); break; case '6': // Encrypt Address - await this.encryptAddress(); + await CLI.CORE.encryptAddress(); break; case '7': // Set Mining Address - await this.setMiningAddress(); + await CLI.CORE.setMiningAddress(); break; case '8': // Start Mining - await this.startMining(); + await CLI.CORE.startMining(); break; case '9': // Start Mining Instantly - await this.startMining(true); + await CLI.CORE.startMining(true); break; case '10': // Mining Pool: Start Mining in a Pool - await this.startMiningInsidePool(); + await CLI.CORE.startMiningInsidePool(); break; case '11-1': // Mining Pool: Create a New Pool - await this.processRemainingPayment(); + await CLI.CORE.processRemainingPayment(); break; case '11': // Mining Pool: Create a New Pool - await this.createMiningPool(); + await CLI.CORE.createMiningPool(); break; case '12': // Server Mining Pool: Create a new Server for Mining Pool - await this.createServerForMiningPool(); + await CLI.CORE.createServerForMiningPool(); break; case '13': // Import Address - await this.signTransaction(); + await CLI.CORE.signTransaction(); break; case '20': // Server Mining Pool: Create a new Server for Mining Pool await NodeServer.startServer(); break; case '21': // Disable Forks Immutability - await this.disableForksImmutability(); + await CLI.CORE.disableForksImmutability(); break; case '22': // Disable Forks Immutability - await this.disconnectFromAllConnectedNodes(); + await CLI.CORE.disconnectFromAllConnectedNodes(); break; case '23': - await this.disconnectAllMinersNodes(); + await CLI.CORE.disconnectAllMinersNodes(); break; case '24': - await this.setIntervalDisconnectAllMinersNodes(); + await CLI.CORE.setIntervalDisconnectAllMinersNodes(); break; case '30': // Set Password await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(); break; case '53': // add banlist - await this.AddAddressBanList(); + await CLI.CORE.AddAddressBanList(); break; case '54': // add banlist - await this.LoadAddressBanList(); + await CLI.CORE.LoadAddressBanList(); break; case '55': // add banlist - await this.SaveAddressBanList(); + await CLI.CORE.SaveAddressBanList(); break; case 'exit': this._exitMenu = true; break; default: - this._showCommands(); + CLI.CORE.showCommands(); break; } await this._runMenu(); }; - signTransaction() { - - console.info('Sign Transaction'); - - return new Promise(async (resolve) => { - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - resolve(false); - return; - } - - let toAddress = await AdvancedMessages.input('Enter the recipient address: '); - let amountToSend = await AdvancedMessages.input('Enter the transaction amount: '); - let nonce = await AdvancedMessages.input('Enter the address current nonce: '); - let timelock = await AdvancedMessages.input('Enter the current block: '); - let addressPath = await AdvancedMessages.input('Enter path for saving the transaction:'); - let wantToPropagate = await AdvancedMessages.input('Do you want to propagate now y/n?:'); - - if (wantToPropagate.toUpperCase().trim() === 'Y' ? true : false) - wantToPropagate = true; - else - wantToPropagate = false; - - let feeToSend = Blockchain.Transactions.wizard.calculateFeeSimple(amountToSend); - - let addressString = Blockchain.Wallet.addresses[addressId].address; - let answer = null; - - //Trick for blocks length and address nonce - Blockchain.blockchain.blocks._length = timelock + 1; - - for (let i = 0; i < Blockchain.Wallet.addresses.length; i++) - if (addressString === Blockchain.Wallet.addresses[i].address) - answer = await Blockchain.Transactions.wizard.validateTransaction(Blockchain.Wallet.addresses[i].address, toAddress, amountToSend * WebDollarCoins.WEBD, feeToSend, undefined, undefined, timelock - 1, nonce, true); - - let data = {}; - - if (answer.result) { - - data.transaction = answer.transaction.serializeTransaction(); - data.signature = answer.signature; - - if (wantToPropagate) - await Blockchain.blockchain.transactions.pendingQueue.includePendingTransaction(answer.transaction, undefined, true); - - } else { - - console.log("Transaction was not created. " + answer.message); - resolve(false); - return; - - } - - FileSystem.writeFile(addressPath + "transaction.tx", JSON.stringify(data), 'utf8', (err) => { - - if (err) { - console.error(err); - resolve(false); - return; - } - - console.log("Transaction successfully exported to ," + addressPath + "transaction.tx"); - - resolve(true); - - }); - - resolve(true); - - }); - - } - - async _start() { + async _startInteractive() { Log.info('CLI menu started', Log.LOG_TYPE.CLI_MENU); - if (Blockchain ) + if (Blockchain) await Blockchain.loadWallet(); this._showCommands(); @@ -222,588 +156,8 @@ class CLI { await this._runMenu(); } - async processRemainingPayment() { - - await this._callCallbackBlockchainSync(undefined, undefined, undefined, async () => { - await Blockchain.PoolManagement.poolRemainingRewards.doPayout(); - }, true); - - } - - async _chooseAddress() { - - await this.listAddresses(); - - let addressId = await AdvancedMessages.readNumber('Choose the address number: '); - - if (isNaN(addressId) || addressId < 0 || Blockchain.Wallet.addresses.length <= addressId) - return -1; - - return addressId; - } - - async AddAddressBanList() { - - let addressWIF = await AdvancedMessages.input('Please input miner address: '); - if (addressWIF.length == 40) { - let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); - if (unencodedAddress) { - let duration = await AdvancedMessages.readNumber('Ban duration (hours): '); - let reason = await AdvancedMessages.input('Please input ban reason: '); - reason = reason.replace(';', '.,'); - AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); - AddressBanList.listBans(); - } - } - - } - - async LoadAddressBanList() { - - try { - - const file = FileSystem.createReadStream('address-ban-list.txt'); - - const rl = readline.createInterface({ - input: file, - crlfDelay: Infinity - }); - - rl.on('error', (err) => { - console.error('Address ban list was not found'); - }); - - file.on('error', (err) => { - console.error('Address ban list was not found'); - }); - - rl.on('line', (line) => { - let triplet = line.split(';'); - if (triplet.length === 3) { - - let duration = parseFloat(triplet[0]); - let addressWIF = triplet[1]; - let reason = triplet[2]; - - if (addressWIF && addressWIF.length == 40) { - let unencodedAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(addressWIF); - if (unencodedAddress) - AddressBanList.addBan(unencodedAddress, duration * 3600 * 1000, reason); - } - } else console.log("Invalid line in address-ban-list.txt", line); - }); - - rl.on('close', () => { - AddressBanList.listBans(); - }); - - } catch (exception) { - console.error("Error loading banlist: ", exception); - } - } - - async SaveAddressBanList() { - AddressBanList.saveBans(); - } - - _showCommands() { - - console.info('\nChoose one of the following commands:'); - - for (let i = 0; i < commands.length; ++i) { - console.info(commands[i]); - } - console.log(); - - return true; - } - - async listAddresses() { - - - console.warn("INFO: YOU NEED TO BE SYNC TO SEE THE VALUE OF YOUR WALLET!!!"); - console.info('\nWallet addresses:'); - - let miningAddress = Blockchain.blockchain.mining.minerAddress; - if ( !miningAddress ) - miningAddress = 'not specified'; - - console.log(addressHeader); - for (let i = 0; i < Blockchain.Wallet.addresses.length; ++i) { - - let address = Blockchain.Wallet.addresses[i].address; - - let balance = Blockchain.blockchain.accountantTree.getBalance(address, undefined); - - balance = (balance === null) ? 0 : (balance / WebDollarCoins.WEBD); - - if (address === miningAddress) - console.log(((i < 10) ? "| *" : "| *") + i + " | " + address + " | " + balance + lineSeparator); - else - console.log(((i < 10) ? "| " : "| ") + i + " | " + address + " | " + balance + lineSeparator); - - } - - let balance = 0; - if (miningAddress !== 'not specified') { - balance = Blockchain.blockchain.accountantTree.getBalance(miningAddress, undefined); - balance = (balance === null) ? 0 : balance; - - if (Blockchain.MinerPoolManagement && Blockchain.MinerPoolManagement.minerPoolStarted) - balance += Blockchain.MinerPoolManagement.minerPoolReward.total; - - balance /= WebDollarCoins.WEBD; - - - } - console.log("| MINING| " + miningAddress + " | " + balance + lineSeparator); - - return true; - - } - - async createNewAddress() { - - console.info('Create new address.'); - try { - let address = await Blockchain.Wallet.createNewAddress(); - console.info("Address was created: " + address.address); - return true; - } catch (err) { - console.err(err); - return false; - } - - } - - async deleteAddress() { - - console.info('Delete address.'); - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - return false; - } - - let response = await Blockchain.Wallet.deleteAddress(Blockchain.Wallet.addresses[addressId].address); - - return response.result; - } - - importAddress() { - - console.info('Import address.'); - - return new Promise(async (resolve) => { - - let addressPath = await AdvancedMessages.input('Enter address path: '); - - FileSystem.readFile(addressPath, 'utf8', async (err, content) => { - - if (err) { - console.error(err); - resolve(false); - return; - } - - try { - - let answer = await Blockchain.Wallet.importAddressFromJSON(JSON.parse(content)); - - if (answer.result === true) { - console.log("Address successfully imported", answer.address); - await Blockchain.Wallet.saveWallet(); - - if (Blockchain.Wallet.addresses.length === 1) Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[0].address; - - resolve(true); - } else { - console.error(answer.message); - resolve(false); - } - - } catch (err) { - console.error(err.message); - resolve(false); - } - - - }); - - }); - - } - - exportAddress() { - - console.info('Export address.'); - - return new Promise(async (resolve) => { - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - resolve(false); - return; - } - - let addressPath = await AdvancedMessages.input('Enter path for saving address: '); - - let addressString = Blockchain.Wallet.addresses[addressId].address; - let fileName = "WEBD$" + Blockchain.Wallet.addresses[addressId].unencodedAddress.toString("hex") + ".webd"; - - let answer = await Blockchain.Wallet.exportAddressToJSON(addressString); - - if (answer.result === false) { - console.log("Address was not exported. :(. " + answer.message); - resolve(false); - return; - } - - let jsonAddress = JSON.stringify(answer.data); - - FileSystem.writeFile(addressPath + fileName, jsonAddress, 'utf8', (err) => { - - if (err) { - console.error(err); - resolve(false); - return; - } - - console.log("Address successfully exported", addressString, ' to ', addressPath + fileName); - - resolve(true); - return; - - }); - - resolve(true); - return; - - }); - - } - - async encryptAddress() { - - console.info('Encrypt address.'); - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - return false; - } - - let addressString = Blockchain.Wallet.addresses[addressId].address; - let newPassword = await InterfaceBlockchainAddressHelper.askForPassword("Please enter a password(12 words separated by space):"); - let response = await Blockchain.Wallet.encryptAddress(addressString, newPassword); - - if (response === true) - console.info("Address was encrypted:", addressString); - else - console.error("Address couldn't be encrypted:", addressString); - - return response.result; - } - - async setMiningAddress() { - - console.info('Set mining address.'); - - let addressId = await this._chooseAddress(); - - if (addressId < 0) { - console.warn("You must enter a valid number."); - return false; - } - - Blockchain.blockchain.mining.minerAddress = Blockchain.Wallet.addresses[addressId].address; - - return true; - } - - async startMining(instantly) { - - - await this._callCallbackBlockchainSync(undefined, () => Blockchain.MinerPoolManagement.minerPoolSettings.setMinerPoolActivated(false), async () => { - - if (instantly) - await Blockchain.startMiningInstantly(); - else - Blockchain.startMiningNextTimeSynchronized = true; - - }, undefined, undefined); - - } - - async startMiningInsidePool() { - - Log.info('Mining inside a POOL', Log.LOG_TYPE.POOLS); - - consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; - - await this._callCallbackBlockchainSync(undefined, async () => { - - try { - - let getNewLink = true; - - if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '') { - - Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); - let response = await AdvancedMessages.confirm('Do you want to continue mining in the same pool: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolURL); - - if (response === true) getNewLink = false; - 7 - } - - let miningPoolLink = undefined; - - if (getNewLink) { - - miningPoolLink = await AdvancedMessages.input('Enter the new mining pool link: '); - Log.info('Your new MiningPool is : ' + miningPoolLink, Log.LOG_TYPE.info); - - } - - StatusEvents.on("miner-pool/connection-established", (data) => { - if (data.connected) - Blockchain.Mining.startMining(); - else - Blockchain.Mining.stopMining(); - }); - - Blockchain.MinerPoolManagement.startMinerPool(miningPoolLink, true); - - } catch (exception) { - - Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); - - } - - }, undefined, undefined, false); - - } - - async createMiningPool() { - - Log.info('Create Mining Pool', Log.LOG_TYPE.info); - - await this._callCallbackBlockchainSync(async () => { - - try { - - await Blockchain.PoolManagement.setPoolStarted(false); - - let getNewLink = true; - - Log.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.', Log.LOG_TYPE.info); - - if (typeof Blockchain.PoolManagement.poolSettings.poolURL === "string" && Blockchain.PoolManagement.poolSettings.poolURL !== '') { - - console.info('You have some settings for a pool: ', Blockchain.PoolManagement.poolSettings.poolName, " ", Blockchain.PoolManagement.poolSettings.poolWebsite); - let response = await AdvancedMessages.confirm('Do you want to continue using the settings for : ' + Blockchain.PoolManagement.poolSettings.poolURL); - - if (response === true) getNewLink = false; - } - - if (getNewLink) { - - let poolFee, poolReferralFee, poolName, poolWebsite, poolServers; - - - poolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); - - if (isNaN(poolFee) || poolFee < 0 || 100 < poolFee) { - Log.error("You have entered an invalid number: " + poolFee, Log.LOG_TYPE.POOLS); - return false; - } else - Log.info("Your fee is " + poolFee, Log.LOG_TYPE.POOLS); - - poolName = await AdvancedMessages.input('Pool Name: '); - poolWebsite = await AdvancedMessages.input('Pool Website: '); - - poolReferralFee = await AdvancedMessages.readNumber("Choose a Referral fee (0...100): ", true); - if (isNaN(poolReferralFee) || poolReferralFee < 0 || 100 < poolReferralFee) { - Log.error("You have entered an invalid number:" + poolReferralFee, Log.LOG_TYPE.POOLS); - return false; - } else - Log.warn("Your Referral fee is: " + poolReferralFee, Log.LOG_TYPE.POOLS); - - let response = await AdvancedMessages.confirm('Do you want to use external pool servers?: '); - - if (response) - poolServers = await AdvancedMessages.input('Pool Servers (separated by comma): '); - else - poolServers = await NodeServer.getServerHTTPAddress(true); - - console.info("Pool Servers:", poolServers); - - if (response) { - await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(true); - } else { - await Blockchain.PoolManagement.poolSettings.setPoolUsePoolServers(false); - await Blockchain.PoolManagement.poolSettings.setPoolUseSignatures(false); - } - - - if (poolFee) await Blockchain.PoolManagement.poolSettings.setPoolFee(poolFee / 100); - if (poolName) await Blockchain.PoolManagement.poolSettings.setPoolName(poolName); - if (poolWebsite) await Blockchain.PoolManagement.poolSettings.setPoolWebsite(poolWebsite); - if (poolServers) await Blockchain.PoolManagement.poolSettings.setPoolServers(poolServers); - if (poolReferralFee) await Blockchain.PoolManagement.poolSettings.setPoolReferralFee(poolReferralFee / 100); - - } - - } catch (exception) { - - Log.error("Error starting your pool", Log.LOG_TYPE.POOLS, exception); - - } - - }, async () => { - - await Blockchain.PoolManagement.startPool(true); - - }, undefined, undefined, true); - - } - - async createServerForMiningPool() { - - await this._callCallbackBlockchainSync(async () => { - - console.info('Create Server Pool'); - console.warn('To be accessible by Browser miners you need an authorized SSL certificate and a free domain.'); - - let serverPoolFee = await AdvancedMessages.readNumber('Choose a fee(0...100): ', true); - - if (isNaN(serverPoolFee) || serverPoolFee < 0 || 100 < serverPoolFee) { - console.log("You have entered an invalid number:", serverPoolFee); - return false; - } else - console.log("your fee is", serverPoolFee); - - await Blockchain.ServerPoolManagement.serverPoolSettings.setServerPoolFee(serverPoolFee / 100); - - }, - async () => { - - await Blockchain.ServerPoolManagement.startServerPool(); - - }, undefined, undefined, true, - ); - - - } - - async _callCallbackBlockchainSync(callbackBeforeBlockchainLoaded, callbackBeforeServerInitialization, callbackAfterServerInitialization, afterSynchronizationCallback, synchronize = true) { - - if (!Blockchain._blockchainInitiated) { - - await Blockchain.createBlockchain("full-node", callbackBeforeBlockchainLoaded, async () => { - - if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); - - await Node.NodeServer.startServer(); - - await Node.NodeClientsService.startService(); - - if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); - - }, afterSynchronizationCallback, synchronize); - - } else { - - if (callbackBeforeBlockchainLoaded) await callbackBeforeBlockchainLoaded(); - - if (callbackBeforeServerInitialization) await callbackBeforeServerInitialization(); - - if (callbackAfterServerInitialization) await callbackAfterServerInitialization(); - - if (afterSynchronizationCallback) await afterSynchronizationCallback(); - - } - - } - - - disableForksImmutability() { - - consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH += 10000; - - setTimeout(() => { - - consts.BLOCKCHAIN.FORKS.IMMUTABILITY_LENGTH -= 10000; - - }, 10 * 60 * 1000); - - } - - disconnectFromAllConnectedNodes() { - - let NodesList = require('node/lists/Nodes-List').default; - NodesList.disconnectAllNodes(CONNECTION_TYPE.CONNECTION_CLIENT_SOCKET); - - } - - disconnectAllMinersNodes() { - - let NodesList = require('node/lists/Nodes-List').default; - NodesList.disconnectAllNodesByConsensusType(NODES_CONSENSUS_TYPE.NODE_CONSENSUS_MINER_POOL); - - } - - async setIntervalDisconnectAllMinersNodes() { - - let intervalTime = await AdvancedMessages.readNumber('Enter the interval time: \n 0 - disable interval \n x - minutes'); - - if (this._intervalDisconnectingMiners) - clearTimeout(this._intervalDisconnectingMiners); - - if (intervalTime > 0) { - - this._intervalDisconnectingMiners = setInterval(() => { - this.disconnectAllMinersNodes(); - }, intervalTime * 60 * 1000); - - } - - } - } -const commands = [ - '1. List addresses', - '2. Create new address', - '3. Delete address', - '4. Import address', - '5. Export address', - '6. Encrypt address', - '7. Set mining address', - '8. Solo: Start Mining', - '9. Solo: Start Mining Instantly Even Unsynchronized', - '10. Mining Pool: Start Mining', - '11. Mining Pool: Create a New Pool', - '11-1. Mining Pool: Process Remaining Payment', - '12. Server for Mining Pool: Create a new Server for Mining Pool (Optional and Advanced)', - '13. Create Offline Transaction', - '20. HTTPS Express Start', - '21. Disable Node Immutability', - '22. Disconnect from all consensus nodes', - '23. Disconnect all miner nodes', - '24. Set Interval to disconnect all miner nodes', - '30. Set Password for Mining Address', - '53. Add address to banlist', - '54. Load address banlist', - '55. Save address banlist', -]; - - const lineSeparator = "\n|_______|____________________________________________|_________________|"; From 0bba4e30e206e3990e388faec63e3490f60920f2 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Thu, 4 Mar 2021 13:36:04 +0200 Subject: [PATCH 047/132] typo for showCommands --- src/node/menu/CLI-Menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/menu/CLI-Menu.js b/src/node/menu/CLI-Menu.js index e459cad3e..1b85100ec 100644 --- a/src/node/menu/CLI-Menu.js +++ b/src/node/menu/CLI-Menu.js @@ -147,7 +147,7 @@ class CLI { if (Blockchain) await Blockchain.loadWallet(); - this._showCommands(); + CLI.CORE.showCommands(); AdvancedMessages.WEBD_CLI.prompt(); JsonRpcServer(consts.JSON_RPC); From 56fcf5fcea31d7db55567a4f89384328d40a6840 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 8 Mar 2021 14:01:14 +0200 Subject: [PATCH 048/132] fix CLI bug for command 4 --- src/node/menu/CLI-Core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js index 91e18051f..3ddd08b5c 100644 --- a/src/node/menu/CLI-Core.js +++ b/src/node/menu/CLI-Core.js @@ -281,7 +281,7 @@ export class CLICore { console.info('Import address.'); return new Promise(async (resolve) => { - path = !!path ? path : AdvancedMessages.input('Enter address path: '); + path = !!path ? path : await AdvancedMessages.input('Enter address path: '); FileSystem.readFile(path, 'utf8', async (err, content) => { From 03792ea66b103003b467ccfc2a2aa642ac815a34 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Tue, 9 Mar 2021 18:39:27 -0700 Subject: [PATCH 049/132] Create a dockerized development environment So I can run this locally --- Dockerfile.dev-env | 44 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ docker-compose.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 Dockerfile.dev-env create mode 100644 docker-compose.yml diff --git a/Dockerfile.dev-env b/Dockerfile.dev-env new file mode 100644 index 000000000..4cf52be4e --- /dev/null +++ b/Dockerfile.dev-env @@ -0,0 +1,44 @@ +FROM ubuntu:20.04 + +ENV TERM xterm +ENV TZ UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN mkdir -p /workspace/.nvm +RUN mkdir -p /workspace/Node-WebDollar +WORKDIR /workspace/ +ENV HOME /workspace/ + +ENV NVM_DIR /workspace/.nvm +ENV NODE_VERSION 8.2.1 + +RUN apt-get update && apt-get install -y git curl wget build-essential software-properties-common clang cmake libtool autoconf psmisc opencl-headers ocl-icd-libopencl1 pciutils python2 + +# Install nvm with node and npm +RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \ + && . $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + +ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +#RUN git clone https://github.com/WebDollar/Node-WebDollar.git miner + +# Build the custom argon2 package +RUN git clone https://github.com/WebDollar/argon2 +WORKDIR /workspace/argon2 +RUN autoreconf -i +RUN bash configure +RUN cmake -DCMAKE_BUILD_TYPE=Release . +RUN make + +ENV NODE_TLS_REJECT_UNAUTHORIZED 0 +WORKDIR /workspace/Node-WebDollar +RUN mkdir -p ./dist_bundle/CPU/ +RUN cp -a ../argon2/* dist_bundle/CPU/ + +ENV PYTHON /usr/bin/python2 + +CMD [ "/bin/bash" ] diff --git a/README.md b/README.md index 225ac83e6..057157506 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,29 @@ npm run start Follow the tutorial: [PM2 to run the Node Indefinitely](/docs/PM2-Tutorial.md) +## Development Environment + +### Dockerized +It is possible to run the development environment in a docker container. +This is useful if you are unable to configure and install the custom argon2 +flavor required by this project. The docker container has this project set up to be +built in it, and comes pre-installed with the tools you need for this project. + +#### Building + +Run `docker-compose build` to build the workspace container. + +To force a rebuild, you can either remove the previous workspace (`docker rm webdollar-dev-env`) +or you can run `docker-compose build --no-cache`. + +#### Running + +Once you've build the workspace container, simply run it to launch an interactive shell with all the tools you need to develop. + +`docker-compose run webdollar-dev-env` + +This entire folder is mounted into the container, so any files you change in the workspace will be available to the container immediately. + # To do: 1. Pool Mining diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..81c35af0f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +# +# This docker-compose provides a development environment in case your +# system is otherwise incompatible with the WebDollar project (like MacOS). +# +# Build with `docker-compose build` +# To force a rebuild, remove the container `docker rm webdollar-dev-env` +# Launch with `docker-compose run webdollar-dev-env` +version: "3.9" + +services: + webdollar-dev-env: + container_name: webdollar-dev-env + build: + context: ./ + dockerfile: Dockerfile.dev-env + # todo: what ports should be exposed? + volumes: + - .:/workspace/Node-WebDollar + ## Launch an interactive CLI workspace. + stdin_open: true # docker run -i + tty: true # docker run -t + entrypoint: + - "/bin/bash" + networks: + webdollar: + +networks: + webdollar: From eadc08fc10e59e6e006ed09fadb7321019c6e8d3 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Tue, 9 Mar 2021 20:14:04 -0700 Subject: [PATCH 050/132] Add a dummy sudo command to the development environment --- Dockerfile.dev-env | 8 ++++++++ webd | 0 2 files changed, 8 insertions(+) create mode 100644 webd diff --git a/Dockerfile.dev-env b/Dockerfile.dev-env index 4cf52be4e..2d3dacb1f 100644 --- a/Dockerfile.dev-env +++ b/Dockerfile.dev-env @@ -41,4 +41,12 @@ RUN cp -a ../argon2/* dist_bundle/CPU/ ENV PYTHON /usr/bin/python2 +# this container runs as root, add a dummy sudo +# creates a tiny script that just runs the command passed to it. +#> eval "$@" +# +# this is needed since many of the scripts in this project use sudo. +RUN echo "#!/bin/bash\\neval \"\$@\"" > /usr/bin/sudo && \ + chmod +x /usr/bin/sudo + CMD [ "/bin/bash" ] diff --git a/webd b/webd new file mode 100644 index 000000000..e69de29bb From 328711fcdc94821b19328174b24af6867579d334 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Tue, 9 Mar 2021 20:31:20 -0700 Subject: [PATCH 051/132] Initial functioning 'webd' script for using the non-intractive CLI --- .gitignore | 3 +++ webd | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) mode change 100644 => 100755 webd diff --git a/.gitignore b/.gitignore index 27750e45f..81f28ef2f 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,9 @@ serverPoolDB*/ transactionsDB*/ +## This gets added by running install scripts. +vue-Frontend/ + certificates/ca_bundle.crt certificates/certificate.crt certificates/private.key diff --git a/webd b/webd old mode 100644 new mode 100755 index e69de29bb..87454e3c5 --- a/webd +++ b/webd @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +### +### This provides a ./webd command for running +### The web-dollar CLI in non-interactive mode. +### + +RED='\033[0;31m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +function check_args { +if [ $# -eq 0 ] +then + echo -e "${RED}No arguments supplied${NC}" + exit 7 +fi +} + +function cli { + if test -f "./dist_bundle/terminal-menu-bundle.js"; then + check_args "$@" + node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js -- "$@" + else + echo + echo -e "${RED}Couldn't find the CLI bundle." + echo -e "${RED}Be sure to build it first!" + echo + echo -e "${CYAN}npm run build_terminal_menu && npm run build_terminal_worker${NC}" + echo + exit 7 + fi +} + +cli "$@" From b9a5a9d1caa580006d4b376c4d1b8bf20491b33d Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Tue, 9 Mar 2021 22:58:35 -0700 Subject: [PATCH 052/132] WIP initial decryption for password protected wallets for PoS non-interactively --- .../Interface-Blockchain-Mining-Basic.js | 8 +- src/node/menu/CLI-Core.js | 85 ++++--------------- src/node/menu/CLI-Menu-non-interactive.js | 12 ++- 3 files changed, 32 insertions(+), 73 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js index 9d2578463..27f96f553 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js @@ -229,13 +229,13 @@ class InterfaceBlockchainMiningBasic { } // if it is in terminal asking for the password (required in POS) - async setPrivateKeyAddressForMiningAddress(){ + async setPrivateKeyAddressForMiningAddress(actualPassword){ let foundAddress = Blockchain.Wallet.getAddress(this.minerAddress); - let password = await foundAddress.getPrivateKey(); + const password = await foundAddress.getPrivateKey(actualPassword); - if (password){ + if (password) { foundAddress._privateKeyForMining = password; console.warn("Mining Address ready for mining" + this.minerAddress ); @@ -251,4 +251,4 @@ class InterfaceBlockchainMiningBasic { } -export default InterfaceBlockchainMiningBasic; \ No newline at end of file +export default InterfaceBlockchainMiningBasic; diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js index 3ddd08b5c..1b4e92320 100644 --- a/src/node/menu/CLI-Core.js +++ b/src/node/menu/CLI-Core.js @@ -128,16 +128,6 @@ export class CLICore { return addressId; } - async _chooseAddressNonInteractive(pos) { - console.log(`Choosing Address ${pos} from addresses:`) - await this.listAddresses(); - - if (isNaN(pos) || pos < 0 || Blockchain.Wallet.addresses.length <= pos) - return -1; - - return pos; - } - async AddAddressBanList() { let addressWIF = await AdvancedMessages.input('Please input miner address: '); @@ -468,64 +458,6 @@ export class CLICore { } - async nonInteractiveMineInPool(url) { - Log.info('Mining inside a POOL: ' + url, Log.LOG_TYPE.POOLS); - - consts.SETTINGS.NODE.PORT = consts.SETTINGS.NODE.MINER_POOL_PORT; - - await this._callCallbackBlockchainSync(undefined, async () => { - - try { - - let getNewLink = !!url; - - if (typeof Blockchain.MinerPoolManagement.minerPoolSettings.poolURL === "string" && Blockchain.MinerPoolManagement.minerPoolSettings.poolURL !== '') { - - Log.info('Your current mining pool is: ' + Blockchain.MinerPoolManagement.minerPoolSettings.poolName + " " + Blockchain.MinerPoolManagement.minerPoolSettings.poolWebsite, Log.LOG_TYPE.error); - - if (!getNewLink) { - console.log('A new link was not provided. This will be used.'); - url = Blockchain.MinerPoolManagement.minerPoolSettings.poolURL - } else { - console.log('A new link was provided. It will overwrite the old link.'); - } - } - - StatusEvents.on("miner-pool/connection-established", (data) => { - if (data.connected) - Blockchain.Mining.startMining(); - else - Blockchain.Mining.stopMining(); - }); - - Blockchain.MinerPoolManagement.startMinerPool(url, true); - - } catch (exception) { - - Log.error("There is a problem starting to mine in this pool", Log.LOG_TYPE.POOLS, exception); - - } - - }, undefined, undefined, false); - - let mining = true; - - process.on('SIGTERM', () => { - console.log('SIGTERM received. Shutting down.'); - mining = false; - }); - - process.on('SIGINT', () => { - console.log('SIGINT received. Shutting down.'); - mining = false; - }); - - while (mining) { - // still mining, no sigterm received - await new Promise(resolve => setTimeout(resolve, 10000)); - } - } - async createMiningPool() { Log.info('Create Mining Pool', Log.LOG_TYPE.info); @@ -695,6 +627,23 @@ export class CLICore { } + decryptWallet(password) { + // var triesLeft = 3 + new Promise((resolve, reject) => { + StatusEvents.once("miner-pool/connection-established", (data) => { + if (data.connected) { + Blockchain.Mining.setPrivateKeyAddressForMiningAddress(password); + resolve(); + } + else { + console.error('Failed to unlock the wallet.') + reject(); + } + // console.error('Failed to unlock the wallet, will retry %o times', triesLeft); + }); + }).finally(() => console.info('Done importing password protected wallet.')); + } + async setIntervalDisconnectAllMinersNodes(interval) { let intervalTime = !!interval || interval === 0 ? interval : await AdvancedMessages.readNumber('Enter the interval time: \n 0 - disable interval \n x - minutes'); diff --git a/src/node/menu/CLI-Menu-non-interactive.js b/src/node/menu/CLI-Menu-non-interactive.js index 69dcbc7e3..08d033c5e 100644 --- a/src/node/menu/CLI-Menu-non-interactive.js +++ b/src/node/menu/CLI-Menu-non-interactive.js @@ -1,5 +1,7 @@ /* eslint-disable */ import CLICore from './CLI-Core'; +import Blockchain from 'main-blockchain/Blockchain'; + class CLIRunner { @@ -115,7 +117,15 @@ class CLIRunner { break; case '30': // Set Password case '--set-password': - await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(); + const actualPassword = rest.shift(); + // console.info('Password will be imported after the blockchain is initialized!'); + CLIRunner.CORE.decryptWallet(actualPassword.trim().split(' ')); + // await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(actualPassword); + break; + case '--set-password-file': + const passwordFile = rest.shift(); + // TODO: read from file. + await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(passwordFile); break; case '53': // add banlist case '--add-to-banlist': From 93debd934e61c065ee9892f6034e98c60cfabc12 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Wed, 10 Mar 2021 08:23:34 -0700 Subject: [PATCH 053/132] Finish the ability to decrypt a wallet, non-interactively (for PoS with locked wallet) --- src/node/menu/CLI-Core.js | 44 +++++++++++++---------- src/node/menu/CLI-Menu-non-interactive.js | 20 ++++++----- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js index 1b4e92320..cd16356f7 100644 --- a/src/node/menu/CLI-Core.js +++ b/src/node/menu/CLI-Core.js @@ -8,7 +8,6 @@ import WebDollarCoins from 'common/utils/coins/WebDollar-Coins'; import InterfaceBlockchainAddressHelper from 'common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper'; import Blockchain from 'main-blockchain/Blockchain'; import StatusEvents from 'common/events/Status-Events'; -import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; import Log from 'common/utils/logging/Log'; import AddressBanList from 'common/utils/bans/AddressBanList'; @@ -627,23 +626,6 @@ export class CLICore { } - decryptWallet(password) { - // var triesLeft = 3 - new Promise((resolve, reject) => { - StatusEvents.once("miner-pool/connection-established", (data) => { - if (data.connected) { - Blockchain.Mining.setPrivateKeyAddressForMiningAddress(password); - resolve(); - } - else { - console.error('Failed to unlock the wallet.') - reject(); - } - // console.error('Failed to unlock the wallet, will retry %o times', triesLeft); - }); - }).finally(() => console.info('Done importing password protected wallet.')); - } - async setIntervalDisconnectAllMinersNodes(interval) { let intervalTime = !!interval || interval === 0 ? interval : await AdvancedMessages.readNumber('Enter the interval time: \n 0 - disable interval \n x - minutes'); @@ -661,6 +643,30 @@ export class CLICore { } + /** + * Asynchronously starts decrypting the active wallet. + * @param password - the 12 word array of strings + */ + decryptWallet(password) { + new Promise((resolve, reject) => { + Blockchain.Mining.setPrivateKeyAddressForMiningAddress(password) + .then(() => resolve()) + .catch(() => reject()); + }).then(() => console.info('Done unlocking password protected wallet.')) + .catch(err => console.error(`Failed to unlock password protected wallet. ${err}`)); + } + + /** + * Read the password from a file and then decrypt the active wallet with it. + * @param filename + */ + decryptWalletFromFile(filename) { + FileSystem.readFile(filename, 'utf8', (err, password) => { + if (err) throw err; + this.decryptWallet(password.trim().split(' ')); + }); + } + showCommands() { console.info('\nChoose one of the following commands:'); @@ -696,7 +702,7 @@ const commands = [ '22. Disconnect from all consensus nodes', '23. Disconnect all miner nodes', '24. Set Interval to disconnect all miner nodes', - '30. Set Password for Mining Address', + '30. Set Password for Mining Address (--set-password \'{quoted password}\', --set-password-file {path to password.txt}', '53. Add address to banlist', '54. Load address banlist', '55. Save address banlist', diff --git a/src/node/menu/CLI-Menu-non-interactive.js b/src/node/menu/CLI-Menu-non-interactive.js index 08d033c5e..8bafaad52 100644 --- a/src/node/menu/CLI-Menu-non-interactive.js +++ b/src/node/menu/CLI-Menu-non-interactive.js @@ -1,7 +1,5 @@ /* eslint-disable */ import CLICore from './CLI-Core'; -import Blockchain from 'main-blockchain/Blockchain'; - class CLIRunner { @@ -19,9 +17,16 @@ class CLIRunner { } async run() { + // process all args, then wait for mining if applicable. + this.miningProcessStarted = false; + while (this.args.length > 0) { this.args = await this.runCommand(this.args); } + + if (this.miningProcessStarted) { + await this.waitForMiningToStop(); + } } async runCommand(args) { @@ -66,18 +71,18 @@ class CLIRunner { case '8': // Start Mining case '--mine': await CLIRunner.CORE.startMining(); - await this.waitForMiningToStop(); + this.miningProcessStarted = true; break; case '9': // Start Mining Instantly case '--mine-now': await CLIRunner.CORE.startMining(true); - await this.waitForMiningToStop(); + this.miningProcessStarted = true; break; case '10': // Mining Pool: Start Mining in a Pool case '--mine-in-pool': let url = rest.shift(); await CLIRunner.CORE.startMiningInsidePool(url, false); - await this.waitForMiningToStop(); + this.miningProcessStarted = true; break; case '11-1': // Mining Pool: Create a New Pool case '--process-payments': @@ -118,14 +123,11 @@ class CLIRunner { case '30': // Set Password case '--set-password': const actualPassword = rest.shift(); - // console.info('Password will be imported after the blockchain is initialized!'); CLIRunner.CORE.decryptWallet(actualPassword.trim().split(' ')); - // await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(actualPassword); break; case '--set-password-file': const passwordFile = rest.shift(); - // TODO: read from file. - await Blockchain.Mining.setPrivateKeyAddressForMiningAddress(passwordFile); + CLIRunner.CORE.decryptWalletFromFile(passwordFile); break; case '53': // add banlist case '--add-to-banlist': From 56f377f8448c9cbb3a971b882a900205c1054b7f Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Wed, 10 Mar 2021 08:30:54 -0700 Subject: [PATCH 054/132] Polish to readme and ./webd script --- README.md | 13 +++++++++++-- webd | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 057157506..8880932fc 100644 --- a/README.md +++ b/README.md @@ -169,8 +169,17 @@ Without `--`, the terminal menu defaults to interactive. The next parts are the commands to run in order. -Mining should be the last command used, as mining stops processing additional arguments since it starts the mining process. -This is useful for programmatically executing a mining task (such as in a container). +Alternatively, you can use the `./webd` command in the root of this project. The cli must be built first. +`./webd` assumes non-interactive, so `--` can be omitted from the command. To run interactively `npm run commands` works best. + +```shell +./webd --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here --set-password 'my 12 word password' +``` + +To display the list of commands, run: +```shell +./webd (-h|--help) +``` #### 5.3 Running Full Node diff --git a/webd b/webd index 87454e3c5..0e98b6109 100755 --- a/webd +++ b/webd @@ -13,6 +13,8 @@ function check_args { if [ $# -eq 0 ] then echo -e "${RED}No arguments supplied${NC}" + # print help + node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js -- exit 7 fi } From ac1d8ad4df6d47f8892ac02b5935d1d3ec541f56 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 13 Mar 2021 23:42:33 +0200 Subject: [PATCH 055/132] fix cli menu loading wallet first --- src/node/menu/CLI-Menu.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/node/menu/CLI-Menu.js b/src/node/menu/CLI-Menu.js index 1b85100ec..50fa1b91e 100644 --- a/src/node/menu/CLI-Menu.js +++ b/src/node/menu/CLI-Menu.js @@ -33,19 +33,21 @@ class CLI { // parse cli args this.cliArgs = process.argv; - if (!this.cliArgs.includes('--')) { - this._startInteractive(); - } else { - console.log("Non-interactive activated. Args will be read from left to right."); - this.cliArgs = this.cliArgs.splice(this.cliArgs.indexOf('--')); - if (this.cliArgs.length <= 0) { - CLI.CORE.showCommands(); + Blockchain.loadWallet().then((answer)=>{ + if (!this.cliArgs.includes('--')) { + this._startInteractive(); + } else { + console.log("Non-interactive activated. Args will be read from left to right."); + this.cliArgs = this.cliArgs.splice(this.cliArgs.indexOf('--')); + if (this.cliArgs.length <= 0) { + CLI.CORE.showCommands(); + } + console.log('Working with args: %o', this.cliArgs); + this.runner = new CLIRunner(this.cliArgs); + this.runner.run() + .then(() => process.exit()); } - console.log('Working with args: %o', this.cliArgs); - this.runner = new CLIRunner(this.cliArgs); - this.runner.run() - .then(() => process.exit()); - } + }) } @@ -144,9 +146,6 @@ class CLI { Log.info('CLI menu started', Log.LOG_TYPE.CLI_MENU); - if (Blockchain) - await Blockchain.loadWallet(); - CLI.CORE.showCommands(); AdvancedMessages.WEBD_CLI.prompt(); From d501854ed4f9d1280d0b1ab5ef3c67cabb70d99b Mon Sep 17 00:00:00 2001 From: tomonetml <34745293+tomonetml@users.noreply.github.com> Date: Mon, 15 Mar 2021 11:17:43 +0100 Subject: [PATCH 056/132] Ask for backup wallet done before Deleting a wallet from ui --- src/main-blockchain/wallet/Main-Blockchain-Wallet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main-blockchain/wallet/Main-Blockchain-Wallet.js b/src/main-blockchain/wallet/Main-Blockchain-Wallet.js index d95bdd072..4ef85baf4 100644 --- a/src/main-blockchain/wallet/Main-Blockchain-Wallet.js +++ b/src/main-blockchain/wallet/Main-Blockchain-Wallet.js @@ -576,7 +576,7 @@ class MainBlockchainWallet { let ask = true; if (bIsInteractive) - ask = await AdvancedMessages.confirm(`Are you sure you want to delete ${address}`); + ask = await AdvancedMessages.confirm(`Are you sure you want to delete ${address} , Did you backed it up?`); if (ask) { let addressToDelete = this.addresses[index]; From f34b1a1eac47c142636829cef83dbd00e82770ac Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 27 Mar 2021 08:05:28 +0200 Subject: [PATCH 057/132] Hard Fork proposed. FORCED_HALVING 2158000 --- .../global/Blockchain-Mining-Reward.js | 81 +++++++++---------- .../blockchain/Interface-Blockchain.js | 2 +- .../blocks/Interface-Blockchain-Block.js | 6 +- .../mining/Interface-Blockchain-Mining.js | 2 +- .../Mini-Blockchain-Accountant-Tree-Node.js | 2 +- ...l-Data-Block-Information-Miner-Instance.js | 2 +- .../pool-work/rewards/Payout/Pool-Payouts.js | 4 +- .../Payout/Pool-Process-Remaining-Payment.js | 2 +- src/consts/const_global.js | 4 +- .../reward-simulator/RewardSimulator.test.js | 6 +- 10 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/common/blockchain/global/Blockchain-Mining-Reward.js b/src/common/blockchain/global/Blockchain-Mining-Reward.js index fbcf364b9..2c1b07756 100644 --- a/src/common/blockchain/global/Blockchain-Mining-Reward.js +++ b/src/common/blockchain/global/Blockchain-Mining-Reward.js @@ -1,78 +1,75 @@ import WebDollarCoins from "common/utils/coins/WebDollar-Coins" +import consts from "../../../consts/const_global"; class BlockchainMiningReward{ + constructor(){ + + this.v = [1, 1867487789, 1007804769, 552321669, 307400655, 173745886, 99728963, 58133318, + 34413271, 20688253, 12630447, 7830882, 4930598, 3152722, 2047239, 1350046, 904119, + 614893, 424689, 297878, 212180, 153485, 112752, 84116, 63728, 49032, 38311, 30400, + 24497, 20047, 16660, 14061, 12051, 10490, 9272, 8323, 7588, 7025, 6604, 6306, 6113]; + + this.blocksPerCycle = 3153600 + this.blocksPerCycle2Year = 1576800 + + } + /** * Returns the entire distribution in WEBD sub-units including GENESIS(~9.9%) */ getSumReward(height){ + throw "not supported anymore. Math is required" + } + + /** + * Returns the block[height]'s reward in WEBD sub-units + */ + _getReward(height){ if (typeof height !== "number") throw {message: 'height is not defined'}; - - let marketSupply = 4156801128; - let minedDistributionAfterCycle = [0, - 18921600000, 28382400000, 33112800000, 35478000000, 36660600000, 37251900000, - 37547550000, 37695375000, 37769287500, 37806243750, 37824721875, 37833960938, - 37838580469, 37840890234, 37842045117, 37842622559, 37842911279, 37843055640, - 37843127820, 37843163910, 37843181955, 37843190977, 37843195489, 37843197744, - 37843198872 - ]; - - let blocksPerCycle = 3153600; - let cycle = Math.trunc( height / blocksPerCycle ); - - let sum = 0; - - - if (height <= 40) - for (let i = 0; i <= height; i++) - sum += this.getReward(i); + + if (height <= 40) { + return this.v[height] * WebDollarCoins.WEBD; + } else { - sum = WebDollarCoins.WEBD * (marketSupply + minedDistributionAfterCycle[cycle]) + - ( this.getReward(height) * (height % blocksPerCycle) ); - if (height <= blocksPerCycle) - sum -= 40 * this.getReward(height); + let cycleNumber = Math.trunc( height / this.blocksPerCycle ); + let reward = WebDollarCoins.WEBD * 6000 / (1 << cycleNumber); + + return Math.max(1, reward ) } - return sum; } /** * Returns the block[height]'s reward in WEBD sub-units */ - getReward(height){ + _getRewardHalving(height){ if (typeof height !== "number") throw {message: 'height is not defined'}; - let blocksPerCycle = 3153600; + height -= consts.BLOCKCHAIN.HARD_FORKS.HARD_FORKS - if (height <= 40) { + const cycleNumber = Math.trunc( height / this.blocksPerCycle2Year ) + 1; - //return WebDollarCoins.WEBD * Math.trunc( 1949770302 / Math.pow(1.01645589, 41.5 * height - height * height / 2 - 41) ); - //return WebDollarCoins.WEBD * Math.trunc( 1867487789 / Math.pow(1.01554, 41.5 * height - height * height / 2 - 41) ); + const reward = WebDollarCoins.WEBD * 3000 / (1 << cycleNumber ); - let v = [1, 1867487789, 1007804769, 552321669, 307400655, 173745886, 99728963, 58133318, - 34413271, 20688253, 12630447, 7830882, 4930598, 3152722, 2047239, 1350046, 904119, - 614893, 424689, 297878, 212180, 153485, 112752, 84116, 63728, 49032, 38311, 30400, - 24497, 20047, 16660, 14061, 12051, 10490, 9272, 8323, 7588, 7025, 6604, 6306, 6113]; + return Math.max(1, reward ) - return v[height] * WebDollarCoins.WEBD; - } - else { - let cycleNumber = Math.trunc( height / blocksPerCycle ); - let reward = WebDollarCoins.WEBD * 6000 / (1 << cycleNumber); + } - let smallestReward = 1; + getFinalReward(height){ - if (reward < smallestReward) - reward = smallestReward; - return reward; + if (height <= consts.BLOCKCHAIN.HARD_FORKS.HARD_FORKS ){ + return this._getReward(height) + } else { + return this._getRewardHalving(height) } } diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index dd506626c..241a3ea7b 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -62,7 +62,7 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ */ async includeBlockchainBlock(block, resetMining, socketsAvoidBroadcast, saveBlock = true, revertActions, showUpdate){ - if (!block.reward ) block.reward = BlockchainMiningReward.getReward(block.height); + if (!block.reward ) block.reward = BlockchainMiningReward.getFinalReward(block.height); if (!block.blockValidation ) block.blockValidation = this.createBlockValidation(); diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js index 3f0a583f9..8328d94c7 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js @@ -113,8 +113,8 @@ class InterfaceBlockchainBlock { await this._validateBlockTimeStamp(); - if (this.reward !== BlockchainMiningReward.getReward(this.height) ) - throw {message: 'reward is not right: ', myReward: this.reward, reward: BlockchainMiningReward.getReward( this.height ) }; + if (this.reward !== BlockchainMiningReward.getFinalReward(this.height) ) + throw {message: 'reward is not right: ', myReward: this.reward, reward: BlockchainMiningReward.getFinalReward( this.height ) }; if ( await this._supplementaryValidation() === false) throw {message: "supplementaryValidation failed"}; @@ -341,7 +341,7 @@ class InterfaceBlockchainBlock { if ( height ) this.height = height||0; if (reward ) this.reward = reward; - else this.reward = BlockchainMiningReward.getReward(this.height); + else this.reward = BlockchainMiningReward.getFinalReward(this.height); if (difficultyTargetPrev ) this.difficultyTargetPrev = difficultyTargetPrev; diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js index 36e88545d..b443a13bc 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js @@ -48,7 +48,7 @@ class InterfaceBlockchainMining extends InterfaceBlockchainMiningBasic{ nextBlock = await this.blockchain.blockCreator.createBlockNew(this.unencodedMinerAddress, undefined, nextTransactions ); nextBlock.timeStamp = await nextBlock.getTimestampForMining(); - nextBlock.reward = BlockchainMiningReward.getReward(nextBlock.height); + nextBlock.reward = BlockchainMiningReward.getFinalReward(nextBlock.height); await nextBlock.updateInterlink(); } catch (Exception){ diff --git a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js index 8dd577090..2e7c7e347 100644 --- a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js +++ b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js @@ -425,7 +425,7 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ if (!bIncludeMiningReward) { for (let i = 1; i <= 40; i++) - if (balance === BlockchainMiningReward.getReward(i)) + if (balance === BlockchainMiningReward.getFinalReward(i)) return; } diff --git a/src/common/mining-pools/pool/pool-management/pool-data/block-informations/Pool-Data-Block-Information-Miner-Instance.js b/src/common/mining-pools/pool/pool-management/pool-data/block-informations/Pool-Data-Block-Information-Miner-Instance.js index db4167d7c..2ce92c228 100644 --- a/src/common/mining-pools/pool/pool-management/pool-data/block-informations/Pool-Data-Block-Information-Miner-Instance.js +++ b/src/common/mining-pools/pool/pool-management/pool-data/block-informations/Pool-Data-Block-Information-Miner-Instance.js @@ -188,7 +188,7 @@ class PoolDataBlockInformationMinerInstance { let rewardDifficulty = rewardPOW.plus(rewardPOS); - let reward = rewardDifficulty.multipliedBy(ratio).multipliedBy( BlockchainMiningReward.getReward( this._lastHeight) ).multipliedBy( 1-this.poolManagement.poolSettings.poolFee).toNumber(); + let reward = rewardDifficulty.multipliedBy(ratio).multipliedBy( BlockchainMiningReward.getFinalReward( this._lastHeight) ).multipliedBy( 1-this.poolManagement.poolSettings.poolFee).toNumber(); let prevReward; if ( this.miner.referrals.referralLinkMiner && this.poolManagement.poolSettings.poolReferralFee > 0 ) { diff --git a/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Payouts.js b/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Payouts.js index c1e086db4..e6d75a683 100644 --- a/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Payouts.js +++ b/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Payouts.js @@ -111,7 +111,7 @@ class PoolPayouts{ let totalSumReward = 0; for (let blockConfirmed of blocksConfirmed) - totalSumReward += BlockchainMiningReward.getReward( blockConfirmed.block.height) * (1 - this.poolManagement.poolSettings.poolFee ); + totalSumReward += BlockchainMiningReward.getFinalReward( blockConfirmed.block.height) * (1 - this.poolManagement.poolSettings.poolFee ); let poolFork = totalSumReward - Blockchain.blockchain.accountantTree.getBalance( this.blockchain.mining.minerAddress ); @@ -152,7 +152,7 @@ class PoolPayouts{ } - let maxSumReward = BlockchainMiningReward.getReward( blockConfirmed.block.height ) * (1 - this.poolManagement.poolSettings.poolFee); + let maxSumReward = BlockchainMiningReward.getFinalReward( blockConfirmed.block.height ) * (1 - this.poolManagement.poolSettings.poolFee); let sumReward = 0; diff --git a/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Process-Remaining-Payment.js b/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Process-Remaining-Payment.js index de049ee09..325e49cfc 100644 --- a/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Process-Remaining-Payment.js +++ b/src/common/mining-pools/pool/pool-management/pool-work/rewards/Payout/Pool-Process-Remaining-Payment.js @@ -92,7 +92,7 @@ class PoolRewardsManagement{ - poolCurrentBalance -= BlockchainMiningReward.getReward(this.blockchain.blocks.length-1) * this.poolData.confirmedBlockInformations.length; + poolCurrentBalance -= BlockchainMiningReward.getFinalReward(this.blockchain.blocks.length-1) * this.poolData.confirmedBlockInformations.length; let remainingAmount = Math.floor( poolCurrentBalance - (poolCurrentBalance + poolRewardSCO) * this.poolFeePercent - this.totalRewardConfirmOther ); diff --git a/src/consts/const_global.js b/src/consts/const_global.js index bc9c2deae..ac07c1833 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -78,7 +78,7 @@ consts.BLOCKCHAIN = { POS_ACTIVATION: 567810, POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 - + FORCED_HALVING: 2158000, } }; @@ -267,7 +267,7 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.02", + VERSION: "1.3.10", VERSION_COMPATIBILITY: "1.200.3", VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", diff --git a/src/tests/utils/reward-simulator/RewardSimulator.test.js b/src/tests/utils/reward-simulator/RewardSimulator.test.js index 64c8aac00..c61859fc5 100644 --- a/src/tests/utils/reward-simulator/RewardSimulator.test.js +++ b/src/tests/utils/reward-simulator/RewardSimulator.test.js @@ -58,21 +58,21 @@ describe('RewardSimulator', () => { let smallestReward = 0.0001; let BLOCKS_PER_CYCLE = 3153600; for (let height = 41; height < BLOCKS_PER_CYCLE; height += 1024) { - reward = BlockchainMiningReward.getReward(height) / WebDollarCoins.WEBD; + reward = BlockchainMiningReward.getFinalReward(height) / WebDollarCoins.WEBD; assert(reward === 6000, "Wrong reward for bock " + height + ": " + reward.toString() + "!==3000"); } //TODO Budisteanu Shifts for (let cycle = 1; cycle <= 25; ++cycle) { let height = cycle * (BLOCKS_PER_CYCLE) - 1; - reward = BlockchainMiningReward.getReward(height) / WebDollarCoins.WEBD; + reward = BlockchainMiningReward.getFinalReward(height) / WebDollarCoins.WEBD; let targetReward = 6000 / (1 << (cycle-1)); if (targetReward < smallestReward) targetReward = smallestReward; assert(reward === targetReward, "Wrong reward for bock " + height + ": " + reward.toString() + "!==" + targetReward.toString()); height = cycle * (BLOCKS_PER_CYCLE); - reward = BlockchainMiningReward.getReward(height) / WebDollarCoins.WEBD; + reward = BlockchainMiningReward.getFinalReward(height) / WebDollarCoins.WEBD; targetReward = 6000 / (1 << cycle); if (targetReward < smallestReward) targetReward = smallestReward; From 14ad9d0befdb5a96e846ea31bc8e67dbf7de480a Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 27 Mar 2021 13:43:24 +0200 Subject: [PATCH 058/132] Hard Fork improved and getSumReward fixed --- .../global/Blockchain-Mining-Reward.js | 100 ++++++-- src/common/blockchain/simulator.js | 229 ++++++++++++++++++ src/consts/const_global.js | 3 +- 3 files changed, 308 insertions(+), 24 deletions(-) create mode 100644 src/common/blockchain/simulator.js diff --git a/src/common/blockchain/global/Blockchain-Mining-Reward.js b/src/common/blockchain/global/Blockchain-Mining-Reward.js index 2c1b07756..91109fbff 100644 --- a/src/common/blockchain/global/Blockchain-Mining-Reward.js +++ b/src/common/blockchain/global/Blockchain-Mining-Reward.js @@ -12,33 +12,93 @@ class BlockchainMiningReward{ this.blocksPerCycle = 3153600 this.blocksPerCycle2Year = 1576800 - } /** * Returns the entire distribution in WEBD sub-units including GENESIS(~9.9%) */ - getSumReward(height){ - throw "not supported anymore. Math is required" + getSumReward( initialHeight){ + + if (typeof initialHeight !== "number") + throw {message: 'height is not defined'}; + + if (initialHeight > 145000000){ + throw {message: "the constants have to be calculated"} + } + + let minedDistributionAfterCycle = [ + 41568011280000 , 171045611280000 , 194697596280000 , 206523596280000 , 212436596280000 , + 215385212280000 , 216851636280000 , 217576964280000 , 217939628280000 , 218113076280000 , + 218191916280000 , 218223452280000 , 218239220280000 , 218254988280000 , 218270756280000 , + 218286524280000 , 218302292280000 , 218318060280000 , 218333828280000 , 218349596280000 , + 218365364280000 , 218381132280000 , 218396900280000 , 218412668280000 , 218428436280000 , + 218444204280000 , 218459972280000 , 218475740280000 , 218491508280000 , 218507276280000 , + 218523044280000 , 218538812280000 , 218554580280000 , 218570348280000 , 218586116280000 , + 218601884280000 , 218617652280000 , 218633420280000 , 218649188280000 , 218664956280000 , + 218680724280000 , 218696492280000 , 218712260280000 , 218728028280000 , 218743796280000 , + 218759564280000 , 218775332280000 , 218791100280000 , 218806868280000 , 218822636280000 , + 218838404280000 , 218854172280000 , 218869940280000 , 218885708280000 , 218901476280000 , + 218917244280000 , 218933012280000 , 218948780280000 , 218964548280000 , 218980316280000 , + 218996084280000 , 219011852280000 , 219027620280000 , 219043388280000 , 219059156280000 , + 219074924280000 , 219090692280000 , 219106460280000 , 219122228280000 , 219137996280000 , + 219153764280000 , 219169532280000 , 219185300280000 , 219201068280000 , 219216836280000 , + 219232604280000 , 219248372280000 , 219264140280000 , 219279908280000 , 219295676280000 , + 219311444280000 , 219327212280000 , 219342980280000 , 219358748280000 , 219374516280000 , + 219390284280000 , 219406052280000 , 219421820280000 , 219437588280000 , 219453356280000 , + 219469124280000 , 219484892280000 , + ]; + + + let blocksPerCycle, height, cycle ; + if (initialHeight <= consts.BLOCKCHAIN.HARD_FORKS.FORCED_HALVING) { + blocksPerCycle = this.blocksPerCycle + height = initialHeight + cycle = Math.trunc( height / blocksPerCycle ); + } + else{ + blocksPerCycle = this.blocksPerCycle2Year + height = initialHeight - consts.BLOCKCHAIN.HARD_FORKS.FORCED_HALVING + cycle = Math.trunc( height / blocksPerCycle ) + 1; + if (cycle > 1 ) { + //cycle -=1 + if ( (height % blocksPerCycle) === blocksPerCycle-1 ) { + cycle += 1 + } + height += 1 + } + } + + let sum = 0; + + if (initialHeight <= 40) + for (let i = 0; i <= initialHeight; i++) + sum += this._getReward(i); + else { + + sum = ( minedDistributionAfterCycle[cycle] ) + + ( this.getFinalReward( initialHeight ) * ( height % blocksPerCycle) ); + + if (initialHeight <= blocksPerCycle) + sum -= 40 * this.getFinalReward( initialHeight ); + } + + return sum; } /** * Returns the block[height]'s reward in WEBD sub-units */ _getReward(height){ - - if (typeof height !== "number") - throw {message: 'height is not defined'}; - if (height <= 40) { return this.v[height] * WebDollarCoins.WEBD; } else { - let cycleNumber = Math.trunc( height / this.blocksPerCycle ); - let reward = WebDollarCoins.WEBD * 6000 / (1 << cycleNumber); + const cycleNumber = Math.min( 53, Math.trunc( height / this.blocksPerCycle ) + 1); + let reward = 6000 / Math.pow(2, cycleNumber - 1 ); - return Math.max(1, reward ) + const rewardFinal = Math.max(1, Math.floor(reward) ) + return WebDollarCoins.WEBD * rewardFinal } } @@ -48,25 +108,21 @@ class BlockchainMiningReward{ */ _getRewardHalving(height){ - if (typeof height !== "number") - throw {message: 'height is not defined'}; - - height -= consts.BLOCKCHAIN.HARD_FORKS.HARD_FORKS - - - const cycleNumber = Math.trunc( height / this.blocksPerCycle2Year ) + 1; - - const reward = WebDollarCoins.WEBD * 3000 / (1 << cycleNumber ); - - return Math.max(1, reward ) + height -= consts.BLOCKCHAIN.HARD_FORKS.FORCED_HALVING + const cycleNumber = Math.min( 53, Math.trunc( height / this.blocksPerCycle2Year ) + 1); + const reward = 3000 / Math.pow(2, cycleNumber ); + const rewardFinal = Math.max(1, Math.floor(reward) ) + return WebDollarCoins.WEBD * rewardFinal } getFinalReward(height){ + if (typeof height !== "number") + throw {message: 'height is not defined'}; - if (height <= consts.BLOCKCHAIN.HARD_FORKS.HARD_FORKS ){ + if (height <= consts.BLOCKCHAIN.HARD_FORKS.FORCED_HALVING ){ return this._getReward(height) } else { return this._getRewardHalving(height) diff --git a/src/common/blockchain/simulator.js b/src/common/blockchain/simulator.js new file mode 100644 index 000000000..2a16b9316 --- /dev/null +++ b/src/common/blockchain/simulator.js @@ -0,0 +1,229 @@ +class WebDollarCoinsClass{ + + constructor(){ + + this.MAX_SAFE_COINS = Number.MAX_SAFE_INTEGER; + this.MIN_SAFE_COINS = Number.MIN_SAFE_INTEGER; + + + //max safe int: 90071992547 40992 + //rewards 42000000000.00000 + + this.WEBD = 10000; + this.UNIT = 1; + } + + + validateCoinsNumber(number){ + + if (number === undefined || number === null) return false; + + if (!Number.isInteger(number)) return false; + if ( number > this.MAX_SAFE_COINS) return false; + if ( number < this.MIN_SAFE_COINS) return false; + + return true; + } + + convertToUnits(number){ + return number * this.WEBD; + } + + convertToWEBD(number){ + return number / this.WEBD; + } + +} + +var WebDollarCoins = new WebDollarCoinsClass() +var HARD_FORK_FAST_HALVING = 2158000 + +class BlockchainMiningReward{ + + constructor(){ + + this.v = [1, 1867487789, 1007804769, 552321669, 307400655, 173745886, 99728963, 58133318, + 34413271, 20688253, 12630447, 7830882, 4930598, 3152722, 2047239, 1350046, 904119, + 614893, 424689, 297878, 212180, 153485, 112752, 84116, 63728, 49032, 38311, 30400, + 24497, 20047, 16660, 14061, 12051, 10490, 9272, 8323, 7588, 7025, 6604, 6306, 6113]; + + this.blocksPerCycle = 3153600 + this.blocksPerCycle2Year = 1576800 + } + + /** + * Returns the entire distribution in WEBD sub-units including GENESIS(~9.9%) + */ + getSumReward( initialHeight){ + + if (typeof initialHeight !== "number") + throw {message: 'height is not defined'}; + + if (initialHeight > 145000000){ + throw {message: "the constants have to be calculated"} + } + + let minedDistributionAfterCycle = [ + 41568011280000 , 171045611280000 , 194697596280000 , 206523596280000 , 212436596280000 , + 215385212280000 , 216851636280000 , 217576964280000 , 217939628280000 , 218113076280000 , + 218191916280000 , 218223452280000 , 218239220280000 , 218254988280000 , 218270756280000 , + 218286524280000 , 218302292280000 , 218318060280000 , 218333828280000 , 218349596280000 , + 218365364280000 , 218381132280000 , 218396900280000 , 218412668280000 , 218428436280000 , + 218444204280000 , 218459972280000 , 218475740280000 , 218491508280000 , 218507276280000 , + 218523044280000 , 218538812280000 , 218554580280000 , 218570348280000 , 218586116280000 , + 218601884280000 , 218617652280000 , 218633420280000 , 218649188280000 , 218664956280000 , + 218680724280000 , 218696492280000 , 218712260280000 , 218728028280000 , 218743796280000 , + 218759564280000 , 218775332280000 , 218791100280000 , 218806868280000 , 218822636280000 , + 218838404280000 , 218854172280000 , 218869940280000 , 218885708280000 , 218901476280000 , + 218917244280000 , 218933012280000 , 218948780280000 , 218964548280000 , 218980316280000 , + 218996084280000 , 219011852280000 , 219027620280000 , 219043388280000 , 219059156280000 , + 219074924280000 , 219090692280000 , 219106460280000 , 219122228280000 , 219137996280000 , + 219153764280000 , 219169532280000 , 219185300280000 , 219201068280000 , 219216836280000 , + 219232604280000 , 219248372280000 , 219264140280000 , 219279908280000 , 219295676280000 , + 219311444280000 , 219327212280000 , 219342980280000 , 219358748280000 , 219374516280000 , + 219390284280000 , 219406052280000 , 219421820280000 , 219437588280000 , 219453356280000 , + 219469124280000 , 219484892280000 , + ]; + + + let blocksPerCycle, height, cycle ; + if (initialHeight <= HARD_FORK_FAST_HALVING) { + blocksPerCycle = this.blocksPerCycle + height = initialHeight + cycle = Math.trunc( height / blocksPerCycle ); + } + else{ + blocksPerCycle = this.blocksPerCycle2Year + height = initialHeight - HARD_FORK_FAST_HALVING + cycle = Math.trunc( height / blocksPerCycle ) + 1; + if (cycle > 1 ) { + //cycle -=1 + if ( (height % blocksPerCycle) === blocksPerCycle-1 ) { + cycle += 1 + } + height += 1 + } + } + + let sum = 0; + + if (initialHeight <= 40) + for (let i = 0; i <= initialHeight; i++) + sum += this._getReward(i); + else { + + sum = ( minedDistributionAfterCycle[cycle] ) + + ( this.getFinalReward( initialHeight ) * ( height % blocksPerCycle) ); + + if (initialHeight <= blocksPerCycle) + sum -= 40 * this.getFinalReward( initialHeight ); + } + + return sum; + } + + /** + * Returns the block[height]'s reward in WEBD sub-units + */ + _getReward(height){ + if (height <= 40) { + return this.v[height] * WebDollarCoins.WEBD; + } + else { + + const cycleNumber = Math.min( 53, Math.trunc( height / this.blocksPerCycle ) + 1); + let reward = 6000 / Math.pow(2, cycleNumber - 1 ); + + const rewardFinal = Math.max(1, Math.floor(reward) ) + return WebDollarCoins.WEBD * rewardFinal + } + + } + + /** + * Returns the block[height]'s reward in WEBD sub-units + */ + _getRewardHalving(height){ + + height -= HARD_FORK_FAST_HALVING + + const cycleNumber = Math.min( 53, Math.trunc( height / this.blocksPerCycle2Year ) + 1); + const reward = 3000 / Math.pow(2, cycleNumber ); + + const rewardFinal = Math.max(1, Math.floor(reward) ) + return WebDollarCoins.WEBD * rewardFinal + } + + getFinalReward(height){ + + if (typeof height !== "number") + throw {message: 'height is not defined'}; + + if (height <= HARD_FORK_FAST_HALVING ){ + return this._getReward(height) + } else { + return this._getRewardHalving(height) + } + + } + +} + +rewarder = new BlockchainMiningReward() + +// console.log ( rewarder.getSumReward(HARD_FORK_FAST_HALVING) ) + +console.log( "nextHalving: ", (3153600 - HARD_FORK_FAST_HALVING)*45/60/60/24, "days" ) + +console.log ( rewarder._getReward(HARD_FORK_FAST_HALVING) ) + +console.log('------------------') +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING-1) ) + " before hard fork2" ) //1 forced halving in 2021 +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING) ) + " before hard fork" ) //1 forced halving in 2021 +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+1) ) + " after hard fork 2021" ) +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+2) ) + " 2021" ) + +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+3153600/2 -1 ) ) + " before 2023" ) //2 forced halving in ~2023 +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+3153600/2 ) ) + " 2023" ) +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+3153600/2 +1 ) ) + " 2023" ) + +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+3153600 -1 ) ) + " before 2025" ) //2 forced halving in ~2025 +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+3153600 ) ) + " 2025" ) +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+3153600 +1 ) ) + " 2025" ) + +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+1.5*3153600 -1 ) ) + " before 2027" ) //2 forced halving halving in ~2027 +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+1.5*3153600 ) )+ " 2027" ) +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+1.5*3153600 +1 ) ) + " 2027" ) + +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+2*3153600 -1 ) ) + " before halving 2029" ) //2 forced halving halving in ~209 +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+2*3153600 ) ) + " 2029" ) +console.log ( WebDollarCoins.convertToWEBD( rewarder.getFinalReward(HARD_FORK_FAST_HALVING+2*3153600 +1 ) ) + " 2029" ) + + +let total = 0 + +let prevReward = 0 +for (let i = 0; i < Number.MAX_SAFE_INTEGER; i++){ + const reward = rewarder.getFinalReward(i) + + if (prevReward !== reward || ( reward === 10000 && ( (i-HARD_FORK_FAST_HALVING) % rewarder.blocksPerCycle2Year === 0) )){ + prevReward = reward + const out = {reward, total} + + //console.log( "i", i, "reward", reward, out, Math.trunc( i / rewarder.blocksPerCycle2Year ) + 1 ) + //console.log( total, ",", i, reward ) + //console.log( total, "," ) + } + + total += reward + + if ( total !== rewarder.getSumReward(i) ) { + console.log(i, total, rewarder.getSumReward(i)) + } + + // if (i % 10000 === 0){ + // console.log(i) + // } +} + + diff --git a/src/consts/const_global.js b/src/consts/const_global.js index ac07c1833..b94de56f6 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -61,7 +61,6 @@ consts.BLOCKCHAIN = { //forks larger than this will not be accepted IMMUTABILITY_LENGTH: 60, - }, HARD_FORKS : { @@ -267,7 +266,7 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.10", + VERSION: "1.3.11", VERSION_COMPATIBILITY: "1.200.3", VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", From fc845960c8b93ef65047f0a0d358052be697a8b8 Mon Sep 17 00:00:00 2001 From: CryptoCoinGB <45538866+CryptoCoinGB@users.noreply.github.com> Date: Thu, 1 Apr 2021 22:17:32 +0100 Subject: [PATCH 059/132] Update blockchain-bootstrap-locations.md Changed my server to run on UTC so updating guide to reflect this change from GMT. --- tutorials/blockchain-bootstrap-locations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/blockchain-bootstrap-locations.md b/tutorials/blockchain-bootstrap-locations.md index afb098af1..93a32ec6f 100644 --- a/tutorials/blockchain-bootstrap-locations.md +++ b/tutorials/blockchain-bootstrap-locations.md @@ -5,7 +5,7 @@ #### High speed backup source provided by CryptoCoinGB: http://webd-blockchain.ddns.net:9001/blockchainDB3.tar.gz -Backups are created at 00:00, 06:00, 12:00 and 18:00 GMT. +Backups are created at 00:00, 06:00, 12:00 and 18:00 UTC. If your download is initiated at these times it may fail due to the file being updated. Instructions (from within your WebDollar folder): From 17fb10fddfb5addbfbf4ab185dd4195c6a0f1708 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 19 Apr 2021 21:34:24 +0300 Subject: [PATCH 060/132] fix CLI --- src/node/menu/CLI-Core.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js index cd16356f7..8e9f33d4e 100644 --- a/src/node/menu/CLI-Core.js +++ b/src/node/menu/CLI-Core.js @@ -37,7 +37,7 @@ export class CLICore { return new Promise(async (resolve) => { - let addressId = await this._chooseAddress(id); + let addressId = await this._chooseAddress(); if (addressId < 0) { console.warn("You must enter a valid number."); @@ -52,10 +52,8 @@ export class CLICore { let addressPath = await AdvancedMessages.input('Enter path for saving the transaction:'); let wantToPropagate = await AdvancedMessages.input('Do you want to propagate now y/n?:'); - if (wantToPropagate.toUpperCase().trim() === 'Y' ? true : false) - wantToPropagate = true; - else - wantToPropagate = false; + if (wantToPropagate.toUpperCase().trim() === 'Y') wantToPropagate = true; + else wantToPropagate = false; let feeToSend = Blockchain.Transactions.wizard.calculateFeeSimple(amountToSend); @@ -115,7 +113,7 @@ export class CLICore { } - async _chooseAddress(id = undefined) { + async _chooseAddress(id ) { await this.listAddresses(); From 76de37869b6adb7cb19af5011a050f2677c04095 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 20 Apr 2021 14:53:04 +0300 Subject: [PATCH 061/132] consts test --- .../blockchain/Interface-Blockchain.js | 3 --- src/consts/const_global.js | 12 ++++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index b9b0848c8..40da95da7 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -181,9 +181,6 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ if (height === -1) return BlockchainGenesis.difficultyTarget; if ( height === consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1) return BlockchainGenesis.difficultyTargetPOS; - //TODO MUST BE REMOVED FOR MAIN NET!!!! - if (height === consts.BLOCKCHAIN.HARD_FORKS.POS100_POW_LOWER_DIFFICULTY_HEIGHT ) return consts.BLOCKCHAIN.HARD_FORKS.POS100_POW_LOWER_DIFFICULTY; - if (POSRecalculation && height >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1){ if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { diff --git a/src/consts/const_global.js b/src/consts/const_global.js index e77388434..723a0c5be 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,11 +79,7 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 FORCED_HALVING: 2158000, - POS100_ACTIVATION: 1750000, //it needs to be % 100 === 0 - - //TODO MUST BE REMOVED FOR MAIN NET!!!! - POS100_POW_LOWER_DIFFICULTY_HEIGHT: 1749990, // lower the difficulty of the forked chain. It must be % 90 === 0 and first POW block after the hard fork - POS100_POW_LOWER_DIFFICULTY: new Buffer ( "00000112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex" ), //hard difficulty + POS100_ACTIVATION: 2167000, //it needs to be % 100 === 0 } @@ -273,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.11", + VERSION: "2.0.0", - VERSION_COMPATIBILITY: "1.3.1", - VERSION_COMPATIBILITY_POOL_MINERS: "1.3.1", + VERSION_COMPATIBILITY: "2.0.0", + VERSION_COMPATIBILITY_POOL_MINERS: "2.0.0", VERSION_COMPATIBILITY_UPDATE: "", From 7dc13dcb755e11242991124e3b918dcf4c047267 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Wed, 28 Apr 2021 14:36:57 -0600 Subject: [PATCH 062/132] Await wallet decryption before moving on --- .../mining/Interface-Blockchain-Mining-Basic.js | 2 +- src/node/menu/CLI-Core.js | 14 +++++--------- src/node/menu/CLI-Menu-non-interactive.js | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js index 27f96f553..efb6a31e2 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Basic.js @@ -229,7 +229,7 @@ class InterfaceBlockchainMiningBasic { } // if it is in terminal asking for the password (required in POS) - async setPrivateKeyAddressForMiningAddress(actualPassword){ + async setPrivateKeyAddressForMiningAddress(actualPassword) { let foundAddress = Blockchain.Wallet.getAddress(this.minerAddress); diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js index 8e9f33d4e..7b90d7a97 100644 --- a/src/node/menu/CLI-Core.js +++ b/src/node/menu/CLI-Core.js @@ -646,11 +646,8 @@ export class CLICore { * @param password - the 12 word array of strings */ decryptWallet(password) { - new Promise((resolve, reject) => { - Blockchain.Mining.setPrivateKeyAddressForMiningAddress(password) - .then(() => resolve()) - .catch(() => reject()); - }).then(() => console.info('Done unlocking password protected wallet.')) + return Blockchain.Mining.setPrivateKeyAddressForMiningAddress(password) + .then(() => console.info('Done unlocking password protected wallet.')) .catch(err => console.error(`Failed to unlock password protected wallet. ${err}`)); } @@ -659,10 +656,9 @@ export class CLICore { * @param filename */ decryptWalletFromFile(filename) { - FileSystem.readFile(filename, 'utf8', (err, password) => { - if (err) throw err; - this.decryptWallet(password.trim().split(' ')); - }); + console.warn(`Reading password from ${filename}`) + const password = FileSystem.readFileSync(filename, 'utf8'); + return this.decryptWallet(password.trim().split(' ')); } showCommands() { diff --git a/src/node/menu/CLI-Menu-non-interactive.js b/src/node/menu/CLI-Menu-non-interactive.js index 8bafaad52..a67fb003c 100644 --- a/src/node/menu/CLI-Menu-non-interactive.js +++ b/src/node/menu/CLI-Menu-non-interactive.js @@ -123,11 +123,11 @@ class CLIRunner { case '30': // Set Password case '--set-password': const actualPassword = rest.shift(); - CLIRunner.CORE.decryptWallet(actualPassword.trim().split(' ')); + await CLIRunner.CORE.decryptWallet(actualPassword.trim().split(' ')); break; case '--set-password-file': const passwordFile = rest.shift(); - CLIRunner.CORE.decryptWalletFromFile(passwordFile); + await CLIRunner.CORE.decryptWalletFromFile(passwordFile); break; case '53': // add banlist case '--add-to-banlist': From fdecb286e8faf8731d6c44ea7aad7be80ddc5d6f Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Thu, 29 Apr 2021 00:09:37 -0600 Subject: [PATCH 063/132] Fixing failing reward simulator test --- .../reward-simulator/RewardSimulator.test.js | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/tests/utils/reward-simulator/RewardSimulator.test.js b/src/tests/utils/reward-simulator/RewardSimulator.test.js index c61859fc5..19aecb4a6 100644 --- a/src/tests/utils/reward-simulator/RewardSimulator.test.js +++ b/src/tests/utils/reward-simulator/RewardSimulator.test.js @@ -6,22 +6,22 @@ import WebDollarCoins from "common/utils/coins/WebDollar-Coins"; describe('RewardSimulator', () => { it('reward simulator test - general formula', ()=>{ - + let TIME_PER_BLOCK = 40; //Number of seconds per block let MINING_YEARS = 100; //Number of total mining years let CYCLE_PERIOD = 4; //Cycle period in years let TOTAL_SUPPLY = 42000000000; //Total Supply WEBDs let GENESIS_PERCENT = 9.99 / 100; //9.99% let INITIAL_REWARD_PER_BLOCK = 6000; - - let GENESIS_SUPPLY = 4156801128; //TOTAL_SUPPLY * GENESIS_PERCENT; + + let GENESIS_SUPPLY = 4156801128; //TOTAL_SUPPLY * GENESIS_PERCENT; let MINING_REWARD = TOTAL_SUPPLY - GENESIS_SUPPLY; - + let MINING_CYCLES = MINING_YEARS / CYCLE_PERIOD; //Number of cycles let BLOCKS_PER_CYCLE = (3600 / TIME_PER_BLOCK) * 24 * 365 * CYCLE_PERIOD; //blocks per cycle - + let REWARD_PER_CYCLE; // The reward per cycle: X + X/2 + X/4 + X/8 + ... + X/2^(N-1) === TOTAL_SUPPLY - + let MINED_SUPPPLY = 0.0; //first mining cycle mines >= half of total supply for (REWARD_PER_CYCLE = MINING_REWARD/2; REWARD_PER_CYCLE < MINING_REWARD; ++REWARD_PER_CYCLE) { @@ -31,7 +31,7 @@ describe('RewardSimulator', () => { if (MINED_SUPPPLY >= MINING_REWARD) break; } - + let STARTING_REWARD = REWARD_PER_CYCLE / BLOCKS_PER_CYCLE; console.log("Blocks per cycle:", BLOCKS_PER_CYCLE); @@ -41,7 +41,7 @@ describe('RewardSimulator', () => { console.log("Starting reward:", STARTING_REWARD); //console.log("Total supply for Y years, CYCLE_PERIOD year cycle, T seconds per block, STARTING_REWARD starting reward: ~STARTING_REWARD*(3600/T)*24*365*4*2"); //console.log("Simplified formula and more accurate(using 1.9999999403953552 instead of 2): 252288000 * STARTING_REWARD / T"); - + STARTING_REWARD = 6000; let MINED_REWARD = 0.0; for (let i = 0; i < MINING_CYCLES; ++i){ @@ -55,13 +55,21 @@ describe('RewardSimulator', () => { it('reward simulator test - particular formula', ()=>{ let reward = 0; - let smallestReward = 0.0001; - let BLOCKS_PER_CYCLE = 3153600; + // a forced reward quartering occured at this block. + const BLOCKS_PER_CYCLE = 2158000; for (let height = 41; height < BLOCKS_PER_CYCLE; height += 1024) { reward = BlockchainMiningReward.getFinalReward(height) / WebDollarCoins.WEBD; - assert(reward === 6000, "Wrong reward for bock " + height + ": " + reward.toString() + "!==3000"); + assert(reward === 6000, "Wrong reward for block " + height + ": " + reward.toString() + "!==3000"); } + }); + + // TODO: This test is not currently relevant due to the forced reward quartering. + xit('should compute the correct reward for each cycle', () => { + const smallestReward = 0.0001; + let reward = 0; + const BLOCKS_PER_CYCLE = 2158000; + //TODO Budisteanu Shifts for (let cycle = 1; cycle <= 25; ++cycle) { let height = cycle * (BLOCKS_PER_CYCLE) - 1; @@ -69,44 +77,43 @@ describe('RewardSimulator', () => { let targetReward = 6000 / (1 << (cycle-1)); if (targetReward < smallestReward) targetReward = smallestReward; - assert(reward === targetReward, "Wrong reward for bock " + height + ": " + reward.toString() + "!==" + targetReward.toString()); + assert(reward === targetReward, "Wrong reward for block " + height + ": " + reward.toString() + "!==" + targetReward.toString()); height = cycle * (BLOCKS_PER_CYCLE); reward = BlockchainMiningReward.getFinalReward(height) / WebDollarCoins.WEBD; targetReward = 6000 / (1 << cycle); if (targetReward < smallestReward) targetReward = smallestReward; - assert(reward === targetReward, "Wrong reward for bock " + height + ": " + reward.toString() + "!==" + targetReward.toString()); + assert(reward === targetReward, "Wrong reward for block " + height + ": " + reward.toString() + "!==" + targetReward.toString()); } - }); - + it('reward simulator test - weekly reward reduction', ()=>{ let TOTAL_SUPPLY = 42000000000; - + let GENESIS_PERCENT = 9.99 / 100; //9.99% - let GENESIS_SUPPLY = TOTAL_SUPPLY * GENESIS_PERCENT; - + let GENESIS_SUPPLY = TOTAL_SUPPLY * GENESIS_PERCENT; + let MINING_REWARD = TOTAL_SUPPLY - GENESIS_SUPPLY; let INITIAL_REWARD_PER_BLOCK = 6000; - + console.log("GENESIS_SUPPLY=", GENESIS_SUPPLY); console.log("MINING_REWARD=", MINING_REWARD); - + //BEGIN SIMUALTION let weeksPerYear = 52; let numWeeks = (365 * 100 + 25) / 7; //~ 52 * 100; 25 is from 366-day years let minedWebd = 0; let actualReward = INITIAL_REWARD_PER_BLOCK; let reducingFactor = 0.24 / 100; //every week we reduce the reward by 1% - + for (let i = 0; i < numWeeks; ++i) { minedWebd += actualReward * 3 * 60 * 24 * 7; //sum the current week's reward actualReward -= actualReward * reducingFactor; //reduce the reward per block with reducingFactor % } - + console.log("WEBD mined after 100 years=", minedWebd); }); -}); \ No newline at end of file +}); From ca2ea6bdc9dde6009bf3b3d50e665917fdfdb340 Mon Sep 17 00:00:00 2001 From: Eric B Date: Thu, 29 Apr 2021 21:36:50 -0400 Subject: [PATCH 064/132] Catch pool URLs with multiple versions & provide better hints for pool URL entry --- src/common/mining-pools/common/Pools-Utils.js | 9 ++++++++- src/node/menu/CLI-Core.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/mining-pools/common/Pools-Utils.js b/src/common/mining-pools/common/Pools-Utils.js index 71c5df5f4..71dc9199c 100644 --- a/src/common/mining-pools/common/Pools-Utils.js +++ b/src/common/mining-pools/common/Pools-Utils.js @@ -182,8 +182,15 @@ class PoolsUtils { url = this.substrNext(url); if (version !== "") version = parseInt(version); + let poolName = this.substr(url) ; + // In the latest (4/2021) version of webdollar UI, the version is listed + // twice which offsets this parser incorrectly. + if (poolName == version) { + url = this.substrNext(url); + poolName = this.substr(url); + } poolName = decodeURIComponent(poolName); url = this.substrNext(url); @@ -283,4 +290,4 @@ class PoolsUtils { } -export default new PoolsUtils(); \ No newline at end of file +export default new PoolsUtils(); diff --git a/src/node/menu/CLI-Core.js b/src/node/menu/CLI-Core.js index 7b90d7a97..48f0a2a9d 100644 --- a/src/node/menu/CLI-Core.js +++ b/src/node/menu/CLI-Core.js @@ -431,7 +431,7 @@ export class CLICore { if (getNewLink) { - miningPoolLink = !!url ? url : await AdvancedMessages.input('Enter the new mining pool link: '); + miningPoolLink = !!url ? url : await AdvancedMessages.input('Pool URLs should look like:\n https://webdollar.io/pool/1/1/MyPoolName//https:$$mybigpool.com\nEnter the new mining pool link: '); Log.info('Your new MiningPool is : ' + miningPoolLink, Log.LOG_TYPE.info); } From b381bdad9f913b0a4da368d329f5b8aa109d28a1 Mon Sep 17 00:00:00 2001 From: Eric B Date: Tue, 4 May 2021 09:12:56 -0400 Subject: [PATCH 065/132] Better logic for copying argon2/* --- build-argon2.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/build-argon2.sh b/build-argon2.sh index 49a4efb2c..248630091 100755 --- a/build-argon2.sh +++ b/build-argon2.sh @@ -652,11 +652,17 @@ if [[ $is_Linux == Linux ]]; then echo "$showok CPU folder inside dist_bundle exists!" echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/ + if [ -d argon2/.libs ]; then + cp -a argon2/.libs dist_bundle/CPU/ + fi else if [[ ! -d dist_bundle/CPU ]]; then echo "$showerror CPU folder inside dist_bundle not found!" echo "$showexecute Creating one now..." && mkdir dist_bundle/CPU echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/ + if [ -d argon2/.libs ]; then + cp -a argon2/.libs dist_bundle/CPU/ + fi fi fi @@ -684,11 +690,17 @@ if [[ $is_Linux == Linux ]]; then echo "$showok CPU folder inside dist_bundle exists!" echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/ + if [ -d argon2/.libs ]; then + cp -a argon2/.libs dist_bundle/CPU/ + fi else if [[ ! -d dist_bundle/CPU ]]; then echo "$showerror CPU folder inside dist_bundle not found!" echo "$showexecute Creating one now..." && mkdir dist_bundle/CPU echo "$showexecute Copying argon2/* files to dist_bundle/CPU" && cp -a argon2/* dist_bundle/CPU/ + if [ -d argon2/.libs ]; then + cp -a argon2/.libs dist_bundle/CPU/ + fi fi fi else @@ -721,11 +733,17 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA echo "$showok GPU folder inside dist_bundle exists!" echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ + if [ -d argon2-gpu/.libs ]; then + cp -a argon2gpu/.libs dist_bundle/GPU/ + fi else if [[ ! -d dist_bundle/GPU ]]; then echo "$showerror GPU folder inside dist_bundle not found!" echo "$showexecute Creating one now..." && mkdir dist_bundle/GPU echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ + if [ -d argon2-gpu/.libs ]; then + cp -a argon2gpu/.libs dist_bundle/GPU/ + fi fi fi @@ -750,11 +768,17 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA echo "$showok GPU folder inside dist_bundle exists!" echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ + if [ -d argon2-gpu/.libs ]; then + cp -a argon2gpu/.libs dist_bundle/GPU/ + fi else if [[ ! -d dist_bundle/GPU ]]; then echo "$showerror GPU folder inside dist_bundle not found!" echo "$showexecute Creating one now..." && mkdir dist_bundle/GPU echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ + if [ -d argon2-gpu/.libs ]; then + cp -a argon2gpu/.libs dist_bundle/GPU/ + fi fi fi else From 7b958ac253227ef7b1e95c312d6d6ad2a743d846 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 4 May 2021 16:59:46 +0300 Subject: [PATCH 066/132] api returns transactions list --- .../blocks/Interface-Blockchain-Block-Data.js | 9 ++++++++- .../blocks/Interface-Blockchain-Block.js | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js index 69d921c94..3e2f20feb 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js @@ -119,9 +119,16 @@ class InterfaceBlockchainBlockData { } toJSON(){ + + const transactions = []; + for (const tx of this.transactions.transactions ){ + transactions.push(tx.txId.toString('hex')) + } + return { minerAddress: Buffer.isBuffer(this.minerAddress) ? this.minerAddress.toString("hex") : '', hashData: Buffer.isBuffer(this.hashData) ? this.hashData.toString("hex") : '', + transactions, }; } @@ -151,4 +158,4 @@ class InterfaceBlockchainBlockData { } } -export default InterfaceBlockchainBlockData; \ No newline at end of file +export default InterfaceBlockchainBlockData; diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js index 8328d94c7..ed44c3731 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js @@ -522,7 +522,6 @@ class InterfaceBlockchainBlock { getBlockHeader(){ return { - version: this.version, height: this.height, hash: this.hash, From edca423b28c12b96d4fdd8dfc1066519f56eb2f2 Mon Sep 17 00:00:00 2001 From: Eric B Date: Tue, 4 May 2021 12:16:37 -0400 Subject: [PATCH 067/132] typo in cp -a commands for argon2-gpu --- build-argon2.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-argon2.sh b/build-argon2.sh index 248630091..02c3f6872 100755 --- a/build-argon2.sh +++ b/build-argon2.sh @@ -734,7 +734,7 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA echo "$showok GPU folder inside dist_bundle exists!" echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ if [ -d argon2-gpu/.libs ]; then - cp -a argon2gpu/.libs dist_bundle/GPU/ + cp -a argon2-gpu/.libs dist_bundle/GPU/ fi else if [[ ! -d dist_bundle/GPU ]]; then @@ -742,7 +742,7 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA echo "$showexecute Creating one now..." && mkdir dist_bundle/GPU echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ if [ -d argon2-gpu/.libs ]; then - cp -a argon2gpu/.libs dist_bundle/GPU/ + cp -a argon2-gpu/.libs dist_bundle/GPU/ fi fi fi @@ -769,7 +769,7 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA echo "$showok GPU folder inside dist_bundle exists!" echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ if [ -d argon2-gpu/.libs ]; then - cp -a argon2gpu/.libs dist_bundle/GPU/ + cp -a argon2-gpu/.libs dist_bundle/GPU/ fi else if [[ ! -d dist_bundle/GPU ]]; then @@ -777,7 +777,7 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA echo "$showexecute Creating one now..." && mkdir dist_bundle/GPU echo "$showexecute Copying argon2-gpu/* files to dist_bundle/GPU" && cp -a argon2-gpu/* dist_bundle/GPU/ if [ -d argon2-gpu/.libs ]; then - cp -a argon2gpu/.libs dist_bundle/GPU/ + cp -a argon2-gpu/.libs dist_bundle/GPU/ fi fi fi From c19548b0cd8b42373801acec6a5a45da162faf2b Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 5 May 2021 15:18:04 +0300 Subject: [PATCH 068/132] api /blocks_complete/at/:block introduced --- .../blocks/Interface-Blockchain-Block-Data.js | 8 ++++++-- .../blocks/Interface-Blockchain-Block.js | 2 +- .../node-server/API-router/Node-API-Router.js | 6 ++++-- .../API/public/Node-API-Public-Blocks.js | 19 ++++++++++++++++++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js index 3e2f20feb..618d60d98 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Data.js @@ -118,11 +118,15 @@ class InterfaceBlockchainBlockData { } - toJSON(){ + toJSON(includeTransactions){ const transactions = []; for (const tx of this.transactions.transactions ){ - transactions.push(tx.txId.toString('hex')) + if (!includeTransactions) { + transactions.push( tx.txId.toString('hex') ) + } else { + transactions.push( tx.toJSON() ) + } } return { diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js index ed44c3731..d26f27b81 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js @@ -214,7 +214,7 @@ class InterfaceBlockchainBlock { version: this.version, hashPrev: this.hashPrev ? this.hashPrev.toString("hex") : '', hashChainPrev: this.hashChainPrev ? this.hashChainPrev.toString("hex") : '', - data: this.data ? this.data.toJSON() : '', + data: this.data ? this.data.toJSON(...arguments) : '', nonce: this.nonce, timeStamp: this.timeStamp, difficulty: this.difficultyTarget ? this.difficultyTarget.toString("hex") : '', diff --git a/src/node/sockets/node-server/API-router/Node-API-Router.js b/src/node/sockets/node-server/API-router/Node-API-Router.js index 9e7871ace..9ab167f77 100644 --- a/src/node/sockets/node-server/API-router/Node-API-Router.js +++ b/src/node/sockets/node-server/API-router/Node-API-Router.js @@ -55,12 +55,14 @@ class NodeAPIRouter{ if (process.env.WALLET_SECRET_URL && typeof process.env.WALLET_SECRET_URL === "string" && process.env.WALLET_SECRET_URL.length >= 30) { + this._addRoute( process.env.WALLET_SECRET_URL+'/blocks_complete/at/:block', NodeAPIPublicBlocks.blockComplete, nodeApiType, 20, app, prefix, middleWare ); + this._addRoute(process.env.WALLET_SECRET_URL+'/mining/balance', NodeAPIPrivate.minerBalance, nodeApiType, 100, app, prefix, middleWare ); this._addRoute(process.env.WALLET_SECRET_URL+'/wallets/import/:address/:publicKey/:privateKey', NodeAPIPrivate.walletImport, nodeApiType, 100, app, prefix, middleWare ); this._addRoute(process.env.WALLET_SECRET_URL+'/wallets/create-transaction/:from/:to/:amount/:fee', NodeAPIPrivate.walletCreateTransaction, nodeApiType, 100, app, prefix, middleWare ); - + this._addRoute(process.env.WALLET_SECRET_URL+'/wallets/export', NodeAPIPrivate.walletExport, nodeApiType, 100, app, prefix, middleWare ); this._addRoute(process.env.WALLET_SECRET_URL+'/wallets/create-wallet', NodeAPIPrivate.walletCreate, nodeApiType, 100, app, prefix, middleWare ); @@ -111,7 +113,7 @@ class NodeAPIRouter{ this._addRoute( 'subscribe/address/transactions', NodeAPICallbacks.addressTransactionsSubscribe.bind(NodeAPICallbacks), nodeApiType, 100 , app, prefix, middleWare ); } - + } export default new NodeAPIRouter(); diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js index 1cd87f940..71b5aa899 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js @@ -51,7 +51,24 @@ class NodeAPIPublicBlocks{ } + async blockComplete(req, res){ + + let index = req.block; + + try { + + if (index < Blockchain.blockchain.blocksStartingPoint) throw {message: "Invalid index."}; + if (index > Blockchain.blockchain.blocks.length) throw {message: "Block not found."}; + + return {result: true, block: (await Blockchain.blockchain.getBlock(index)).toJSON(true)} + + } catch (exception) { + return {result: false, message: "Invalid Block"}; + } + + } + } -export default new NodeAPIPublicBlocks(); \ No newline at end of file +export default new NodeAPIPublicBlocks(); From 7df7d659a754f267fca8234aba1011cebf2ba9ea Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 5 May 2021 15:19:56 +0300 Subject: [PATCH 069/132] change version --- src/consts/const_global.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index b94de56f6..bca9acb78 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -266,7 +266,7 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.11", + VERSION: "1.3.12", VERSION_COMPATIBILITY: "1.200.3", VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", From 11ec8a695bc757e6159aaa5b1449036926f8157a Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 5 May 2021 19:27:45 +0300 Subject: [PATCH 070/132] fix to json --- .../ppow-blockchain/blocks/PPoW-Blockchain-Block.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js b/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js index 4738f1823..22527cc66 100644 --- a/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js +++ b/src/common/blockchain/ppow-blockchain/blocks/PPoW-Blockchain-Block.js @@ -266,7 +266,8 @@ class PPoWBlockchainBlock extends InterfaceBlockchainBlock{ } toJSON(){ - let answer = InterfaceBlockchainBlock.prototype.toJSON.call(this); + + let answer = InterfaceBlockchainBlock.prototype.toJSON.call(this, ...arguments ); answer.interlinks = this._interlinksToJSON(this.interlink); @@ -319,4 +320,4 @@ class PPoWBlockchainBlock extends InterfaceBlockchainBlock{ } -export default PPoWBlockchainBlock; \ No newline at end of file +export default PPoWBlockchainBlock; From 626d7724ec396b51d9d83c51057b592ec7fa4109 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 8 May 2021 11:27:34 +0300 Subject: [PATCH 071/132] changes API --- .../Interface-Blockchain-Transactions-Wizard.js | 6 ++++-- .../sockets/node-server/API-router/Node-API-Router.js | 2 +- src/node/sockets/node-server/API/Node-API-Private.js | 11 ++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js b/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js index e8e7b2b32..155985e9d 100644 --- a/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js +++ b/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js @@ -28,8 +28,9 @@ class InterfaceBlockchainTransactionsWizard{ let process = await this.validateTransaction( address, toAddress, toAmount, fee, currencyTokenId, password, timeLock, undefined); - if(process.result) - return await this.propagateTransaction( process.signature , process.transaction ); + if (process.result) { + return this.propagateTransaction(process.signature, process.transaction); + } else return process; @@ -209,6 +210,7 @@ class InterfaceBlockchainTransactionsWizard{ result: true, message: "Your transaction is pending...", signature: signature, + txId: transaction.txId, transaction: transaction, } diff --git a/src/node/sockets/node-server/API-router/Node-API-Router.js b/src/node/sockets/node-server/API-router/Node-API-Router.js index 9ab167f77..57751525a 100644 --- a/src/node/sockets/node-server/API-router/Node-API-Router.js +++ b/src/node/sockets/node-server/API-router/Node-API-Router.js @@ -68,7 +68,7 @@ class NodeAPIRouter{ this._addRoute(process.env.WALLET_SECRET_URL+'/wallets/create-wallet', NodeAPIPrivate.walletCreate, nodeApiType, 100, app, prefix, middleWare ); } - + // Return address info: balance, blocks mined and transactions // this._addRoute( 'address/:address', NodeAPIPublicAddresses.addressInfo, nodeApiType, 3 , app, prefix, middleWare ); diff --git a/src/node/sockets/node-server/API/Node-API-Private.js b/src/node/sockets/node-server/API/Node-API-Private.js index ac182015b..36e07a430 100644 --- a/src/node/sockets/node-server/API/Node-API-Private.js +++ b/src/node/sockets/node-server/API/Node-API-Private.js @@ -49,7 +49,7 @@ class NodeAPIPrivate{ } async walletCreateTransaction(req, res){ - + var from; var to; @@ -72,10 +72,15 @@ class NodeAPIPrivate{ let fee = parseFloat(req.fee) * WebDollarCoins.WEBD; amount = Math.round(amount) fee = Math.round(fee) - let result = await Blockchain.Transactions.wizard.createTransactionSimple(from, to, amount, fee); - return result; + let out = await Blockchain.Transactions.wizard.createTransactionSimple(from, to, amount, fee); + if (out && out.result ) { + out.signature = out.signature.toString('hex') + out.txId = out.txId.toString('hex') + } + + return result; } From 2e63728865995586f5346c673d8eaf554584d4ce Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 8 May 2021 12:36:36 +0300 Subject: [PATCH 072/132] changes API fix --- src/node/sockets/node-server/API/Node-API-Private.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/sockets/node-server/API/Node-API-Private.js b/src/node/sockets/node-server/API/Node-API-Private.js index 36e07a430..44090f9ae 100644 --- a/src/node/sockets/node-server/API/Node-API-Private.js +++ b/src/node/sockets/node-server/API/Node-API-Private.js @@ -80,7 +80,7 @@ class NodeAPIPrivate{ out.txId = out.txId.toString('hex') } - return result; + return out; } From 0c51d4748c845d663c65161143b41105016277e7 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 12 May 2021 23:45:39 +0300 Subject: [PATCH 073/132] removeEncryptionAddress function implementation --- .../addresses/Interface-Blockchain-Address.js | 15 +++++----- .../wallet/Main-Blockchain-Wallet.js | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js b/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js index 2e0620278..521eec415 100644 --- a/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js +++ b/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js @@ -57,16 +57,15 @@ class InterfaceBlockchainAddress{ if ( !password ) return data; - else { - let encr = null; - if (Array.isArray(password)) - encr = MultiSig.getMultiAESEncrypt(data, password); - else - encr = WebDollarCrypto.encryptAES(data, password); + let encr ; - return Buffer.from(encr); - } + if (Array.isArray(password)) + encr = MultiSig.getMultiAESEncrypt(data, password); + else + encr = WebDollarCrypto.encryptAES(data, password); + + return Buffer.from(encr); } /** diff --git a/src/main-blockchain/wallet/Main-Blockchain-Wallet.js b/src/main-blockchain/wallet/Main-Blockchain-Wallet.js index 4ef85baf4..01d098a10 100644 --- a/src/main-blockchain/wallet/Main-Blockchain-Wallet.js +++ b/src/main-blockchain/wallet/Main-Blockchain-Wallet.js @@ -497,6 +497,35 @@ class MainBlockchainWallet { } + async removeEncryptionAddress(address, oldPassword ){ + if (typeof address === "object" && address.hasOwnProperty("address")) + address = address.address; + + address = this.getAddress(address); + + if (await this.isAddressEncrypted(address) === false ) + return false + + if ( oldPassword === undefined) { + oldPassword = await InterfaceBlockchainAddressHelper.askForPassword(); + if (!oldPassword ) + return false; + } + + let privateKey = await address._getPrivateKey(oldPassword); + + try { + + if (InterfaceBlockchainAddressHelper.validatePrivateKeyWIF(privateKey)) + return (await address.savePrivateKey(privateKey, undefined)); + + } catch (exception) { + + AdvancedMessages.alert('Your old password is incorrect!', "Password Error", "error", 5000); + return false; + } + } + async deleteAddress(address, bIsInteractive = true, password = null){ if (typeof address === 'object' && address.hasOwnProperty('address')) From 8a51a7e2fd95e5781813dc9cc8d9d59a67bef29e Mon Sep 17 00:00:00 2001 From: Constantin Busuioceanu <39584380+cbusuioceanu@users.noreply.github.com> Date: Thu, 20 May 2021 23:01:07 +0300 Subject: [PATCH 074/132] update for build-argon2.sh & install-miner.sh - small changes --- build-argon2.sh | 38 ++++++++++++++++++++++---------------- install-miner.sh | 4 ++-- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/build-argon2.sh b/build-argon2.sh index 02c3f6872..040097718 100755 --- a/build-argon2.sh +++ b/build-argon2.sh @@ -24,19 +24,19 @@ whitebg=$(tput setab 7 && tput bold) stand=$(tput sgr0) ### System dialog VARS -showinfo="$green[info]$stand" -showerror="$red[error]$stand" -showexecute="$yellow[running]$stand" -showok="$magenta[OK]$stand" -showdone="$blue[DONE]$stand" -showinput="$cyan[input]$stand" -showwarning="$red[warning]$stand" -showremove="$green[removing]$stand" -shownone="$magenta[none]$stand" -redhashtag="$redbg$white#$stand" -abortte="$cyan[abort to Exit]$stand" -showport="$yellow[PORT]$stand" -show_hint="$green[hint]$stand" +showinfo="${green}[info]$stand" +showerror="${red}[error]$stand" +showexecute="${yellow}[running]$stand" +showok="${magenta}[OK]$stand" +showdone="${blue}[DONE]$stand" +showinput="${cyan}[input]$stand" +showwarning="${red}[warning]$stand" +showremove="${green}[removing]$stand" +shownone="${magenta}[none]$stand" +redhashtag="${redbg}${white}#$stand" +abortte="${cyan}[abort to Exit]$stand" +showport="${yellow}[PORT]$stand" +show_hint="${green}[hint]$stand" ## ### @@ -73,6 +73,7 @@ export show_hint ### ### GENERAL_VARS +# shellcheck disable=SC2003 is_Linux=$(expr substr "$(uname -s)" 1 5) get_const_global="src/consts/const_global.js" ### @@ -100,10 +101,14 @@ if [[ $is_Linux == Linux ]]; then if cat /etc/*release | grep -q -o -m 1 Ubuntu; then # check cmake - if cmake --version | grep "3.10.*" > /dev/null || cmake --version | grep "3.12.*" > /dev/null; then + if cmake --version | grep "3.*.*" > /dev/null || cmake --version | grep "3.12.*" > /dev/null; then echo "$showok ${blue}cmake$stand is already installed!" + elif ! which cmake; then + + echo "$showexecute Installing cmake..." && sudo apt install -y cmake + elif ! cmake --version | grep "3.5.*" > /dev/null; then if [[ $(cat /etc/*release | grep -m 1 VERSION | cut -d '"' -f2 | awk '{print$1}') == 18* ]]; then @@ -623,7 +628,7 @@ fi ### ASK_USER_FUNCTION_END ### NODE_WEBDOLLAR_START -if [[ $(grep "name" package.json | sed s'/[",]//g' | awk '{print $2}') == node-webdollar ]]; then +if [[ $(grep "name" package.json | sed s'/[",]//g' | awk '{print $2}') =~ [node-webdollarwebdollar] ]]; then if [[ $is_Linux == Linux ]]; then @@ -736,6 +741,7 @@ if [[ $(lspci | grep VGA | grep -m 1 "controller:" | awk '{print$5}') == NVIDIA if [ -d argon2-gpu/.libs ]; then cp -a argon2-gpu/.libs dist_bundle/GPU/ fi + else if [[ ! -d dist_bundle/GPU ]]; then echo "$showerror GPU folder inside dist_bundle not found!" @@ -822,7 +828,7 @@ else ### Node else if [[ ! $(ls -d argon2) == argon2 ]]; then echo "$showerror You are not inside ${yellow}Node-WebDollar$stand folder." - echo "$showinfo Run this script inside ${yellow}Node-WebDollar$stand folder to compile ${yellow}argon2$stand." + echo -e "$showinfo Run this script inside ${yellow}Node-WebDollar$stand folder to compile ${yellow}argon2$stand" fi fi fi ### NODE_WEBDOLLAR_END diff --git a/install-miner.sh b/install-miner.sh index deb758eb4..ecbb8abaa 100755 --- a/install-miner.sh +++ b/install-miner.sh @@ -111,11 +111,11 @@ fi if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then if [[ $(apt-cache policy python2.7 | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y python2.7; else echo "$showok python2.7 is already installed!"; fi + if [[ $(apt-cache policy python-is-python2 | grep none | awk '{print$2}' | sed s'/[()]//g') == none ]]; then sudo apt-get install -y python-is-python2; else echo "$showok python-is-python2 is already installed!"; fi elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ $(yum list python2.7 | grep -o "Available Packages") == "Available Packages" ]]; then yum install -y python2.7; else echo "$showok python2.7 is already installed!"; fi - fi ### @@ -163,4 +163,4 @@ else echo "$showerror You are not inside the Node-WebDollar folder." echo "$showinfo To install your miner, use this script inside the Node-WebDollar folder." fi -### \ No newline at end of file +### From 04d4f2816fccf28adb289b1745624fd7b5ede06a Mon Sep 17 00:00:00 2001 From: Igneom Date: Thu, 27 May 2021 19:45:50 -0400 Subject: [PATCH 075/132] Stop argon2-bench2, in case it's running, when a POS round starts, in order to save cpu usage when it's not being used. --- .../mining/backbone/Blockchain-Backbone-Mining.js | 4 +++- .../interface-blockchain/mining/backbone/Workers.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js b/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js index 2b785e942..9982e0c78 100644 --- a/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js +++ b/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js @@ -80,8 +80,10 @@ class BlockchainBackboneMining extends InterfaceBlockchainMining { this.bestHash = consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER; this.bestHashNonce = -1; - if ( BlockchainGenesis.isPoSActivated( height ) ) + if ( BlockchainGenesis.isPoSActivated( height ) ) { + this._workers.stopMining(); return this._minePOS(block, difficulty) ; + } if (consts.TERMINAL_WORKERS.CPU_MAX === -100) // NO POW MINING return undefined; diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js b/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js index 4b5ce7c66..26fb682d6 100644 --- a/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js +++ b/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js @@ -152,13 +152,18 @@ class Workers { try { - console.log("Stop Mining!"); + if (this.workers_list.length === 0) + return; + + console.log("Stop POW Mining!"); for (let i = 0; i < this.workers_list.length; i++){ if (this.workers_list[i] !== undefined && typeof this.workers_list[i].kill === "function") this.workers_list[i].kill('SIGINT'); } + this.workers_list = []; + } catch (exception){ } From fe4dbc0fd9c2863092a5885779ece7f0d8602cb9 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sun, 27 Jun 2021 18:37:22 +0300 Subject: [PATCH 076/132] new const_global for the pos100 testnet --- src/consts/const_global.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 723a0c5be..30c898e38 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,7 +79,7 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 FORCED_HALVING: 2158000, - POS100_ACTIVATION: 2167000, //it needs to be % 100 === 0 + POS100_ACTIVATION: 2295800, //it needs to be % 100 === 0 } @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "2.0.0", + VERSION: "3.0.0", - VERSION_COMPATIBILITY: "2.0.0", - VERSION_COMPATIBILITY_POOL_MINERS: "2.0.0", + VERSION_COMPATIBILITY: "3.0.0", + VERSION_COMPATIBILITY_POOL_MINERS: "3.0.0", VERSION_COMPATIBILITY_UPDATE: "", From 1943a3301e8856569811bd660d8131b13045ee16 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sun, 27 Jun 2021 19:13:39 +0300 Subject: [PATCH 077/132] New block height for testnet. Fallback nodes --- src/consts/const_global.js | 2 +- .../fallbacks/fallback_nodes_list.js | 221 +++++++++--------- 2 files changed, 113 insertions(+), 110 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 30c898e38..3c825dd38 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,7 +79,7 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 FORCED_HALVING: 2158000, - POS100_ACTIVATION: 2295800, //it needs to be % 100 === 0 + POS100_ACTIVATION: 2296100, //it needs to be % 100 === 0 } diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index d734189da..70504d512 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -9,115 +9,118 @@ export default { //--------------Community FallBack Nodes------------------- //--------------------------------------------------------- - {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M - - //{"addr": ["https://ez.cnbacolt.com:443"]}, - //{"addr": ["https://server.cnbacolt.com:443"]}, - - //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, - - {"addr": ["https://node1.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node2.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node3.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node4.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node5.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node6.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node7.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node8.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node9.petreus.ro:443"]}, // Thanks to Dani Petreus - {"addr": ["https://node10.petreus.ro:443"]}, // Thanks to Dani Petreus - - {"addr": ["https://node.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node1.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node2.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node3.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node4.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node5.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node6.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node7.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node8.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node9.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node10.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node11.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node12.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node13.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node14.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node15.timi.ro:443"]}, // Thanks to @TimiDani - {"addr": ["https://node16.timi.ro:443"]}, // Thanks to @TimiDani - - {"addr": ["https://node1.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node2.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node3.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node4.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node5.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node6.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node7.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node8.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node9.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node10.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node11.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node12.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node13.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node14.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - {"addr": ["https://node15.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - - //{"addr": ["https://webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - //{"addr": ["https://us.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - //{"addr": ["https://losangeles.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - //{"addr": ["https://singapore.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - - {"addr": ["https://falx.romeonet.ro:65001"]}, // Thanks to @romeonet - {"addr": ["https://romeonet.ddns.net:65101"]}, // Thanks to @romeonet - - //{"addr": ["https://node-eu.int-webd.com:5001"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5002"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5003"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5004"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5005"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5006"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5007"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5008"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5009"]}, // Thanks to @int_webd - //{"addr": ["https://node-eu.int-webd.com:5010"]}, // Thanks to @int_webd - - {"addr": ["https://cryptocoingb.ddns.net:8080"]}, // Thanks to CryptoCoinGB - {"addr": ["https://cryptocoingb.ddns.net:8081"]}, // Thanks to CryptoCoinGB - - //{"addr": ["https://bacm.ro:443"]}, //Thanks to @jigodia - - - //--------------------------------------------------------- - //--------------WebDollar FallBack Nodes------------------- - //--------------------------------------------------------- - - //{"addr": ["https://webdchucknorris.vpnromania.ro:80"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8080"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8081"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8082"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8083"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8084"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8085"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8086"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8087"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8088"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8089"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8090"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8091"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8092"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8093"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8094"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8095"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8096"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8097"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8098"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8099"]}, // Thanks to @cbusuioceanu - //{"addr": ["https://webdchucknorris.vpnromania.ro:8100"]}, // Thanks to @cbusuioceanu - - - //{"addr": ["https://webdollar.csland.ro:8440"]}, // Thanks to @mariotheodor - //{"addr": ["https://webdollar.csland.ro:8441"]}, // Thanks to @mariotheodor - //{"addr": ["https://webdollar.csland.ro:8442"]}, // Thanks to @mariotheodor - //{"addr": ["https://webdollar.csland.ro:8443"]}, // Thanks to @mariotheodor + {"addr": ["http://helloworldx.ddns.net:8080"]}, + {"addr": ["http://mryoung79.de:3333"]}, + + // {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M + // + // //{"addr": ["https://ez.cnbacolt.com:443"]}, + // //{"addr": ["https://server.cnbacolt.com:443"]}, + // + // //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, + // + // {"addr": ["https://node1.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node2.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node3.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node4.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node5.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node6.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node7.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node8.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node9.petreus.ro:443"]}, // Thanks to Dani Petreus + // {"addr": ["https://node10.petreus.ro:443"]}, // Thanks to Dani Petreus + // + // {"addr": ["https://node.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node1.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node2.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node3.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node4.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node5.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node6.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node7.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node8.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node9.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node10.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node11.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node12.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node13.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node14.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node15.timi.ro:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node16.timi.ro:443"]}, // Thanks to @TimiDani + // + // {"addr": ["https://node1.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node2.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node3.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node4.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node5.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node6.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node7.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node8.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node9.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node10.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node11.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node12.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node13.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node14.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // {"addr": ["https://node15.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + // + // //{"addr": ["https://webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + // //{"addr": ["https://us.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + // //{"addr": ["https://losangeles.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + // //{"addr": ["https://singapore.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + // + // {"addr": ["https://falx.romeonet.ro:65001"]}, // Thanks to @romeonet + // {"addr": ["https://romeonet.ddns.net:65101"]}, // Thanks to @romeonet + // + // //{"addr": ["https://node-eu.int-webd.com:5001"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5002"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5003"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5004"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5005"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5006"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5007"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5008"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5009"]}, // Thanks to @int_webd + // //{"addr": ["https://node-eu.int-webd.com:5010"]}, // Thanks to @int_webd + // + // {"addr": ["https://cryptocoingb.ddns.net:8080"]}, // Thanks to CryptoCoinGB + // {"addr": ["https://cryptocoingb.ddns.net:8081"]}, // Thanks to CryptoCoinGB + // + // //{"addr": ["https://bacm.ro:443"]}, //Thanks to @jigodia + // + // + // //--------------------------------------------------------- + // //--------------WebDollar FallBack Nodes------------------- + // //--------------------------------------------------------- + // + // //{"addr": ["https://webdchucknorris.vpnromania.ro:80"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8080"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8081"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8082"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8083"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8084"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8085"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8086"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8087"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8088"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8089"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8090"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8091"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8092"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8093"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8094"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8095"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8096"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8097"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8098"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8099"]}, // Thanks to @cbusuioceanu + // //{"addr": ["https://webdchucknorris.vpnromania.ro:8100"]}, // Thanks to @cbusuioceanu + // + // + // //{"addr": ["https://webdollar.csland.ro:8440"]}, // Thanks to @mariotheodor + // //{"addr": ["https://webdollar.csland.ro:8441"]}, // Thanks to @mariotheodor + // //{"addr": ["https://webdollar.csland.ro:8442"]}, // Thanks to @mariotheodor + // //{"addr": ["https://webdollar.csland.ro:8443"]}, // Thanks to @mariotheodor ], From f61b9506fd99b53e147c309a692f9db63640d198 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 28 Jun 2021 16:59:13 +0300 Subject: [PATCH 078/132] POS100 fixes --- src/common/blockchain/global/Blockchain-Genesis.js | 9 ++++++--- .../blockchain/Interface-Blockchain.js | 6 ++++-- .../blockchain/forks/Interface-Blockchain-Fork-Basic.js | 6 ++++-- src/consts/const_global.js | 6 +++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 688c20bd0..3bb68186c 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -69,7 +69,9 @@ class BlockchainGenesis{ //29,0..19 pos //20..29 pow - } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { + } else + // pos 90% activated + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { //0..9 pos -10% //9..19 pos -10% @@ -90,7 +92,8 @@ class BlockchainGenesis{ if (height % 100 < 90) return true; else return false; - } else return true; // pos 100% + } else + return true; // pos 100% @@ -98,4 +101,4 @@ class BlockchainGenesis{ } -export default new BlockchainGenesis(); \ No newline at end of file +export default new BlockchainGenesis(); diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index 40da95da7..27ecaa78b 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -183,12 +183,14 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ if (POSRecalculation && height >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1){ - if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { //66% POS if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work - } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { + } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { //90% POS if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work + } else{//100% POS + height = height - 10 } } diff --git a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js index 02d4cd36b..aa266a188 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js +++ b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js @@ -122,12 +122,14 @@ class InterfaceBlockchainFork { if (height >= consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION-1) { //calculating the virtualization of the POS - if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) { // 66% if (height % 30 === 29) height = height - 10; //first POS, get the last proof of Stake else if (height % 30 === 19) height = height - 20; //first POW, get the last proof of Work } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work + } else { + height = height - 10 } forkHeight = height - this.forkStartingHeight; @@ -314,4 +316,4 @@ class InterfaceBlockchainFork { } -export default InterfaceBlockchainFork; \ No newline at end of file +export default InterfaceBlockchainFork; diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 3c825dd38..dc4b1b84a 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "3.0.0", + VERSION: "4.0.0", - VERSION_COMPATIBILITY: "3.0.0", - VERSION_COMPATIBILITY_POOL_MINERS: "3.0.0", + VERSION_COMPATIBILITY: "4.0.0", + VERSION_COMPATIBILITY_POOL_MINERS: "4.0.0", VERSION_COMPATIBILITY_UPDATE: "", From cb185adf7e8d69739c50c2f3df56254b362fb96b Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 28 Jun 2021 17:05:58 +0300 Subject: [PATCH 079/132] new fallback. --- src/common/blockchain/global/Blockchain-Genesis.js | 11 ++++------- .../discovery/fallbacks/fallback_nodes_list.js | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 3bb68186c..15f39648b 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -42,11 +42,10 @@ class BlockchainGenesis{ if (typeof height === "string") height = Number.parseInt(height); // no pos activated - if (height < consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) return 0; - - if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) return 30; - else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) return 100; - else return 0; + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) return 0; // NO POS + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS90_ACTIVATION) return 30; // 66% POS + if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) return 100; // 90% POS + return 0; // 100% POS } @@ -95,8 +94,6 @@ class BlockchainGenesis{ } else return true; // pos 100% - - } } diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index 70504d512..400a731f3 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -11,6 +11,7 @@ export default { {"addr": ["http://helloworldx.ddns.net:8080"]}, {"addr": ["http://mryoung79.de:3333"]}, + {"addr": ["http://188.24.107.165:8080"]}, // {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M // From 1c2ba0cd3b8edd10aa07a0b9caf801b5acd5ab90 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 29 Jun 2021 14:36:46 +0300 Subject: [PATCH 080/132] disable _intervalVerifyConsensus ? --- .../Interface-Blockchain-Agent-Basic.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js b/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js index 8b5a48f54..3f17d6d74 100644 --- a/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js +++ b/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js @@ -84,21 +84,21 @@ class InterfaceBlockchainAgentBasic { this._prevBlocks = 0; this._prevDate = 0; - this._intervalVerifyConsensus = setInterval( () => { - - if ( this._prevDate && this._prevBlocks === this.blockchain.blocks.length ) { - - if (this.status !== AGENT_STATUS.AGENT_STATUS_NOT_SYNCHRONIZED) { - console.warn("agent basic synchronization"); - Blockchain.synchronizeBlockchain(); //let's synchronize again - } - - } - - this._prevDate = new Date(); - this._prevBlocks = this.blockchain.blocks.length; - - }, process.env.BROWSER ? TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_BROWSER : TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_TERMINAL ); + // this._intervalVerifyConsensus = setInterval( () => { + // + // if ( this._prevDate && this._prevBlocks === this.blockchain.blocks.length ) { + // + // if (this.status !== AGENT_STATUS.AGENT_STATUS_NOT_SYNCHRONIZED) { + // console.warn("agent basic synchronization"); + // Blockchain.synchronizeBlockchain(); //let's synchronize again + // } + // + // } + // + // this._prevDate = new Date(); + // this._prevBlocks = this.blockchain.blocks.length; + // + // }, process.env.BROWSER ? TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_BROWSER : TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_TERMINAL ); } @@ -114,4 +114,4 @@ class InterfaceBlockchainAgentBasic { } -export default InterfaceBlockchainAgentBasic; \ No newline at end of file +export default InterfaceBlockchainAgentBasic; From 328b2049c67142944c2f2725a04d6e18f3e03ad5 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 29 Jun 2021 16:36:31 +0300 Subject: [PATCH 081/132] activate again _intervalVerifyConsensus ? --- .../Interface-Blockchain-Agent-Basic.js | 30 +++++++++---------- src/main-blockchain/Blockchain.js | 16 +++++----- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js b/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js index 3f17d6d74..064ba0266 100644 --- a/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js +++ b/src/common/blockchain/interface-blockchain/agents/Interface-Blockchain-Agent-Basic.js @@ -84,21 +84,21 @@ class InterfaceBlockchainAgentBasic { this._prevBlocks = 0; this._prevDate = 0; - // this._intervalVerifyConsensus = setInterval( () => { - // - // if ( this._prevDate && this._prevBlocks === this.blockchain.blocks.length ) { - // - // if (this.status !== AGENT_STATUS.AGENT_STATUS_NOT_SYNCHRONIZED) { - // console.warn("agent basic synchronization"); - // Blockchain.synchronizeBlockchain(); //let's synchronize again - // } - // - // } - // - // this._prevDate = new Date(); - // this._prevBlocks = this.blockchain.blocks.length; - // - // }, process.env.BROWSER ? TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_BROWSER : TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_TERMINAL ); + this._intervalVerifyConsensus = setInterval( () => { + + if ( this._prevDate && this._prevBlocks === this.blockchain.blocks.length ) { + + if (this.status !== AGENT_STATUS.AGENT_STATUS_NOT_SYNCHRONIZED) { + console.warn("agent basic synchronization"); + Blockchain.synchronizeBlockchain(); //let's synchronize again + } + + } + + this._prevDate = new Date(); + this._prevBlocks = this.blockchain.blocks.length; + + }, process.env.BROWSER ? TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_BROWSER : TIME_TO_RESYNCHRONIZE_IN_CASE_NO_NEW_BLOCKS_WERE_RECEIVED_TERMINAL ); } diff --git a/src/main-blockchain/Blockchain.js b/src/main-blockchain/Blockchain.js index 88ccd6d4f..14073c335 100644 --- a/src/main-blockchain/Blockchain.js +++ b/src/main-blockchain/Blockchain.js @@ -59,7 +59,7 @@ class Blockchain{ this.onPoolsCreated = new Promise((resolve)=>{ this._onPoolsCreatedResolver = resolve; }); - + this._loaded = false; this._poolsLoaded = false; @@ -175,7 +175,7 @@ class Blockchain{ */ async synchronizeBlockchain(firstTime, synchronizeComplete=false){ - if ( this.synchronized === false) return; + if ( !this.synchronized ) return; this.synchronized = false; console.warn("################### RESYNCHRONIZATION STARTED ##########"); @@ -208,7 +208,7 @@ class Blockchain{ else StatusEvents.emit('blockchain/status', {message: "No Internet Access"}); - if (NodesList.nodes.length === 0) + if ( !NodesList.nodes.length) NodesWaitlist.resetWaitlist(NODE_TYPE.NODE_WEB_PEER); this.Agent.initializeAgentPromise(); @@ -216,14 +216,14 @@ class Blockchain{ } - this.synchronized = true; - console.warn( "Blockchain Ready to Mine" ); - if (suspendMining) { - this.startMining(); + await this.startMining(); StatusEvents.emit('blockchain/status', {message: "Blockchain Ready to Mine"}); } + this.synchronized = true; + console.warn( "Blockchain Ready to Mine" ); + } get poolsLoaded(){ @@ -341,4 +341,4 @@ class Blockchain{ } -export default new Blockchain() \ No newline at end of file +export default new Blockchain() From 382ab086151b0bcc3247412ff50c0f51371c7435 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 30 Jun 2021 20:34:38 +0300 Subject: [PATCH 082/132] changing POS100_ACTIVATION to %100 = 10 --- src/consts/const_global.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index dc4b1b84a..1f755c9cc 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,7 +79,7 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 FORCED_HALVING: 2158000, - POS100_ACTIVATION: 2296100, //it needs to be % 100 === 0 + POS100_ACTIVATION: 2296110, //it needs to be % 110 === 0 } @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "4.0.0", + VERSION: "5.0.0", - VERSION_COMPATIBILITY: "4.0.0", - VERSION_COMPATIBILITY_POOL_MINERS: "4.0.0", + VERSION_COMPATIBILITY: "5.0.0", + VERSION_COMPATIBILITY_POOL_MINERS: "5.0.0", VERSION_COMPATIBILITY_UPDATE: "", From 2e8238ad0ad3fa6796acc90d73ff579ca9e6e4cf Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Thu, 1 Jul 2021 16:45:39 +0300 Subject: [PATCH 083/132] POS difficulty bug fix --- .../interface-blockchain/blockchain/Interface-Blockchain.js | 2 -- .../blockchain/forks/Interface-Blockchain-Fork-Basic.js | 2 -- src/consts/const_global.js | 6 +++--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js index 27ecaa78b..85e63176a 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js +++ b/src/common/blockchain/interface-blockchain/blockchain/Interface-Blockchain.js @@ -189,8 +189,6 @@ class InterfaceBlockchain extends InterfaceBlockchainBasic{ } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { //90% POS if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work - } else{//100% POS - height = height - 10 } } diff --git a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js index aa266a188..355caa4f7 100644 --- a/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js +++ b/src/common/blockchain/interface-blockchain/blockchain/forks/Interface-Blockchain-Fork-Basic.js @@ -128,8 +128,6 @@ class InterfaceBlockchainFork { } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { if (height % 100 === 99) height = height - 10; //first POS, get the last proof of Stake else if (height % 100 === 89) height = height - 90; //first POW, get the last proof of work - } else { - height = height - 10 } forkHeight = height - this.forkStartingHeight; diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 1f755c9cc..b223001a1 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "5.0.0", + VERSION: "6.0.0", - VERSION_COMPATIBILITY: "5.0.0", - VERSION_COMPATIBILITY_POOL_MINERS: "5.0.0", + VERSION_COMPATIBILITY: "6.0.0", + VERSION_COMPATIBILITY_POOL_MINERS: "6.0.0", VERSION_COMPATIBILITY_UPDATE: "", From 838ecf1a6d70fe6ab1aa634c05233bf08c4e3865 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Fri, 2 Jul 2021 16:56:08 +0300 Subject: [PATCH 084/132] POS100 ACTIVATION --- src/consts/const_global.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index b223001a1..6ad5a0709 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -79,7 +79,7 @@ consts.BLOCKCHAIN = { POS90_ACTIVATION: 1650000, //it needs to be % 30 === 0, better it should be % 100 = 0 && % 30 === 0 FORCED_HALVING: 2158000, - POS100_ACTIVATION: 2296110, //it needs to be % 110 === 0 + POS100_ACTIVATION: 2348110, //it needs to be % 110 === 0 } @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "6.0.0", + VERSION: "1.3.2", - VERSION_COMPATIBILITY: "6.0.0", - VERSION_COMPATIBILITY_POOL_MINERS: "6.0.0", + VERSION_COMPATIBILITY: "1.200.3", + VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", VERSION_COMPATIBILITY_UPDATE: "", From 0537db81cdbf3e5a4816d69be3c911518a0a1d95 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Fri, 2 Jul 2021 16:58:49 +0300 Subject: [PATCH 085/132] Revert fallback changes --- .../fallbacks/fallback_nodes_list.js | 223 +++++++++--------- 1 file changed, 110 insertions(+), 113 deletions(-) diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index 400a731f3..a820a2538 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -9,119 +9,116 @@ export default { //--------------Community FallBack Nodes------------------- //--------------------------------------------------------- - {"addr": ["http://helloworldx.ddns.net:8080"]}, - {"addr": ["http://mryoung79.de:3333"]}, - {"addr": ["http://188.24.107.165:8080"]}, - - // {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M - // - // //{"addr": ["https://ez.cnbacolt.com:443"]}, - // //{"addr": ["https://server.cnbacolt.com:443"]}, - // - // //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, - // - // {"addr": ["https://node1.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node2.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node3.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node4.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node5.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node6.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node7.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node8.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node9.petreus.ro:443"]}, // Thanks to Dani Petreus - // {"addr": ["https://node10.petreus.ro:443"]}, // Thanks to Dani Petreus - // - // {"addr": ["https://node.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node1.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node2.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node3.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node4.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node5.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node6.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node7.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node8.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node9.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node10.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node11.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node12.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node13.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node14.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node15.timi.ro:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node16.timi.ro:443"]}, // Thanks to @TimiDani - // - // {"addr": ["https://node1.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node2.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node3.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node4.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node5.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node6.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node7.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node8.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node9.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node10.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node11.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node12.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node13.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node14.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // {"addr": ["https://node15.webdollarminingpool.com:443"]}, // Thanks to @TimiDani - // - // //{"addr": ["https://webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - // //{"addr": ["https://us.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - // //{"addr": ["https://losangeles.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - // //{"addr": ["https://singapore.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre - // - // {"addr": ["https://falx.romeonet.ro:65001"]}, // Thanks to @romeonet - // {"addr": ["https://romeonet.ddns.net:65101"]}, // Thanks to @romeonet - // - // //{"addr": ["https://node-eu.int-webd.com:5001"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5002"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5003"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5004"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5005"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5006"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5007"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5008"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5009"]}, // Thanks to @int_webd - // //{"addr": ["https://node-eu.int-webd.com:5010"]}, // Thanks to @int_webd - // - // {"addr": ["https://cryptocoingb.ddns.net:8080"]}, // Thanks to CryptoCoinGB - // {"addr": ["https://cryptocoingb.ddns.net:8081"]}, // Thanks to CryptoCoinGB - // - // //{"addr": ["https://bacm.ro:443"]}, //Thanks to @jigodia - // - // - // //--------------------------------------------------------- - // //--------------WebDollar FallBack Nodes------------------- - // //--------------------------------------------------------- - // - // //{"addr": ["https://webdchucknorris.vpnromania.ro:80"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8080"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8081"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8082"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8083"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8084"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8085"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8086"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8087"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8088"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8089"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8090"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8091"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8092"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8093"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8094"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8095"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8096"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8097"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8098"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8099"]}, // Thanks to @cbusuioceanu - // //{"addr": ["https://webdchucknorris.vpnromania.ro:8100"]}, // Thanks to @cbusuioceanu - // - // - // //{"addr": ["https://webdollar.csland.ro:8440"]}, // Thanks to @mariotheodor - // //{"addr": ["https://webdollar.csland.ro:8441"]}, // Thanks to @mariotheodor - // //{"addr": ["https://webdollar.csland.ro:8442"]}, // Thanks to @mariotheodor - // //{"addr": ["https://webdollar.csland.ro:8443"]}, // Thanks to @mariotheodor + + {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M + + //{"addr": ["https://ez.cnbacolt.com:443"]}, + //{"addr": ["https://server.cnbacolt.com:443"]}, + + //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, + + {"addr": ["https://node1.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node2.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node3.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node4.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node5.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node6.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node7.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node8.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node9.petreus.ro:443"]}, // Thanks to Dani Petreus + {"addr": ["https://node10.petreus.ro:443"]}, // Thanks to Dani Petreus + + {"addr": ["https://node.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node1.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node2.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node3.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node4.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node5.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node6.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node7.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node8.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node9.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node10.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node11.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node12.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node13.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node14.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node15.timi.ro:443"]}, // Thanks to @TimiDani + {"addr": ["https://node16.timi.ro:443"]}, // Thanks to @TimiDani + + {"addr": ["https://node1.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node2.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node3.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node4.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node5.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node6.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node7.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node8.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node9.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node10.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node11.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node12.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node13.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node14.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + {"addr": ["https://node15.webdollarminingpool.com:443"]}, // Thanks to @TimiDani + + //{"addr": ["https://webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + //{"addr": ["https://us.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + //{"addr": ["https://losangeles.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + //{"addr": ["https://singapore.webdollarpool.win:80/"]}, // Thanks to @vladimirpetre + + {"addr": ["https://falx.romeonet.ro:65001"]}, // Thanks to @romeonet + {"addr": ["https://romeonet.ddns.net:65101"]}, // Thanks to @romeonet + + //{"addr": ["https://node-eu.int-webd.com:5001"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5002"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5003"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5004"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5005"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5006"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5007"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5008"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5009"]}, // Thanks to @int_webd + //{"addr": ["https://node-eu.int-webd.com:5010"]}, // Thanks to @int_webd + + {"addr": ["https://cryptocoingb.ddns.net:8080"]}, // Thanks to CryptoCoinGB + {"addr": ["https://cryptocoingb.ddns.net:8081"]}, // Thanks to CryptoCoinGB + + //{"addr": ["https://bacm.ro:443"]}, //Thanks to @jigodia + + + //--------------------------------------------------------- + //--------------WebDollar FallBack Nodes------------------- + //--------------------------------------------------------- + + //{"addr": ["https://webdchucknorris.vpnromania.ro:80"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8080"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8081"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8082"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8083"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8084"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8085"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8086"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8087"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8088"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8089"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8090"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8091"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8092"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8093"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8094"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8095"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8096"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8097"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8098"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8099"]}, // Thanks to @cbusuioceanu + //{"addr": ["https://webdchucknorris.vpnromania.ro:8100"]}, // Thanks to @cbusuioceanu + + + //{"addr": ["https://webdollar.csland.ro:8440"]}, // Thanks to @mariotheodor + //{"addr": ["https://webdollar.csland.ro:8441"]}, // Thanks to @mariotheodor + //{"addr": ["https://webdollar.csland.ro:8442"]}, // Thanks to @mariotheodor + //{"addr": ["https://webdollar.csland.ro:8443"]}, // Thanks to @mariotheodor ], From 8007f7593b5d4a3f7f6ef6f0778df356a5b4e4ed Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sun, 4 Jul 2021 13:50:21 +0300 Subject: [PATCH 086/132] 4 new fallback nodes --- .../blocks/Interface-Blockchain-Block.js | 1 + .../mini-blockchain/blocks/Mini-Blockchain-Block-Data.js | 3 +-- .../mini-blockchain/blocks/Mini-Blockchain-Block.js | 8 +++++++- .../service/discovery/fallbacks/fallback_nodes_list.js | 6 ++++-- .../node-server/API/public/Node-API-Public-Nodes.js | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js index d26f27b81..7deda4b6b 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js @@ -220,6 +220,7 @@ class InterfaceBlockchainBlock { difficulty: this.difficultyTarget ? this.difficultyTarget.toString("hex") : '', hash: this.hash ? this.hash.toString("hex"): "", hashChain: this.hashChain ? this.hashChain.toString("hex") : '', + reward: this.reward, } } diff --git a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block-Data.js b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block-Data.js index 17c866473..1f9d9a592 100644 --- a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block-Data.js +++ b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block-Data.js @@ -83,7 +83,6 @@ class MiniBlockchainBlockData extends inheritBlockData { } - } -export default MiniBlockchainBlockData; \ No newline at end of file +export default MiniBlockchainBlockData; diff --git a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js index 0d3aab92d..56f3c25ad 100644 --- a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js +++ b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js @@ -293,6 +293,12 @@ class MiniBlockchainBlock extends inheritBlockchainBlock { } + toJSON(){ + const json = super.toJSON() + json.posMinerAddress = Buffer.isBuffer(this.posMinerAddress) ? this.posMinerAddress.toString("hex") : ''; + return json + } + } -export default MiniBlockchainBlock \ No newline at end of file +export default MiniBlockchainBlock diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index a820a2538..b74fbc4ee 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -12,8 +12,10 @@ export default { {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M - //{"addr": ["https://ez.cnbacolt.com:443"]}, - //{"addr": ["https://server.cnbacolt.com:443"]}, + {"addr": ["https://daniuda.ddns.net:8080"]}, // Thanks to Sorin M + {"addr": ["https://doris.webdollarpool.ca:443"]}, // Thanks to Sorin M + {"addr": ["https://webd-europool.ddns.net:2222"]}, // Thanks to Sorin M + {"addr": ["https://pool.bacm.ro:2053"]}, // Thanks to Sorin M //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js b/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js index c40fc161e..07948d4c1 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js @@ -72,4 +72,4 @@ class NodeAPIPublicNodes{ } -export default new NodeAPIPublicNodes(); \ No newline at end of file +export default new NodeAPIPublicNodes(); From 810d8ae1704381cefa7d4f3728d788ab3e508de6 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Tue, 6 Jul 2021 10:57:32 -0600 Subject: [PATCH 087/132] Change truthiness evaluation to continue if blockchain is actually unsynchronized --- src/main-blockchain/Blockchain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main-blockchain/Blockchain.js b/src/main-blockchain/Blockchain.js index 14073c335..1b3ccba4e 100644 --- a/src/main-blockchain/Blockchain.js +++ b/src/main-blockchain/Blockchain.js @@ -175,7 +175,7 @@ class Blockchain{ */ async synchronizeBlockchain(firstTime, synchronizeComplete=false){ - if ( !this.synchronized ) return; + if ( !!this.synchronized ) return; this.synchronized = false; console.warn("################### RESYNCHRONIZATION STARTED ##########"); From a698431d15e74bbdc0a86c52377f8d076f4a7e14 Mon Sep 17 00:00:00 2001 From: WEBDmine <56698687+WEBDmine@users.noreply.github.com> Date: Thu, 8 Jul 2021 23:55:30 +0300 Subject: [PATCH 088/132] US & EU nodes added. FREE! Helping webdollar community ! --- .../service/discovery/fallbacks/fallback_nodes_list.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index b74fbc4ee..0e08bedfb 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -15,8 +15,12 @@ export default { {"addr": ["https://daniuda.ddns.net:8080"]}, // Thanks to Sorin M {"addr": ["https://doris.webdollarpool.ca:443"]}, // Thanks to Sorin M {"addr": ["https://webd-europool.ddns.net:2222"]}, // Thanks to Sorin M - {"addr": ["https://pool.bacm.ro:2053"]}, // Thanks to Sorin M - + + {"addr": ["https://us-est.webdmine.io:8443"]}, // USA WEBDmine pools ( free nodes forever ) + {"addr": ["https://webdmine.io:8443"]}, // USA WEBDmine pools ( free nodes forever ) + {"addr": ["https://pool.maison:8443"]}, // EUROPE WEBDmine pools ( free nodes forever ) + {"addr": ["https://europe.pool.maison:8443"]}, // EUROPE WEBDmine pools ( free nodes forever ) + //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, {"addr": ["https://node1.petreus.ro:443"]}, // Thanks to Dani Petreus @@ -86,7 +90,7 @@ export default { {"addr": ["https://cryptocoingb.ddns.net:8080"]}, // Thanks to CryptoCoinGB {"addr": ["https://cryptocoingb.ddns.net:8081"]}, // Thanks to CryptoCoinGB - //{"addr": ["https://bacm.ro:443"]}, //Thanks to @jigodia + {"addr": ["https://bacm.ro:2053"]}, // Thanks to @jigOdia //--------------------------------------------------------- From ee12cbb9a7870770bec9aeb07d4f3d6bcce0dc32 Mon Sep 17 00:00:00 2001 From: WEBDmine <56698687+WEBDmine@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:03:12 +0300 Subject: [PATCH 089/132] MOFTpool - USA EST POOL MINING --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 6b7aeb472..517f6f4a3 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -228,6 +228,7 @@ class MinerPoolSettings { } async _addPoolsList(){ + await this.addPoolList("/pool/1/MOFTpool/0.01/ca771a8a192c7f23b11a6b409732ab1f5e30949205a13e81a4580921ec5ae295/https:$$us-est.webdmine.io:8443", undefined, true); await this.addPoolList("/pool/1/CanadianStakePool/0.02/ea115a560322c557d3617732145a837af9992d729e5f8165d3b7077b22ee12a4/https:$$webdollarpool.ca:443", undefined, true); await this.addPoolList("/pool/1/WEBD-Splashpool-USA/0.02/61761896b4d958b3cc9073ae3c724a127b4ee5b31f6b8dcafd29643cf20a796a/https:$$splashpool.myvnc.com:8080", undefined, true); await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); From 8f1ee9c456ece2a7368a3c7e41d19edb60f4a287 Mon Sep 17 00:00:00 2001 From: MartinCanto Date: Mon, 12 Jul 2021 13:39:58 -0400 Subject: [PATCH 090/132] Update Miner-Pool-Settings.js Add MartinCanto Pool to addPoolsList() --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 517f6f4a3..1e2aef075 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -228,6 +228,7 @@ class MinerPoolSettings { } async _addPoolsList(){ + await this.addPoolList("/pool/1/MartinCanto/0.02/f2406eea8d43bc17ac9f4d126d8baa56b0ffd0be28f2a76ae35b4e4ef6f67064/https:$$pool.martincanto.com:443", undefined, true); await this.addPoolList("/pool/1/MOFTpool/0.01/ca771a8a192c7f23b11a6b409732ab1f5e30949205a13e81a4580921ec5ae295/https:$$us-est.webdmine.io:8443", undefined, true); await this.addPoolList("/pool/1/CanadianStakePool/0.02/ea115a560322c557d3617732145a837af9992d729e5f8165d3b7077b22ee12a4/https:$$webdollarpool.ca:443", undefined, true); await this.addPoolList("/pool/1/WEBD-Splashpool-USA/0.02/61761896b4d958b3cc9073ae3c724a127b4ee5b31f6b8dcafd29643cf20a796a/https:$$splashpool.myvnc.com:8080", undefined, true); From 800047e08bd9795a2bf9fca871f98b279ed4cf95 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 24 Jul 2021 19:11:07 +0300 Subject: [PATCH 091/132] fixed issue toJSON --- .../blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js index 56f3c25ad..346d5b25e 100644 --- a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js +++ b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js @@ -294,7 +294,7 @@ class MiniBlockchainBlock extends inheritBlockchainBlock { } toJSON(){ - const json = super.toJSON() + const json = super.toJSON(...arguments) json.posMinerAddress = Buffer.isBuffer(this.posMinerAddress) ? this.posMinerAddress.toString("hex") : ''; return json } From 3d0c1f798bc602f4c2a804b1532ce183346b874b Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sun, 8 Aug 2021 00:06:32 +0300 Subject: [PATCH 092/132] const global changed to allow more sockets --- src/consts/const_global.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 6ad5a0709..323d1caae 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -333,8 +333,8 @@ consts.SETTINGS = { MIN_SOCKET_CLIENTS_WAITLIST_FALLBACK: 2, SERVER_OPEN:{ - MAX_SOCKET_CLIENTS_WAITLIST: 5, - MAX_SOCKET_CLIENTS_WAITLIST_FALLBACK: 3, + MAX_SOCKET_CLIENTS_WAITLIST: 10, + MAX_SOCKET_CLIENTS_WAITLIST_FALLBACK: 10, }, SSL:{ From cecb832e4673e6c12f159102c5eee34dc22b8944 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sun, 8 Aug 2021 15:02:01 +0300 Subject: [PATCH 093/132] const global changed to allow more sockets #2 --- src/consts/const_global.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 323d1caae..c2a161b77 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -326,8 +326,8 @@ consts.SETTINGS = { CLIENT: { - MAX_SOCKET_CLIENTS_WAITLIST: 5, - MAX_SOCKET_CLIENTS_WAITLIST_FALLBACK: 5, + MAX_SOCKET_CLIENTS_WAITLIST: 10, + MAX_SOCKET_CLIENTS_WAITLIST_FALLBACK: 10, MIN_SOCKET_CLIENTS_WAITLIST: 0, MIN_SOCKET_CLIENTS_WAITLIST_FALLBACK: 2, From 307382b6b4c62ad3d3e07bcdfb7074a185ce3fca Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 9 Aug 2021 12:55:16 +0300 Subject: [PATCH 094/132] error catching --- src/build_terminal.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/build_terminal.js b/src/build_terminal.js index e99975b7f..b621a1890 100644 --- a/src/build_terminal.js +++ b/src/build_terminal.js @@ -11,6 +11,10 @@ process.on('uncaughtException', (err) => { console.error(`Caught exception: ${err}`); }); +process.on('unhandledRejection', (err) => { + console.error(`Caught exception: ${err}`); +}); + // light-node Blockchain.createBlockchain('full-node', () => {}, async () => { From c254dcf8ee19375a645b565ab445e9eb8bf9fb52 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 9 Aug 2021 18:02:47 +0300 Subject: [PATCH 095/132] error catching #2 --- src/node/sockets/node-clients/socket/Node-Client.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/node/sockets/node-clients/socket/Node-Client.js b/src/node/sockets/node-clients/socket/Node-Client.js index b7e6f5efd..7f4f371e4 100644 --- a/src/node/sockets/node-clients/socket/Node-Client.js +++ b/src/node/sockets/node-clients/socket/Node-Client.js @@ -138,6 +138,12 @@ class NodeClient { }); + socket.once("error", response =>{ + + resolve(false); + + }) + socket.once("connect_failed", response =>{ //console.log("Client error connecting (connect_failed) ", address, response); @@ -192,6 +198,13 @@ class NodeClient { }); + this.socket.on("error", async () => { + + console.warn("Client error ", this.socket.node.sckAddress.getAddress(true)); + await NodesList.disconnectSocket(this.socket); + + }) + this.socket.node.protocol.propagation.initializePropagation(); From 59e2ba8854d70cd4bbcace8080489d3f5c29c825 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 9 Aug 2021 22:35:40 +0300 Subject: [PATCH 096/132] node client #3 --- .../node-clients/socket/Node-Client.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/node/sockets/node-clients/socket/Node-Client.js b/src/node/sockets/node-clients/socket/Node-Client.js index 7f4f371e4..0ba1c8812 100644 --- a/src/node/sockets/node-clients/socket/Node-Client.js +++ b/src/node/sockets/node-clients/socket/Node-Client.js @@ -97,6 +97,9 @@ class NodeClient { }); + socket.on("error", response =>{ + }) + } catch (Exception){ console.error("Error Connecting Node to ", address," ", Exception); return resolve(false); @@ -139,9 +142,7 @@ class NodeClient { }); socket.once("error", response =>{ - resolve(false); - }) socket.once("connect_failed", response =>{ @@ -177,6 +178,13 @@ class NodeClient { //it is not unique... then I have to disconnect + this.socket.on("error", async () => { + + console.warn("Client error ", this.socket.node.sckAddress.getAddress(true)); + await NodesList.disconnectSocket(this.socket); + + }) + if ( Blockchain.MinerPoolManagement.minerPoolStarted && waitlist.nodeConsensusType !== NODES_CONSENSUS_TYPE.NODE_CONSENSUS_SERVER) { console.error("socket disconnected by not being minerPool"); return false; @@ -198,14 +206,6 @@ class NodeClient { }); - this.socket.on("error", async () => { - - console.warn("Client error ", this.socket.node.sckAddress.getAddress(true)); - await NodesList.disconnectSocket(this.socket); - - }) - - this.socket.node.protocol.propagation.initializePropagation(); } From cd80e75ab2577bb6668dd95367a6300f39c7cd30 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 03:42:26 +0300 Subject: [PATCH 097/132] node client error handling #4 --- .../node-clients/socket/Node-Client.js | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/node/sockets/node-clients/socket/Node-Client.js b/src/node/sockets/node-clients/socket/Node-Client.js index 0ba1c8812..db1f47557 100644 --- a/src/node/sockets/node-clients/socket/Node-Client.js +++ b/src/node/sockets/node-clients/socket/Node-Client.js @@ -52,7 +52,7 @@ class NodeClient { //if (!waitlist.isFallback) return false; - let timeoutTotal = 8*1000 + Math.floor( Math.random()*10*1000) + ( !process.env.BROWSER ? 10*1000+Math.random()*30*1000 : 0 ); + let timeoutTotal = Math.floor( 8*1000 + Math.random()*10*1000 + ( !process.env.BROWSER ) ? 10*1000+Math.random()*30*1000 : 0 ); try { @@ -97,14 +97,37 @@ class NodeClient { }); - socket.on("error", response =>{ - }) - } catch (Exception){ console.error("Error Connecting Node to ", address," ", Exception); return resolve(false); } + + socket.on("error", response =>{ + }) + + socket.on("connect_error", response =>{ + + //console.log("Client error connecting", address, response); + resolve(false); + + }); + + socket.on("error", response =>{ + resolve(false); + }) + + socket.on("connect_failed", response =>{ + + //console.log("Client error connecting (connect_failed) ", address, response); + resolve(false); + + }); + + socket.on("disconnect", ()=>{ + resolve(false); + }); + if ( Blockchain.MinerPoolManagement.minerPoolStarted && waitlist.nodeConsensusType !== NODES_CONSENSUS_TYPE.NODE_CONSENSUS_SERVER) throw {message: "You switched to pool"}; @@ -115,7 +138,6 @@ class NodeClient { console.warn("Client connected to " + socket.node.sckAddress.address); }); - socket.once("HelloNode", async (data) => { try{ @@ -134,28 +156,6 @@ class NodeClient { }); - socket.once("connect_error", response =>{ - - //console.log("Client error connecting", address, response); - resolve(false); - - }); - - socket.once("error", response =>{ - resolve(false); - }) - - socket.once("connect_failed", response =>{ - - //console.log("Client error connecting (connect_failed) ", address, response); - resolve(false); - - }); - - socket.on("disconnect", ()=>{ - resolve(false); - }); - socket.connect(); } From 796b018b309a5cbe7fd43dbf84bc3065c8c7aacd Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 18:40:05 +0300 Subject: [PATCH 098/132] node client error handling #5 --- .../node-server/sockets/Node-Server.js | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/node/sockets/node-server/sockets/Node-Server.js b/src/node/sockets/node-server/sockets/Node-Server.js index f772658e2..c91040005 100644 --- a/src/node/sockets/node-server/sockets/Node-Server.js +++ b/src/node/sockets/node-server/sockets/Node-Server.js @@ -232,23 +232,16 @@ class NodeServer { }); - try { - //multiple ports, but doesn't work - - server.listen (NodeExpress.server).on('error', (err) => { + //multiple ports, but doesn't work - console.error( "Couldn't open server on port ", NodeExpress.port, " try next port") ; - this.loaded = false; + server.listen (NodeExpress.server).on('error', (err) => { - throw err; + console.error( "Couldn't open server on port ", NodeExpress.port, " try next port") ; + this.loaded = false - }); - - this.loaded = true; + }); - } catch(Exception){ - console.error("Error Calling node_server.listen", Exception); - } + this.loaded = true; } catch(Exception){ @@ -285,12 +278,8 @@ class NodeServer { async getServerHTTPAddress(getIP) { - if ( !NodeExpress ) return ''; - - if ( !this.loaded ) - await NodeExpress.startExpress(); - + if ( !this.loaded ) return '' if (NodeExpress.port === 0) return ''; if (NodeExpress.domain === '') return ''; From edadfc866c698b41a2e72d7da5562eb72f50d44f Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 19:22:33 +0300 Subject: [PATCH 099/132] node client error handling #5 --- src/build_terminal.js | 4 ++++ src/node/sockets/node-server/sockets/Node-Server.js | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/build_terminal.js b/src/build_terminal.js index b621a1890..d7acd7d55 100644 --- a/src/build_terminal.js +++ b/src/build_terminal.js @@ -7,6 +7,10 @@ import {JsonRpcServer} from './node/jsonRpc'; JsonRpcServer(consts.JSON_RPC); +process.on('error', (err) => { + console.error(`Caught exception: ${err}`); +}); + process.on('uncaughtException', (err) => { console.error(`Caught exception: ${err}`); }); diff --git a/src/node/sockets/node-server/sockets/Node-Server.js b/src/node/sockets/node-server/sockets/Node-Server.js index c91040005..18977aad1 100644 --- a/src/node/sockets/node-server/sockets/Node-Server.js +++ b/src/node/sockets/node-server/sockets/Node-Server.js @@ -132,7 +132,7 @@ class NodeServer { if ( (Blockchain.PoolManagement && Blockchain.PoolManagement._poolStarted && nodeConsensusType !== NODES_CONSENSUS_TYPE.NODE_CONSENSUS_SERVER) || - (Blockchain.ServerPoolManagement && Blockchain.ServerPoolManagement._serverPoolStarted && nodeConsensusType !== NODES_CONSENSUS_TYPE.NODE_CONSENSUS_SERVER)){ + (Blockchain.ServerPoolManagement && Blockchain.ServerPoolManagement._serverPoolStarted && nodeConsensusType !== NODES_CONSENSUS_TYPE.NODE_CONSENSUS_SERVER)){ if (Math.random() < 0.1) console.error("disconnecting user for being simple node", nodeConsensusType); @@ -183,12 +183,12 @@ class NodeServer { else if (NODE_TYPE.NODE_WEB_PEER === nodeType && this._rooms.browsers.serverSits <= 0) - if (new Date().getTime() - this._rooms.browsers.timeLastConnected >= ROOMS.BROWSERS.TIME_TO_PASS_TO_CONNECT_NEW_CLIENT) { + if (new Date().getTime() - this._rooms.browsers.timeLastConnected >= ROOMS.BROWSERS.TIME_TO_PASS_TO_CONNECT_NEW_CLIENT) { - this._rooms.browsers.serverSits = (Blockchain.isPoolActivated ? 10 : 1 ) * ROOMS.BROWSERS.SERVER_FREE_ROOM; - this._rooms.browsers.timeLastConnected = new Date().getTime(); + this._rooms.browsers.serverSits = (Blockchain.isPoolActivated ? 10 : 1 ) * ROOMS.BROWSERS.SERVER_FREE_ROOM; + this._rooms.browsers.timeLastConnected = new Date().getTime(); - } else return NodePropagationList.propagateWaitlistSimple(socket, nodeType, true); //it will also disconnect the socket + } else return NodePropagationList.propagateWaitlistSimple(socket, nodeType, true); //it will also disconnect the socket //check if it is a unique connection, add it to the list @@ -288,8 +288,6 @@ class NodeServer { return 'http' + ( NodeExpress.SSL ? 's' : '') + '://' + await publicIp.v4() + ":" + NodeExpress.port; return 'http' + ( NodeExpress.SSL ? 's' : '') + '://' + NodeExpress.domain + ":" + NodeExpress.port; - - } _disconnectOldSockets() { From 2e3d83adda3c470e667769407def395db0c49e09 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 21:15:09 +0300 Subject: [PATCH 100/132] v16 upgrade --- README.md | 19 --------- package.json | 10 ++--- .../blockchain/global/Blockchain-Genesis.js | 6 +-- .../Interface-Blockchain-Address-Helper.js | 2 +- .../blocks/Interface-Blockchain-Block.js | 4 +- .../blocks/Interface-Blockchain-Blocks.js | 2 +- .../Interface-Blockchain-Mining-Workers.js | 4 +- .../mining/Interface-Blockchain-Mining.js | 2 +- .../mining/backbone/Workers.js | 8 ++-- .../backbone/workers/Backbone-Worker.js | 10 ++--- .../Interface-Blockchain-Transactions.js | 2 +- .../Interface-Blockchain-Transaction-From.js | 8 ++-- ...nterface-Blockchain-Transactions-Wizard.js | 2 +- .../blocks/Mini-Blockchain-Block.js | 2 +- .../protocol/Mini-Blockchain-Protocol.js | 2 +- .../light/Mini-Blockchain-Light-Fork.js | 6 ++- .../Mini-Blockchain-Accountant-Tree-Node.js | 12 +++--- .../state/Mini-Blockchain-Accountant-Tree.js | 4 +- .../protocol/PPoW-Blockchain-Protocol.js | 2 +- .../crypto/Argon2/browser/Argon2-Browser.js | 2 +- .../Argon2-Browser-WebAssembly.js | 2 +- src/common/crypto/WebDollar-Crypto-Data.js | 18 ++++----- src/common/crypto/WebDollar-Crypto.js | 11 ++--- src/common/crypto/ed25519.js | 6 +-- src/common/mining-pools/common/Pools-Utils.js | 2 +- .../mining-pools/miner/Miner-Pool-Settings.js | 4 +- .../miner/mining/Miner-Pool-Mining.js | 4 +- .../pool/pool-management/Pool-Settings.js | 2 +- .../pool-management/pool-work/Pool-Work.js | 6 +-- .../Pool-Connected-Miners-Protocol.js | 2 +- .../satoshmindb/Interface-SatoshminDB.js | 4 +- .../protocol/extend-socket/Socket-Protocol.js | 2 +- src/common/trees/Interface-Tree-Node.js | 2 +- .../merkle-tree/Interface-Merkle-Tree-Node.js | 6 +-- src/common/utils/BufferExtended.js | 4 +- src/common/utils/Serialization.js | 24 +++++------ .../wallet/Main-Blockchain-Wallet.js | 2 +- .../node-server/express/Node-Express.js | 14 +++---- ...erface-Blockchain-Block-LocalStore.test.js | 6 +-- .../Interface-Blockchain-LocalStore.test.js | 8 ++-- .../Interface-Blockchain-Transactions.test.js | 2 +- .../mining-pools/miner/MinerProtocol.test.js | 40 +++++++++---------- .../PoolLeaderProtocol.test.js | 2 +- .../Mini-Blockchain-Accountant-Tree.test.js | 14 +++---- .../PPoW-Blockchain-Block-LocalStore.test.js | 10 ++--- .../PPoW-Blockchain-Interlink.test.js | 6 +-- src/tests/crypto/Argon2.test.js | 6 +-- src/tests/crypto/WebDollar-Crypto.test.js | 6 +-- .../satoshmindb/Interface-SatoshminDB.test.js | 10 ++--- src/tests/trees/Interface-Merkle-Tree.test.js | 4 +- .../helpers/Interface-Tree.test.helper.js | 12 +++--- ...rface-Accountant-Radix-Tree.test.helper.js | 14 +++---- .../Interface-Merkle-Radix-Tree.test.js | 6 +-- 53 files changed, 175 insertions(+), 195 deletions(-) diff --git a/README.md b/README.md index 8880932fc..5ef7c5f7a 100644 --- a/README.md +++ b/README.md @@ -91,25 +91,6 @@ env CXX=g++-5 npm install argon2 Tutorial based on https://github.com/ranisalt/node-argon2/issues/29 - -### Install x509 on Windows -Open a powershell terminal -```shell -npm install --python=python2.7 -git clone https://github.com/ReadyTalk/win32.git -mkdir C:\OpenSSL-Win64\lib\ -cp .\win32\msvc\lib\libeay32.lib C:\OpenSSL-Win64\lib\ -rm -r -fo .\win32\ -``` -Or a command prompt (``cmd.exe``): -```shell -npm install --python=python2.7 -git clone https://github.com/ReadyTalk/win32.git -md C:\OpenSSL-Win64\lib\ -copy /y .\win32\msvc\lib\libeay32.lib C:\OpenSSL-Win64\lib\ -rd /s /q .\win32\ -``` - ## 4. SSL (Secure Socket Layer) Certificate WebDollar uses SSL (Secured Socket Layer) and in order to generate your SSL Certificate you need a Domain or to generate your own SSL Certificate for your IP diff --git a/package.json b/package.json index 9e1e4e389..66b23cb87 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ }, "homepage": "https://github.com/WebDollar/Node-WebDollar#readme", "dependencies": { - "argon2": "^0.19.3", + "@ghaiklor/x509": "^1.1.0", + "argon2": "^0.28.2", "argon2-browser": "1.1.0", "atob": "^2.0.3", "babel-plugin-module-alias": "^1.6.0", @@ -73,11 +74,11 @@ "mnemonic.js": "0.0.1", "module": "^1.2.5", "my-ip": "^1.1.1", - "node-gyp": "^3.6.2", + "node-gyp": "^8.1.0", "opn": "^5.2.0", "path": "^0.12.7", - "pouchdb-node": "^6.4.3", - "pouchdb-browser": "^7.0.0", + "pouchdb-browser": "^7.2.2", + "pouchdb-node": "^7.2.2", "public-ip": "^2.4.0", "raven": "^2.6.4", "readline": "^1.3.0", @@ -89,7 +90,6 @@ "tweetnacl": "^1.0.0", "uuid": "^3.2.1", "webworkify-webpack": "^2.1.1", - "x509": "^0.3.3", "zlib": "^1.0.5" }, "devDependencies": { diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 15f39648b..89a0726e7 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -5,7 +5,7 @@ class BlockchainGenesis{ constructor(){ - this.hashPrev = new Buffer("731D46C131EB6DD4667A96BDC27BAF9223BEC72C3468DFB6BA52C460E76423A4", "hex"); //main net + this.hashPrev = Buffer.from("731D46C131EB6DD4667A96BDC27BAF9223BEC72C3468DFB6BA52C460E76423A4", "hex"); //main net this.timeStamp = 0; @@ -14,8 +14,8 @@ class BlockchainGenesis{ else this.timeStampOffset = 1529344475; //test net - this.difficultyTarget = new Buffer ( "00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex" ); //hard difficulty - this.difficultyTargetPOS = new Buffer ( "00000000000006ece3173c784c7d4871c061a1f20eca8f33aa76fb15846e0c13", "hex" ); //smallest difficulty + this.difficultyTarget = Buffer.from ( "00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex" ); //hard difficulty + this.difficultyTargetPOS = Buffer.from ( "00000000000006ece3173c784c7d4871c061a1f20eca8f33aa76fb15846e0c13", "hex" ); //smallest difficulty this.address = BufferExtended.fromBase("WEBD$gBzsiV+$FARK8qSGqs09V6AEDBi#@fP6n7$"); // genesis address diff --git a/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper.js b/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper.js index f7d3898c5..478357800 100644 --- a/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper.js +++ b/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address-Helper.js @@ -106,7 +106,7 @@ class InterfaceBlockchainAddressHelper{ if (showDebug) console.log("pubKey", pubKey); - return new Buffer(pubKey); + return Buffer.from(pubKey); } static verifySignedData(msg, signature, pubKey){ diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js index 7deda4b6b..6f956a1b0 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block.js @@ -239,7 +239,7 @@ class InterfaceBlockchainBlock { Serialization.serializeNumber2Bytes( this.version ), Serialization.serializeToFixedBuffer( consts.BLOCKCHAIN.BLOCKS_POW_LENGTH , this.hashPrev ), Serialization.serializeNumber4Bytes( this.timeStamp ), - (this.height > consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) ? Serialization.serializeToFixedBuffer( consts.BLOCKCHAIN.BLOCKS_POW_LENGTH , this.hashChainPrev ) : new Buffer(0), + (this.height > consts.BLOCKCHAIN.HARD_FORKS.POS_ACTIVATION) ? Serialization.serializeToFixedBuffer( consts.BLOCKCHAIN.BLOCKS_POW_LENGTH , this.hashChainPrev ) : Buffer.alloc(0), //data contains addressMiner, transactions history, contracts, etc this.data.serializeData(requestHeader), @@ -338,7 +338,7 @@ class InterfaceBlockchainBlock { deserializeBlock(buffer, height, reward, difficultyTargetPrev, offset = 0, blockLengthValidation = true, onlyHeader = false){ if (!Buffer.isBuffer(buffer) && typeof buffer === "string") - buffer = new Buffer(buffer, "hex"); + buffer = Buffer.from(buffer, "hex"); if ( height ) this.height = height||0; if (reward ) this.reward = reward; diff --git a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Blocks.js b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Blocks.js index 46fcd55d3..8da910663 100644 --- a/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Blocks.js +++ b/src/common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Blocks.js @@ -29,7 +29,7 @@ class InterfaceBlockchainBlocks{ this.blocksStartingPoint = 0; this._length = 0; this.chainWork = BigInteger(0); - this.chainWorkSerialized = new Buffer(0); + this.chainWorkSerialized = Buffer.alloc(0); this._networkHashRate = 0 ; diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Workers.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Workers.js index 0c98a1648..7c706b23b 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Workers.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining-Workers.js @@ -212,7 +212,7 @@ class InterfaceBlockchainMiningWorkers extends InterfaceBlockchainMining { - this.bestHash = new Buffer(event.data.hash); + this.bestHash = Buffer.from(event.data.hash); this.bestHashNonce = event.data.nonce; if (this.bestHash.compare(this.difficulty) <= 0) { @@ -222,7 +222,7 @@ class InterfaceBlockchainMiningWorkers extends InterfaceBlockchainMining { this._workerResolve({ result: true, - hash: new Buffer(event.data.hash), + hash: Buffer.from(event.data.hash), nonce: event.data.nonce, }); diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js index b443a13bc..4d6f854f3 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js @@ -397,7 +397,7 @@ class InterfaceBlockchainMining extends InterfaceBlockchainMiningBasic{ if (start < 0 || end < 0 || start > end) return { result: false, - hash: new Buffer(consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER), + hash: Buffer.from(consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER), nonce: -1, }; diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js b/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js index 26fb682d6..298e9cddc 100644 --- a/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js +++ b/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js @@ -316,7 +316,7 @@ class Workers { let hash; if (msg.hash.length === 64) hash = Buffer.from(msg.hash, "hex"); - else hash = new Buffer(msg.hash); + else hash = Buffer.from(msg.hash); let nonce = parseInt(msg.nonce); @@ -326,7 +326,7 @@ class Workers { this._stopAndResolve(true, hash, nonce); - // console.log("sol",new Buffer(msg.hash).toString("hex")); + // console.log("sol",Buffer.from(msg.hash).toString("hex")); return true; } @@ -341,7 +341,7 @@ class Workers { let bestHash; if (msg.bestHash.length === 64) bestHash = Buffer.from(msg.bestHash, "hex"); - else bestHash = new Buffer(msg.bestHash); + else bestHash = Buffer.from(msg.bestHash); let change = false; for (let i = 0, l = this.ibb.bestHash.length; i < l; i++) @@ -378,7 +378,7 @@ class Workers { if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp" || consts.TERMINAL_WORKERS.TYPE === "gpu") { //validate hash - let nonceBuffer = new Buffer([nonce >> 24 & 0xff, nonce >> 16 & 0xff, nonce >> 8 & 0xff, nonce & 0xff]); + let nonceBuffer = Buffer.from([nonce >> 24 & 0xff, nonce >> 16 & 0xff, nonce >> 8 & 0xff, nonce & 0xff]); let block = Buffer.concat([this.block, nonceBuffer]); let hash = await Argon2.hash(block); diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js b/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js index 28f4ad054..5438c599b 100644 --- a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js +++ b/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js @@ -49,23 +49,23 @@ var sendMessage = (msg) => { * @return {Boolean} */ -var difficulty = new Buffer(32); +var difficulty = Buffer.alloc(32); var start = 0; var end = 0; var blockId = 0; var length = 0; var buffer = 0; -var bestHash = new Buffer(32); +var bestHash = Buffer.alloc(32); var bestNonce = 0; var mineNoncesBatch = (myBlock, myDifficulty, myStart, myBatch, myBlockId) => { - myBlock = new Buffer(myBlock); - difficulty = new Buffer(myDifficulty); + myBlock = Buffer.from(myBlock); + difficulty = Buffer.from(myDifficulty); // pool mining length = myBlock.length; - buffer = Buffer.concat([myBlock, new Buffer(4) ]); + buffer = Buffer.concat([myBlock, Buffer.alloc(4) ]); start = parseInt(myStart); end = parseInt(myStart) + parseInt(myBatch); diff --git a/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions.js b/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions.js index 7a11d6918..486ce5e2a 100644 --- a/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions.js +++ b/src/common/blockchain/interface-blockchain/transactions/Interface-Blockchain-Transactions.js @@ -42,7 +42,7 @@ class InterfaceBlockchainTransactions extends InterfaceBlockchainTransactionsEve _createTransactionFromBuffer(buffer, offset = 0){ - let transaction = this._createTransaction ( undefined, undefined, 0, 0xFFFFFFFF, 0x00, new Buffer(32), false, false, false, false, false, false ); + let transaction = this._createTransaction ( undefined, undefined, 0, 0xFFFFFFFF, 0x00, Buffer.alloc(32), false, false, false, false, false, false ); offset = transaction.deserializeTransaction(buffer, offset); return {transaction: transaction, offset: offset}; } diff --git a/src/common/blockchain/interface-blockchain/transactions/transaction/Interface-Blockchain-Transaction-From.js b/src/common/blockchain/interface-blockchain/transactions/transaction/Interface-Blockchain-Transaction-From.js index 5870d8efd..af87a7abc 100644 --- a/src/common/blockchain/interface-blockchain/transactions/transaction/Interface-Blockchain-Transaction-From.js +++ b/src/common/blockchain/interface-blockchain/transactions/transaction/Interface-Blockchain-Transaction-From.js @@ -71,13 +71,13 @@ class InterfaceBlockchainTransactionFrom { } if (typeof fromObject.publicKey === "string") - fromObject.publicKey = new Buffer(fromObject.publicKey, "hex"); + fromObject.publicKey = Buffer.from(fromObject.publicKey, "hex"); if (typeof fromObject.signature === "string") - fromObject.signature = new Buffer(fromObject.signature, "hex"); + fromObject.signature = Buffer.from(fromObject.signature, "hex"); if ( !fromObject.signature ) - fromObject.signature = new Buffer(consts.TRANSACTIONS.SIGNATURE_SCHNORR.LENGTH); + fromObject.signature = Buffer.alloc(consts.TRANSACTIONS.SIGNATURE_SCHNORR.LENGTH); if (typeof fromObject.amount === "string") fromObject.amount = parseInt(fromObject.amount); @@ -93,7 +93,7 @@ class InterfaceBlockchainTransactionFrom { } if ( !currencyTokenId ) { - currencyTokenId = new Buffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); + currencyTokenId = Buffer.alloc(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); currencyTokenId[0] = consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.VALUE; } diff --git a/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js b/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js index 155985e9d..0ba94e0b3 100644 --- a/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js +++ b/src/common/blockchain/interface-blockchain/transactions/wizard/Interface-Blockchain-Transactions-Wizard.js @@ -229,7 +229,7 @@ class InterfaceBlockchainTransactionsWizard{ } calculateFeeSimple(){ - return this.calculateFeeWizzard( new Buffer(141) ); + return this.calculateFeeWizzard( Buffer.alloc(141) ); } } diff --git a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js index 346d5b25e..3edd50224 100644 --- a/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js +++ b/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js @@ -228,7 +228,7 @@ class MiniBlockchainBlock extends inheritBlockchainBlock { ]; if ( this.posMinerAddress === undefined) - buffers.push(new Buffer(1)); + buffers.push( Buffer.alloc(1)); else { buffers.push(Serialization.serializeNumber1Byte(this.posMinerAddress.length)); diff --git a/src/common/blockchain/mini-blockchain/protocol/Mini-Blockchain-Protocol.js b/src/common/blockchain/mini-blockchain/protocol/Mini-Blockchain-Protocol.js index 565aa0cd7..52f8a614d 100644 --- a/src/common/blockchain/mini-blockchain/protocol/Mini-Blockchain-Protocol.js +++ b/src/common/blockchain/mini-blockchain/protocol/Mini-Blockchain-Protocol.js @@ -24,7 +24,7 @@ class MiniBlockchainProtocol extends inheritProtocol{ if (typeof data.header.data.hashAccountantTree === 'string') data.header.data.hashAccountantTree = Serialization.fromBase(data.header.data.hashAccountantTree); else - data.header.data.hashAccountantTree = new Buffer(data.header.data.hashAccountantTree); + data.header.data.hashAccountantTree = Buffer.from(data.header.data.hashAccountantTree); } _initializeNewSocket(nodesListObject) { diff --git a/src/common/blockchain/mini-blockchain/protocol/light/Mini-Blockchain-Light-Fork.js b/src/common/blockchain/mini-blockchain/protocol/light/Mini-Blockchain-Light-Fork.js index fbaff556e..179583270 100644 --- a/src/common/blockchain/mini-blockchain/protocol/light/Mini-Blockchain-Light-Fork.js +++ b/src/common/blockchain/mini-blockchain/protocol/light/Mini-Blockchain-Light-Fork.js @@ -140,9 +140,11 @@ class MiniBlockchainLightFork extends MiniBlockchainFork { this._blocksStartingPointClone = this.blockchain.blocks.blocksStartingPoint; this._lightAccountantTreeSerializationsHeightClone = this.blockchain.lightAccountantTreeSerializations[diffIndex] !== undefined; this._lightAccountantTreeSerializationsHeightCloneGzipped = this.blockchain.lightAccountantTreeSerializationsGzipped[diffIndex] !== undefined ? this.blockchain.lightAccountantTreeSerializationsGzipped[diffIndex] : 0; - this._lightPrevDifficultyTargetClone = new Buffer(this.blockchain.lightPrevDifficultyTargets[diffIndex] !== undefined ? this.blockchain.lightPrevDifficultyTargets[diffIndex] : 0); + + this._lightPrevDifficultyTargetClone = Buffer.isBuffer( this.blockchain.lightPrevDifficultyTargets[diffIndex] ) ? Buffer.from(this.blockchain.lightPrevDifficultyTargets[diffIndex]) : Buffer.alloc( 0 ) this._lightPrevTimeStampClone = this.blockchain.lightPrevTimeStamps[diffIndex]; - this._lightPrevHashPrevClone = new Buffer(this.blockchain.lightPrevHashPrevs[diffIndex] !== undefined ? this.blockchain.lightPrevHashPrevs[diffIndex] : 0); + + this._lightPrevHashPrevClone = Buffer.isBuffer( this.blockchain.lightPrevHashPrevs[diffIndex] ) ? Buffer.from( this.blockchain.lightPrevHashPrevs[diffIndex] ) : Buffer.alloc(0); //it is just a simple fork return MiniBlockchainFork.prototype.preForkClone.call(this, true, true ); diff --git a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js index 2e7c7e347..df97cb25a 100644 --- a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js +++ b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree-Node.js @@ -14,7 +14,7 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ super(root, parent, edges); //console.log("value", value); - this.hash = new Buffer(32); + this.hash = Buffer.alloc(32); this.total = 0; if ( value ) { @@ -37,7 +37,7 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ updateBalanceToken(value, tokenId){ if ( !tokenId ) { - tokenId = new Buffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); + tokenId = Buffer.alloc(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); tokenId[0] = consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.VALUE; } @@ -96,7 +96,7 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ getBalance(tokenId){ if ( !tokenId ) { - tokenId = new Buffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); + tokenId = Buffer.alloc(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); tokenId[0] = consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.VALUE; } @@ -176,9 +176,9 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ let hash = InterfaceMerkleRadixTreeNode.prototype.serializeNodeDataHash.call(this, includeHashes); - if ( !hash ) hash = new Buffer(0); + if ( !hash ) hash = Buffer.alloc(0); - let dataBuffer = new Buffer(0); + let dataBuffer = Buffer.alloc(0); if ( this.isLeaf() ) { @@ -197,7 +197,7 @@ class MiniBlockchainAccountantTreeNode extends InterfaceMerkleRadixTreeNode{ if (WEBDTokenIndex === null) { if (this.balances.length > 0) { - let idWEBD = new Buffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); + let idWEBD = Buffer.alloc(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); idWEBD[0] = consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.VALUE; balancesBuffers.push(this._serializeBalanceWEBDToken({id: idWEBD, amount: 0})); diff --git a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree.js b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree.js index a6e15172b..392b6f865 100644 --- a/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree.js +++ b/src/common/blockchain/mini-blockchain/state/Mini-Blockchain-Accountant-Tree.js @@ -32,7 +32,7 @@ class MiniBlockchainAccountantTree extends MiniBlockchainAccountantTreeEvents { updateAccount(address, value, tokenId, revertActions, showUpdate = true) { if ( !tokenId ) { - tokenId = new Buffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); + tokenId = Buffer.alloc(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); tokenId[0] = consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.VALUE; } @@ -222,7 +222,7 @@ class MiniBlockchainAccountantTree extends MiniBlockchainAccountantTreeEvents { calculateNodeCoins(tokenId, node) { if (!tokenId ) { - tokenId = new Buffer(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); + tokenId = Buffer.alloc(consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.LENGTH); tokenId[0] = consts.MINI_BLOCKCHAIN.TOKENS.WEBD_TOKEN.VALUE; } diff --git a/src/common/blockchain/ppow-blockchain/protocol/PPoW-Blockchain-Protocol.js b/src/common/blockchain/ppow-blockchain/protocol/PPoW-Blockchain-Protocol.js index 222ef9650..5358b1ba5 100644 --- a/src/common/blockchain/ppow-blockchain/protocol/PPoW-Blockchain-Protocol.js +++ b/src/common/blockchain/ppow-blockchain/protocol/PPoW-Blockchain-Protocol.js @@ -68,7 +68,7 @@ class PPoWBlockchainProtocol extends InterfaceBlockchainProtocol{ if (serialization.length - 1 - data.starting > 0) serialization = BufferExtended.substr(serialization, data.starting, Math.min(data.length, serialization.length - data.starting)); else - serialization = new Buffer(0); + serialization = Buffer.alloc(0); return socket.node.sendRequest("get/nipopow-blockchain/headers/get-proofs/pi-gzip/answer", { result: true, diff --git a/src/common/crypto/Argon2/browser/Argon2-Browser.js b/src/common/crypto/Argon2/browser/Argon2-Browser.js index 0a149d570..1fea23820 100644 --- a/src/common/crypto/Argon2/browser/Argon2-Browser.js +++ b/src/common/crypto/Argon2/browser/Argon2-Browser.js @@ -60,7 +60,7 @@ class Argon2Browser{ let result = await argon2.hash(params); //console.log("ARgon2Browser", result.hash); - return new Buffer(result.hash); + return Buffer.from(result.hash); } catch (Exception){ console.log("Argon2 exception hashJavascript", Exception) diff --git a/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js b/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js index 96cbb83a6..8efe65373 100644 --- a/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js +++ b/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js @@ -130,7 +130,7 @@ class Argon2BrowserWebAssembly{ //console.log("result", result) - return new Buffer(result.hash); + return Buffer.from(result.hash); } catch (Exception){ console.error("Argon2 exception hash", Exception) diff --git a/src/common/crypto/WebDollar-Crypto-Data.js b/src/common/crypto/WebDollar-Crypto-Data.js index 7a89b951d..0f4e3a68e 100644 --- a/src/common/crypto/WebDollar-Crypto-Data.js +++ b/src/common/crypto/WebDollar-Crypto-Data.js @@ -24,7 +24,7 @@ class WebDollarCryptoData { if (WebDollarCryptoData.isWebDollarCryptoData(object)){ if (forceToCreate) - return new WebDollarCryptoData( new Buffer(object.buffer), "buffer" ); + return new WebDollarCryptoData( Buffer.from(object.buffer) ); return object; } @@ -32,7 +32,7 @@ class WebDollarCryptoData { let cryptoData = new WebDollarCryptoData(object); if (forceToCreate && cryptoData.buffer ) { - cryptoData.buffer = new Buffer(cryptoData.buffer); + cryptoData.buffer = Buffer.from(cryptoData.buffer); } return cryptoData; @@ -46,23 +46,23 @@ class WebDollarCryptoData { this.buffer = data; else if (type === "hex") - this.buffer = new Buffer(data, "hex"); + this.buffer = Buffer.from(data, "hex"); else if (type === "base") - this.buffer = new Buffer(BufferExtended.fromBase(data)); //if it is string, it must be a Base string + this.buffer = Buffer.from(BufferExtended.fromBase(data)); //if it is string, it must be a Base string else if (type === "utf-8") - this.buffer = new Buffer(data, "utf-8"); + this.buffer = Buffer.from(data, "utf-8"); else if (type === "ascii" || typeof data === "string") - this.buffer = new Buffer(data, "ascii"); + this.buffer = Buffer.from(data, "ascii"); else if (type === "byte" || Array.isArray(data)) //if it is array { if (data.length > 0 && typeof data[0] === "object" ) this.buffer = this.createBufferFromArray(data); else // byte array - this.buffer = new Buffer(data); + this.buffer = Buffer.from(data); } else if (type === "object" || typeof data === "object"){ @@ -80,7 +80,7 @@ class WebDollarCryptoData { } if ( !data ) - this.buffer = new Buffer ( [0] ); + this.buffer = Buffer.from ( [0] ); else this.buffer = this.createBufferFromArray(data); @@ -123,7 +123,7 @@ class WebDollarCryptoData { if (newValue ) return newValue.buffer; else - return new Buffer( [0] ); + return Buffer.from( [0] ); } toHex(){ diff --git a/src/common/crypto/WebDollar-Crypto.js b/src/common/crypto/WebDollar-Crypto.js index 3382f8edc..b33ddc698 100644 --- a/src/common/crypto/WebDollar-Crypto.js +++ b/src/common/crypto/WebDollar-Crypto.js @@ -12,7 +12,7 @@ class WebDollarCrypto { static encodeBase64(buffer) { if (!Buffer.isBuffer(buffer)) - buffer = new Buffer(buffer); + buffer = Buffer.from(buffer); let result = buffer.toString('base64'); @@ -47,17 +47,14 @@ class WebDollarCrypto { else newStr += str[i]; } - let result = new Buffer(newStr, 'base64'); + let result = Buffer.from(newStr, 'base64'); return result; } - static getBufferRandomValues(count){ + static getBufferRandomValues(count = 32){ - if (count === undefined) - count = 32; - - let randArr = new Buffer(count); //create a typed array of 32 bytes (256 bits) + let randArr = Buffer.alloc(count); //create a typed array of 32 bytes (256 bits) // if ( typeof window !== 'undefined' && window.crypto !==undefined) // window.crypto.getRandomValues(randArr) //populate array with cryptographically secure random numbers diff --git a/src/common/crypto/ed25519.js b/src/common/crypto/ed25519.js index b26c84aab..5f503627b 100644 --- a/src/common/crypto/ed25519.js +++ b/src/common/crypto/ed25519.js @@ -19,7 +19,7 @@ class ED25519{ else privateKey = nacl.sign.keyPair.fromSecretKey(fromSecret).secretKey; if ( ! Buffer.isBuffer(privateKey) ) - privateKey = new Buffer(privateKey); + privateKey = Buffer.from(privateKey); return privateKey; } @@ -31,7 +31,7 @@ class ED25519{ let publicKey = nacl.sign.keyPair.fromSecretKey(secretKey).publicKey; if (!Buffer.isBuffer(publicKey)) - publicKey = new Buffer(publicKey); + publicKey = Buffer.from(publicKey); return publicKey; @@ -45,7 +45,7 @@ class ED25519{ let signature = nacl.sign.detached( data, secretKey ); if ( !Buffer.isBuffer(signature) ) - signature = new Buffer(signature); + signature = Buffer.from(signature); return signature; diff --git a/src/common/mining-pools/common/Pools-Utils.js b/src/common/mining-pools/common/Pools-Utils.js index 71dc9199c..b26d5ddf0 100644 --- a/src/common/mining-pools/common/Pools-Utils.js +++ b/src/common/mining-pools/common/Pools-Utils.js @@ -209,7 +209,7 @@ class PoolsUtils { let poolPublicKey = this.substr(url); url = this.substrNext(url); - poolPublicKey = new Buffer(poolPublicKey, "hex"); + poolPublicKey = Buffer.from(poolPublicKey, "hex"); let poolWebsite = ''; diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index 1e2aef075..e4f917ed6 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -32,7 +32,7 @@ class MinerPoolSettings { this.poolWebsite = ""; this.poolDescription = ""; this.poolServers = []; - this.poolPublicKey = new Buffer(0); + this.poolPublicKey = Buffer.alloc(0); this.poolUseSignatures = false; this.poolURLReferral = ''; @@ -181,7 +181,7 @@ class MinerPoolSettings { for (let key in this.poolsList) list[key] = this.poolsList[key]; - let result = await this._db.save("minerPool_poolsList", new Buffer( JSON.stringify( list ), "ascii") ); + let result = await this._db.save("minerPool_poolsList", Buffer.from( JSON.stringify( list ), "ascii") ); return result; } diff --git a/src/common/mining-pools/miner/mining/Miner-Pool-Mining.js b/src/common/mining-pools/miner/mining/Miner-Pool-Mining.js index 10ae3b428..76f7fa99c 100644 --- a/src/common/mining-pools/miner/mining/Miner-Pool-Mining.js +++ b/src/common/mining-pools/miner/mining/Miner-Pool-Mining.js @@ -116,7 +116,7 @@ class MinerPoolMining extends InheritedPoolMining { } - let block = new this.blockchain.blockCreator.blockClass( this.blockchain, undefined, 0, new Buffer(32), new Buffer(32), new Buffer(32), new Buffer(32), 0, 0, undefined, work.h, ); + let block = new this.blockchain.blockCreator.blockClass( this.blockchain, undefined, 0, Buffer.alloc(32), Buffer.alloc(32), Buffer.alloc(32), Buffer.alloc(32), 0, 0, undefined, work.h, ); block.deserializeBlock( work.block, work.h, undefined, work.t, undefined, undefined, true, true ); //required data @@ -131,7 +131,7 @@ class MinerPoolMining extends InheritedPoolMining { this._miningWork.height = work.h; this._miningWork.blockId = work.I||work.h; - this._miningWork.blockLastSignature = work.lsig || new Buffer(0 ); + this._miningWork.blockLastSignature = work.lsig || Buffer.alloc(0 ); this._miningWork.difficultyTarget = work.t; this._miningWork.serializedHeader = work.s; diff --git a/src/common/mining-pools/pool/pool-management/Pool-Settings.js b/src/common/mining-pools/pool/pool-management/Pool-Settings.js index a4905a8e7..5d531e203 100644 --- a/src/common/mining-pools/pool/pool-management/Pool-Settings.js +++ b/src/common/mining-pools/pool/pool-management/Pool-Settings.js @@ -30,7 +30,7 @@ class PoolSettings { this._poolReferralFee = 0; this._poolPrivateKey = WebDollarCrypto.getBufferRandomValues(64); - this.poolPublicKey = new Buffer(0); + this.poolPublicKey = Buffer.alloc(0); this.poolAddress = ''; this.poolURL = ''; diff --git a/src/common/mining-pools/pool/pool-management/pool-work/Pool-Work.js b/src/common/mining-pools/pool/pool-management/pool-work/Pool-Work.js index f972d68cb..d94b7855d 100644 --- a/src/common/mining-pools/pool/pool-management/pool-work/Pool-Work.js +++ b/src/common/mining-pools/pool/pool-management/pool-work/Pool-Work.js @@ -62,10 +62,10 @@ class PoolWork { this.lastBlockNonce = 0; //fill with blank info - this.lastBlock.hash = new Buffer( consts.BLOCKCHAIN.BLOCKS_POW_LENGTH ); + this.lastBlock.hash = Buffer.alloc( consts.BLOCKCHAIN.BLOCKS_POW_LENGTH ); if (BlockchainGenesis.isPoSActivated(this.lastBlock.height)) { - this.lastBlock.posMinerPublicKey = new Buffer(consts.ADDRESSES.PUBLIC_KEY.LENGTH ); - this.lastBlock.posSignature = new Buffer(consts.TRANSACTIONS.SIGNATURE_SCHNORR.LENGTH ); + this.lastBlock.posMinerPublicKey = Buffer.alloc(consts.ADDRESSES.PUBLIC_KEY.LENGTH ); + this.lastBlock.posSignature = Buffer.alloc(consts.TRANSACTIONS.SIGNATURE_SCHNORR.LENGTH ); } let error = false; diff --git a/src/common/mining-pools/pool/pool-management/protocol/connected-miners/Pool-Connected-Miners-Protocol.js b/src/common/mining-pools/pool/pool-management/protocol/connected-miners/Pool-Connected-Miners-Protocol.js index 40654c057..f1d0c1e50 100644 --- a/src/common/mining-pools/pool/pool-management/protocol/connected-miners/Pool-Connected-Miners-Protocol.js +++ b/src/common/mining-pools/pool/pool-management/protocol/connected-miners/Pool-Connected-Miners-Protocol.js @@ -114,7 +114,7 @@ class PoolConnectedMinersProtocol extends PoolProtocolList{ //generate a message for confirming pool Owner let messageAddressConfirmation = undefined; if ( Blockchain.Wallet.getAddress(unencodedAddress) ) - messageAddressConfirmation = new Buffer(32); + messageAddressConfirmation = Buffer.alloc(32); let work = await this.poolManagement.generatePoolWork(minerInstance, true); minerInstance.lastWork = work; diff --git a/src/common/satoshmindb/Interface-SatoshminDB.js b/src/common/satoshmindb/Interface-SatoshminDB.js index f4fd62f9f..59a669949 100644 --- a/src/common/satoshmindb/Interface-SatoshminDB.js +++ b/src/common/satoshmindb/Interface-SatoshminDB.js @@ -90,7 +90,7 @@ class InterfaceSatoshminDB { if (!response ) return null; else if ( !response._attachments ) return response.value; - else return new Buffer(atob(response._attachments.key.data).toString('hex'), 'hex'); //get attachment + else return Buffer.from( atob(response._attachments.key.data).toString('hex'), 'hex'); //get attachment } catch (Exception) { @@ -136,7 +136,7 @@ class InterfaceSatoshminDB { if (process.env.BROWSER && Buffer.isBuffer(value)) attachment = new Blob([value.toString('hex')]); else //we are in node - attachment = new Buffer(value.toString('hex')); + attachment = Buffer.from( value.toString('hex'), "hex" ); try { diff --git a/src/common/sockets/protocol/extend-socket/Socket-Protocol.js b/src/common/sockets/protocol/extend-socket/Socket-Protocol.js index 42dc8917c..3e0186737 100644 --- a/src/common/sockets/protocol/extend-socket/Socket-Protocol.js +++ b/src/common/sockets/protocol/extend-socket/Socket-Protocol.js @@ -110,7 +110,7 @@ class SocketProtocol { data[prop] = Buffer.from(data[prop]); else if (prop === "type" && data.type === "Buffer" && data.hasOwnProperty("data")) { - data = new Buffer(data); + data = Buffer.from(data); return data; } else diff --git a/src/common/trees/Interface-Tree-Node.js b/src/common/trees/Interface-Tree-Node.js index 963a97c1e..29a429120 100644 --- a/src/common/trees/Interface-Tree-Node.js +++ b/src/common/trees/Interface-Tree-Node.js @@ -55,7 +55,7 @@ class InterfaceTreeNode { buffers.push(Serialization.serializeNumber2Bytes(this.value.length)); buffers.push( this.value ); } else - buffers.push ( new Buffer(2) ); + buffers.push ( Buffer.alloc(2) ); return Buffer.concat(buffer); } diff --git a/src/common/trees/merkle-tree/Interface-Merkle-Tree-Node.js b/src/common/trees/merkle-tree/Interface-Merkle-Tree-Node.js index 1c2b3e670..3eda94140 100644 --- a/src/common/trees/merkle-tree/Interface-Merkle-Tree-Node.js +++ b/src/common/trees/merkle-tree/Interface-Merkle-Tree-Node.js @@ -14,7 +14,7 @@ class InterfaceMerkleTreeNode extends InterfaceTreeNode{ super(root, parent, edges, value); - if ( !hash ) hash = new Buffer(32); + if ( !hash ) hash = Buffer.alloc(32); this.hash = hash; } @@ -110,7 +110,7 @@ class InterfaceMerkleTreeNode extends InterfaceTreeNode{ _computeHash(){ if (this === this.root && this.edges.length === 0){ - this.hash = new Buffer(32); + this.hash = Buffer.alloc(32); return this.hash; } @@ -140,7 +140,7 @@ class InterfaceMerkleTreeNode extends InterfaceTreeNode{ this.edges[i].targetNode._computeHash(); if (i === 0) - hashConcat.push( new Buffer(this.edges[i].targetNode.hash) ); + hashConcat.push( Buffer.from(this.edges[i].targetNode.hash) ); else hashConcat.push ( this.edges[i].targetNode.hash ); } diff --git a/src/common/utils/BufferExtended.js b/src/common/utils/BufferExtended.js index 5d289581f..adddd640f 100644 --- a/src/common/utils/BufferExtended.js +++ b/src/common/utils/BufferExtended.js @@ -16,9 +16,9 @@ class BufferExtended { if (length-index < 0) throw {message: "length-index <= 0...", buffer: buffer.toString("hex"), index:index, length:length, count: count}; - if (length-index === 0) return new Buffer(0); + if (length-index === 0) return Buffer.alloc(0); - let buf = new Buffer(length-index); + let buf = Buffer.alloc(length-index); buffer.copy(buf, 0, index, length); return buf; diff --git a/src/common/utils/Serialization.js b/src/common/utils/Serialization.js index 819136ec5..70d6cd3f6 100644 --- a/src/common/utils/Serialization.js +++ b/src/common/utils/Serialization.js @@ -21,7 +21,7 @@ class Serialization{ } list.reverse(); - let buffer = new Buffer( list.length ); + let buffer = Buffer.alloc( list.length ); for (let i = 0; i < list.length; i++) buffer[i] = list[i]; @@ -44,7 +44,7 @@ class Serialization{ convertBigNumber( bigNumber, length ){ //converting number value into a buffer - let buffer = new Buffer(length); + let buffer = Buffer.alloc(length); let count = length-1; while (bigNumber.isGreaterThan(0)){ @@ -60,7 +60,7 @@ class Serialization{ serializeNumber1Byte(data){ //converting number value into a buffer - let buffer = Buffer(1); + let buffer = Buffer.alloc(1); buffer[0] = (data & 0xff); return buffer; @@ -68,7 +68,7 @@ class Serialization{ serializeNumber2Bytes(data){ //converting number value into a buffer - let buffer = Buffer(2); + let buffer = Buffer.alloc(2); buffer[1] = data & 0xff; buffer[0] = data>>8 & 0xff; @@ -77,7 +77,7 @@ class Serialization{ serializeNumber3Bytes(data){ //converting number value into a buffer - let buffer = Buffer(3); + let buffer = Buffer.alloc(3); buffer[2] = data & 0xff; buffer[1] = data>>8 & 0xff; buffer[0] = data>>16 & 0xff; @@ -87,7 +87,7 @@ class Serialization{ //converting number value into a buffer serializeNumber4Bytes(data){ - let buffer = Buffer(4); + let buffer = Buffer.alloc(4); buffer[3] = data & 0xff; buffer[2] = data>>8 & 0xff; buffer[1] = data>>16 & 0xff; @@ -127,7 +127,7 @@ class Serialization{ serializeNumber7Bytes(long){ // we want to represent the input as a 8-bytes array - var byteArray = new Buffer(7); + var byteArray = Buffer.alloc(7); for ( let index = 0; index < byteArray.length; index ++ ) { let byte = long & 0xff; @@ -170,11 +170,11 @@ class Serialization{ serializeToFixedBuffer(noBytes, buffer){ if (buffer === undefined || buffer === null) - return new Buffer(noBytes); + return Buffer.alloc(noBytes); if (buffer.length === noBytes) // in case has the same number of bits as output return buffer; - let result = new Buffer(noBytes); + let result = Buffer.alloc(noBytes); let c = 0; for (let i = buffer.length-1; i >= 0; i--){ @@ -205,7 +205,7 @@ class Serialization{ offset += hashLength; let deserializedHash = Buffer.concat([ - new Buffer(hashPrefix), + Buffer.from(hashPrefix), hashLeadingZero ]); @@ -223,7 +223,7 @@ class Serialization{ while (count < buffer.length && buffer[count] === 0) count++; - let result = new Buffer(1 + buffer.length - count ); + let result = Buffer.alloc(1 + buffer.length - count ); result [0] = buffer.length - count; for (let i = count; i < buffer.length; i++) @@ -284,7 +284,7 @@ class Serialization{ if ( data.c.length === 0 ) throw "data is 0 and can't be "; - let buffer = new Buffer( 1 + 1 + data.c.length*6 ); + let buffer = Buffer.alloc( 1 + 1 + data.c.length*6 ); buffer[0] = Math.abs(data.e) % 128 + (data.e >= 0 ? 0 : 1)*128; buffer[1] = data.c.length % 128 + (data.s >= 0? 0 : 1)*128; diff --git a/src/main-blockchain/wallet/Main-Blockchain-Wallet.js b/src/main-blockchain/wallet/Main-Blockchain-Wallet.js index 01d098a10..cbb640e09 100644 --- a/src/main-blockchain/wallet/Main-Blockchain-Wallet.js +++ b/src/main-blockchain/wallet/Main-Blockchain-Wallet.js @@ -353,7 +353,7 @@ class MainBlockchainWallet { privateKey = Buffer.from(inputData, "hex"); if (Buffer.isBuffer(inputData)) - privateKey = new Buffer(inputData); + privateKey = Buffer.from(inputData); if (typeof privateKey === "string") privateKey = Buffer.from(privateKey, "hex"); if (typeof publicKey === "string") publicKey = Buffer.from(publicKey, "hex"); diff --git a/src/node/sockets/node-server/express/Node-Express.js b/src/node/sockets/node-server/express/Node-Express.js index d91e6dfaa..022ad79f3 100644 --- a/src/node/sockets/node-server/express/Node-Express.js +++ b/src/node/sockets/node-server/express/Node-Express.js @@ -30,16 +30,14 @@ class NodeExpress{ _extractDomain( fileName ){ - const x509 = require('x509'); - let subject = x509.getSubject( fileName ); + const x509 = require('@ghaiklor/x509'); + const subject = x509.getSubject( fileName ); let domain = subject.commonName; - if (domain === undefined) domain = ''; + if (!domain) domain = ''; - domain = domain.replace( "*.", "" ); - - return domain; + return domain.replace( "*.", "" ); } async startExpress(){ @@ -154,7 +152,9 @@ class NodeExpress{ resolve(true); - }).on('error', (err) => { + }) + + this.server.on('error', (err) => { this.domain = ''; diff --git a/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Block-LocalStore.test.js b/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Block-LocalStore.test.js index 529c2d058..c6c3bfd74 100644 --- a/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Block-LocalStore.test.js +++ b/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Block-LocalStore.test.js @@ -11,9 +11,9 @@ describe('test Interface-Block save/load/remove to/from local storage', () => { let db = new InterfaceSatoshminDB(); let version = consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION; - let hash = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd30ca", "hex"); - let hashPrev = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); - let hashChainPrev = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); + let hash = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd30ca", "hex"); + let hashPrev = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); + let hashChainPrev = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); let timeStamp = Math.trunc(Math.random() * 100000); let nonce = Math.trunc(Math.random() * 1000); let minerAddress = BlockchainGenesis.minerAddress; diff --git a/src/tests/blockchain/interface-blockchain/Interface-Blockchain-LocalStore.test.js b/src/tests/blockchain/interface-blockchain/Interface-Blockchain-LocalStore.test.js index c80a3d1b9..a36714045 100644 --- a/src/tests/blockchain/interface-blockchain/Interface-Blockchain-LocalStore.test.js +++ b/src/tests/blockchain/interface-blockchain/Interface-Blockchain-LocalStore.test.js @@ -16,10 +16,10 @@ describe('test Interface-Blockchain save/load/remove to/from local storage', () //create dummy blocks //it requires real data - let b0 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 0, blockchain.db ); - let b1 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 1, blockchain.db ); - let b2 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 2, blockchain.db ); - let b3 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 3, blockchain.db ); + let b0 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 0, blockchain.db ); + let b1 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 1, blockchain.db ); + let b2 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 2, blockchain.db ); + let b3 = new InterfaceBlockchainBlock( Blockchain.blockchain, Blockchain.blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 3, blockchain.db ); blockchain.blocks.addBlock(b0); blockchain.blocks.addBlock(b1); diff --git a/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Transactions.test.js b/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Transactions.test.js index d6b3ea4ab..fd99f696f 100644 --- a/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Transactions.test.js +++ b/src/tests/blockchain/interface-blockchain/Interface-Blockchain-Transactions.test.js @@ -14,7 +14,7 @@ describe('test transactions', () => { blockchain = new InterfaceBlockchain(); //create dummy blocks - let b0 = new InterfaceBlockchainBlock( blockchain, blockchain.blockValidation, 0, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 0, blockchain.db ); + let b0 = new InterfaceBlockchainBlock( blockchain, blockchain.blockValidation, 0, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 0, blockchain.db ); }); diff --git a/src/tests/blockchain/interface-blockchain/mining-pools/miner/MinerProtocol.test.js b/src/tests/blockchain/interface-blockchain/mining-pools/miner/MinerProtocol.test.js index 9bfbc5fd2..fb5b07951 100644 --- a/src/tests/blockchain/interface-blockchain/mining-pools/miner/MinerProtocol.test.js +++ b/src/tests/blockchain/interface-blockchain/mining-pools/miner/MinerProtocol.test.js @@ -8,53 +8,53 @@ describe('test pool mining', () => { let blocksData = [{ "height":0, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("0001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000004476c1d355b03205412204804e427f9a56de15f10f0c80fc530fecde9a48ae6aede861e9903e5422f7c111358032dfe6ca37aad8bdd5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000a1cfceb215aeac46c0b7eea0d5da9defd927e24504b757e6c3d3702853c9c9901000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("0001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000004476c1d355b03205412204804e427f9a56de15f10f0c80fc530fecde9a48ae6aede861e9903e5422f7c111358032dfe6ca37aad8bdd5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000a1cfceb215aeac46c0b7eea0d5da9defd927e24504b757e6c3d3702853c9c9901000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4", "hex"), "nonce":59172 }, { "height":1, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("000100007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e3300000472920ffd31f9752f90a0bd4c9fba25790b5340d7900b0438273a76b834b9f17856bd87b88551446a84650bdb7525ec27326e55ffd85df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000229cba7cd7926a980ddae11625db7a7a5e0f5a86267d44ab1689f140cd7a4b7303000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33000000", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("000100007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e3300000472920ffd31f9752f90a0bd4c9fba25790b5340d7900b0438273a76b834b9f17856bd87b88551446a84650bdb7525ec27326e55ffd85df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000229cba7cd7926a980ddae11625db7a7a5e0f5a86267d44ab1689f140cd7a4b7303000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33000000", "hex"), "nonce":15398 }, { "height":2, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("0001000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb60000047e5feda917aaa3bb30a8ed20eb69b20704f19f173e0148d3dc69b6db8172b48a22ce5ac968eb922693d0cb5894ec3d1774a0cc67515df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000321cf1c8157a085a6c2cb0e3e3282bf79d535f51b6cac06f58236336ca50c0ef03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000003000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb600000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("0001000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb60000047e5feda917aaa3bb30a8ed20eb69b20704f19f173e0148d3dc69b6db8172b48a22ce5ac968eb922693d0cb5894ec3d1774a0cc67515df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000321cf1c8157a085a6c2cb0e3e3282bf79d535f51b6cac06f58236336ca50c0ef03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000003000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb600000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33", "hex"), "nonce":20467 }, { "height":3, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("0001000283c869d2359cd18433f8ca570cf7ea4694e8b46c29e33fb53a602f0d6a910000048eb2d8f9e2ba00ffc6a28346aa796ab80adcce01b3c803aa10ce0d5124206944caf37c68c72b61d58bbdc64d4db422ed568e47c7655df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000ab5f994c54c3b182a4a42c2f8f2b4cbfa94aa6783e6aeae33ec83f8aa0bd53b703000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000003000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb600000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("0001000283c869d2359cd18433f8ca570cf7ea4694e8b46c29e33fb53a602f0d6a910000048eb2d8f9e2ba00ffc6a28346aa796ab80adcce01b3c803aa10ce0d5124206944caf37c68c72b61d58bbdc64d4db422ed568e47c7655df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000ab5f994c54c3b182a4a42c2f8f2b4cbfa94aa6783e6aeae33ec83f8aa0bd53b703000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000003000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb600000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33", "hex"), "nonce":7856 }, { "height":4, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("000100008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c0000049466553362b66b767abdff2acd94a93f60f786fe3c7c76732fb24a58327a00c7d58263f7b8b901a9184bf2adaa1f08e84f0be6512a5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000aa8fea4f18a6a81cfbdfa867e477d2330d37a84b7602fdf14c94eb24b258eabb03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c000000", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("000100008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c0000049466553362b66b767abdff2acd94a93f60f786fe3c7c76732fb24a58327a00c7d58263f7b8b901a9184bf2adaa1f08e84f0be6512a5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000aa8fea4f18a6a81cfbdfa867e477d2330d37a84b7602fdf14c94eb24b258eabb03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c000000", "hex"), "nonce":16847 }, { "height":5, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("000100025e446210fbf8daeba9729587a1dba4bd1485fa40c08409f06bad8e3c555a0000049f4700c26257611308d4972a026cd1f3acdc0c675e6a99a37a5bce564b7b94c70117110a69e30df4728841f3b7f082de37dc1326875df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000001766f51dc8ad81f9038b47d828621aae1e969780f3528dd36ff4760075ee39ed03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c000000", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("000100025e446210fbf8daeba9729587a1dba4bd1485fa40c08409f06bad8e3c555a0000049f4700c26257611308d4972a026cd1f3acdc0c675e6a99a37a5bce564b7b94c70117110a69e30df4728841f3b7f082de37dc1326875df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000001766f51dc8ad81f9038b47d828621aae1e969780f3528dd36ff4760075ee39ed03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c000000", "hex"), "nonce":42975 }, { "height":6, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("000100010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f4000004bcf1e6f0aaa41b351e3046d65ac87967dcf0cd70c3ad2ca41250c98ab5823f9bce513b37f90dd143d9a563f2c055e7255f380245f95df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000997d7fcbcfef268f4d3582bcbeaa8fb28acde79969aa4d850605f7f99b28179503000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("000100010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f4000004bcf1e6f0aaa41b351e3046d65ac87967dcf0cd70c3ad2ca41250c98ab5823f9bce513b37f90dd143d9a563f2c055e7255f380245f95df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000997d7fcbcfef268f4d3582bcbeaa8fb28acde79969aa4d850605f7f99b28179503000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), "nonce":23380 }, { "height":7, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("00010001e262d2520d0204552d3cb2c6252994ef7222a747ad26e6aeb68786013bb4000004cdd59005d9d6bd440012612dde35addbfdf13d11f39a59c0332fc191a9b6184320be0cd4a43ebcea56702f2a3a75df55ab844ae70a5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000001b734c258fea2530cc63ff07862749dd0fc30442ada072f98c13d109c690453a03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("00010001e262d2520d0204552d3cb2c6252994ef7222a747ad26e6aeb68786013bb4000004cdd59005d9d6bd440012612dde35addbfdf13d11f39a59c0332fc191a9b6184320be0cd4a43ebcea56702f2a3a75df55ab844ae70a5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000001b734c258fea2530cc63ff07862749dd0fc30442ada072f98c13d109c690453a03000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), "nonce":45429 }, { "height":8, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("000100026bcbe367f8d8da260dfa18d6ad758799cc7d824eb764ef10ae0de9b86d0b000004f00a24f8b240e83991a2cbbc32effd69e72ee8f1071c2b463afca671bd5978ccb4dd62a73d768083ffc308ef673fe32516e6d74b295df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000038696debb9c977c6da04cfacd85b71c06b0840619db8768b4e6edbd70e32b1103000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("000100026bcbe367f8d8da260dfa18d6ad758799cc7d824eb764ef10ae0de9b86d0b000004f00a24f8b240e83991a2cbbc32effd69e72ee8f1071c2b463afca671bd5978ccb4dd62a73d768083ffc308ef673fe32516e6d74b295df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000038696debb9c977c6da04cfacd85b71c06b0840619db8768b4e6edbd70e32b1103000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), "nonce":24499 }, { "height":9, - "difficultyTargetPrev":new Buffer("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), - "computedBlockPrefix":new Buffer("00010001ac6d145215e09a60752063f1fa76ac934da0a4075fb14cac66fb6da9fce9000005034918821cb0567c9c85c36f7826f7801790d685906b8b0a42c0bfd7a756f3b9fb7f0bdb94e13a7664dd3613ce78705fd281d45b4b5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000185739fc474482f42afcdece0d3e81a0b445f7d331f07c44088731275255da303000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), + "difficultyTargetPrev":Buffer.from("00029112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex"), + "computedBlockPrefix":Buffer.from("00010001ac6d145215e09a60752063f1fa76ac934da0a4075fb14cac66fb6da9fce9000005034918821cb0567c9c85c36f7826f7801790d685906b8b0a42c0bfd7a756f3b9fb7f0bdb94e13a7664dd3613ce78705fd281d45b4b5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000185739fc474482f42afcdece0d3e81a0b445f7d331f07c44088731275255da303000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000700010a222f890abf1c34464d2d03428c7af50708a5fb934f867fed72e41403f400000500008a40c66617831ab0a6b7f160b08f228b90ccdb3b12d34fe3c342f6809d8c", "hex"), "nonce":94818 } ]; diff --git a/src/tests/blockchain/interface-blockchain/mining-pools/pool-management/PoolLeaderProtocol.test.js b/src/tests/blockchain/interface-blockchain/mining-pools/pool-management/PoolLeaderProtocol.test.js index a7c24e6ee..e37fe2b1e 100644 --- a/src/tests/blockchain/interface-blockchain/mining-pools/pool-management/PoolLeaderProtocol.test.js +++ b/src/tests/blockchain/interface-blockchain/mining-pools/pool-management/PoolLeaderProtocol.test.js @@ -8,7 +8,7 @@ import PoolLeaderProtocol from 'common/mining-pools/pool/pool-management/protoco describe('test pool leader protocol', () => { - let testTargetHash = new Buffer("00098112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex" ); + let testTargetHash = Buffer.from("00098112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "hex" ); let testMinersList = [ { diff --git a/src/tests/blockchain/mini-blockchain/Mini-Blockchain-Accountant-Tree.test.js b/src/tests/blockchain/mini-blockchain/Mini-Blockchain-Accountant-Tree.test.js index aa5f19387..412e099c7 100644 --- a/src/tests/blockchain/mini-blockchain/Mini-Blockchain-Accountant-Tree.test.js +++ b/src/tests/blockchain/mini-blockchain/Mini-Blockchain-Accountant-Tree.test.js @@ -28,7 +28,7 @@ describe('MiniBlockchainAccountantTree', () => { sum += parseInt(array[i].val); } - assert(!Tree.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); + assert(!Tree.root.hash.equals( Buffer.alloc(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); let response = await Tree.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); @@ -83,7 +83,7 @@ describe('MiniBlockchainAccountantTree', () => { for (let i = 0; i < list.length; i++) assert(Tree.getBalance(list[i].address) === list[i].value, " value is not equal: " +list[i].value+" "+Tree.getBalance(list[i].address)); - assert(!Tree.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); + assert(!Tree.root.hash.equals(Buffer.alloc(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); let response = await Tree.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); @@ -170,7 +170,7 @@ describe('MiniBlockchainAccountantTree', () => { assert(Tree.getBalance(list[i].address) === sum, " value is not equal: " + list[i].value + list[i].value2 + " " + Tree.getBalance(list[i].address)); } - assert(!Tree.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); + assert(!Tree.root.hash.equals(Buffer.alloc(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); let response = await Tree.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); @@ -375,7 +375,7 @@ describe('MiniBlockchainAccountantTree', () => { assert(Tree.getAccountNonce(list[i].address) === sum, " nonce 2 is not equal: " + sum + " " + Tree.getBalance(list[i].address)); } - assert(!Tree.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); + assert(!Tree.root.hash.equals(Buffer.alloc(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); let response = await Tree.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); @@ -554,7 +554,7 @@ describe('MiniBlockchainAccountantTree', () => { assert(Tree.getAccountNonce(list[i].address) === sum, " nonce 2 is not equal: " + sum + " " + Tree.getBalance(list[i].address)); } - assert(!Tree.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); + assert(!Tree.root.hash.equals(Buffer.alloc(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); let response = await Tree.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); @@ -734,7 +734,7 @@ describe('MiniBlockchainAccountantTree', () => { assert(Tree.getAccountNonce(list[i].address) === sum, " nonce 2 is not equal: " + sum + " " + Tree.getBalance(list[i].address)); } - assert(!Tree.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); + assert(!Tree.root.hash.equals(Buffer.alloc(32)), "root hash is not valid "+Tree.root.hash.toString("hex")); let response = await Tree.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); @@ -826,7 +826,7 @@ describe('MiniBlockchainAccountantTree', () => { for (let i = tests.length-1; i >= 0 ; i-- ) assert( Tree1.getBalance( tests[i].address ) === sumAddress(tests[i].address), " balance value is not equal: " + Tree1.getBalance( tests[i].address ) + " " + sumAddress(tests[i].address) ); - assert(!Tree1.root.hash.equals(new Buffer(32)), "root hash is not valid "+Tree1.root.hash.toString("hex")); + assert(!Tree1.root.hash.equals(Buffer.alloc(32)), "root hash is not valid "+Tree1.root.hash.toString("hex")); let response = await Tree1.saveMiniAccountant(true, "MiniBlockchainAccountantTree.test"); assert(response === true, 'save miniblockchain accountant tree : ' + response); diff --git a/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Block-LocalStore.test.js b/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Block-LocalStore.test.js index c7f155708..328bd9aa6 100644 --- a/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Block-LocalStore.test.js +++ b/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Block-LocalStore.test.js @@ -10,11 +10,11 @@ describe('test PPoW-Blocks save/load/remove to/from local storage', () => { let db = new InterfaceSatoshminDB(); let version = consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION; - let hash = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd30ca", "hex"); - let interlinkHash1 = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d70b5462806b92be0cbccd30cb", "hex"); - let interlinkHash2 = new Buffer("7bb3e84e1234c7e76be2beedb94a5678b7f095d50b5462806b92be0cbccd30cc", "hex"); - let hashPrev = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); - let hashChainPrev = new Buffer("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); + let hash = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd30ca", "hex"); + let interlinkHash1 = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d70b5462806b92be0cbccd30cb", "hex"); + let interlinkHash2 = Buffer.from("7bb3e84e1234c7e76be2beedb94a5678b7f095d50b5462806b92be0cbccd30cc", "hex"); + let hashPrev = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); + let hashChainPrev = Buffer.from("7bb3e84e6892c7e76be2beedb94a1035b7f095d50b5462806b92be0cbccd31fa", "hex"); let timeStamp = Math.trunc(Math.random() * 100000); let nonce = Math.trunc(Math.random() * 1000); let minerAddress = BlockchainGenesis.minerAddress; diff --git a/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js b/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js index 5cddcc36b..97e682b4a 100644 --- a/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js +++ b/src/tests/blockchain/ppow-blockchain/PPoW-Blockchain-Interlink.test.js @@ -21,7 +21,7 @@ describe('test PPoW-Blockchain interlink data structure', () => { let height = []; let blockId = []; let blockchain = new MiniBlockcain(); - let block = new MiniBlockcainBlock( blockchain, blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 0, blockchain.db ); + let block = new MiniBlockcainBlock( blockchain, blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, 0, blockchain.db ); for (let i = 0; i < logLen; ++i) { height.push(i); @@ -69,8 +69,8 @@ describe('test PPoW-Blockchain interlink data structure', () => { for (let i = 0; i < serialized.length; ++i) { - let block = new MiniBlockcainBlock( blockchain, blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), new Buffer(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, i, blockchain.db ); - let buffer = new Buffer(serialized[i], 'hex'); + let block = new MiniBlockcainBlock( blockchain, blockchain.createBlockValidation(), consts.TRANSACTIONS.VERSIONS.SCHNORR_VERSION, Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), Buffer.alloc(consts.BLOCKCHAIN.BLOCKS_POW_LENGTH), undefined, undefined, undefined, i, blockchain.db ); + let buffer = Buffer.from(serialized[i], 'hex'); block.deserializeBlock(buffer); diff --git a/src/tests/crypto/Argon2.test.js b/src/tests/crypto/Argon2.test.js index c003f35e4..b882e0fde 100644 --- a/src/tests/crypto/Argon2.test.js +++ b/src/tests/crypto/Argon2.test.js @@ -7,10 +7,10 @@ describe('Argon2', ()=>{ it('Argon2.Hash Buffer ', async ()=>{ - const message1 = new Buffer( TestsHelper.makeId() , "ascii"); - const message1_copy = new Buffer( message1); //it will make a copy + const message1 = Buffer.from( TestsHelper.makeId() , "ascii"); + const message1_copy = Buffer.from( message1); //it will make a copy - const message2 = new Buffer( TestsHelper.makeId() , "ascii"); + const message2 = Buffer.from( TestsHelper.makeId() , "ascii"); let hash1 = await Argon2.hash(message1) let hash1_copy = await Argon2.hash(message1_copy) diff --git a/src/tests/crypto/WebDollar-Crypto.test.js b/src/tests/crypto/WebDollar-Crypto.test.js index a39c935ba..1eb48f2bc 100644 --- a/src/tests/crypto/WebDollar-Crypto.test.js +++ b/src/tests/crypto/WebDollar-Crypto.test.js @@ -40,10 +40,10 @@ describe('WebDollar crypt', ()=>{ //this.timeout(15000); - const message1 = new Buffer ( TestsHelper.makeId(), "ascii"); - const message1_copy = new Buffer (message1); + const message1 = Buffer.from ( TestsHelper.makeId(), "ascii"); + const message1_copy = Buffer.from (message1); - const message2 = new Buffer( TestsHelper.makeId(), "ascii"); + const message2 = Buffer.from( TestsHelper.makeId(), "ascii"); let hash1 = await WebDollarCrypto.hashPOW(message1) let hash1_copy = await WebDollarCrypto.hashPOW(message1_copy) diff --git a/src/tests/satoshmindb/Interface-SatoshminDB.test.js b/src/tests/satoshmindb/Interface-SatoshminDB.test.js index 2f3020ac9..0cd08354b 100644 --- a/src/tests/satoshmindb/Interface-SatoshminDB.test.js +++ b/src/tests/satoshmindb/Interface-SatoshminDB.test.js @@ -94,7 +94,7 @@ describe('interfaceSatoshminDB', () => { it('save/remove/get sample Buffer', async() => { key = Math.floor(Math.random() * 10000).toString(); - value = new Buffer('44FF00234561217fdeca', 'hex'); + value = Buffer.from('44FF00234561217fdeca', 'hex'); db = new InterfaceSatoshminDB(); response = await db.save(key, value); @@ -111,8 +111,8 @@ describe('interfaceSatoshminDB', () => { it('save/save/get sample Buffer test', async () => { key = Math.floor(Math.random() * 10000).toString(); - value = new Buffer('744Fagfe4578ab', 'hex'); - let new_value = new Buffer('7444caed', 'hex'); + value = Buffer.from('744Fagfe4578ab', 'hex'); + let new_value = Buffer.from('7444caed', 'hex'); db = new InterfaceSatoshminDB(); @@ -141,7 +141,7 @@ describe('interfaceSatoshminDB', () => { it('save/get sample Array', async () => { key = Math.floor(Math.random() * 10000).toString(); - value = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + value = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); db = new InterfaceSatoshminDB(); response = await db.save(key, value); @@ -156,7 +156,7 @@ describe('interfaceSatoshminDB', () => { key = Math.floor(Math.random() * 10000).toString(); value = 'my string value'; - let new_value = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + let new_value = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); db = new InterfaceSatoshminDB(); response = await db.save(key, value); diff --git a/src/tests/trees/Interface-Merkle-Tree.test.js b/src/tests/trees/Interface-Merkle-Tree.test.js index fc8a67541..be956e02f 100644 --- a/src/tests/trees/Interface-Merkle-Tree.test.js +++ b/src/tests/trees/Interface-Merkle-Tree.test.js @@ -24,7 +24,7 @@ describe('interfaceMerkleTree', () => { let parent = merkleTree.root.edges[ 0 ].targetNode; - merkleTree.add( new Buffer(str, "ascii") , parent); + merkleTree.add( Buffer.from(str, "ascii") , parent); assert(merkleTree.validateRoot() === true, "Merkle Tree is invalid!!!"); }); @@ -54,7 +54,7 @@ describe('interfaceMerkleTree', () => { let edgeIndex = merkleTree.root.edges.length; let parent = merkleTree.root.edges[ Math.floor( Math.random() * edgeIndex) ].targetNode; - merkleTree.add( new Buffer(str, "ascii"), parent); + merkleTree.add( Buffer.from(str, "ascii"), parent); assert(merkleTree.validateRoot() === true, "Merkle Tree is invalid!!!"); diff --git a/src/tests/trees/helpers/Interface-Tree.test.helper.js b/src/tests/trees/helpers/Interface-Tree.test.helper.js index d2b387584..39ea8e592 100644 --- a/src/tests/trees/helpers/Interface-Tree.test.helper.js +++ b/src/tests/trees/helpers/Interface-Tree.test.helper.js @@ -18,7 +18,7 @@ class InterfaceTreeTestHelper { if ( !createValue ) createValue = true; radixData.forEach((str) => { - radixTree.add(new Buffer(str, "ascii"), createValue ? {address: str} : undefined ); + radixTree.add( Buffer.from(str, "ascii"), createValue ? {address: str} : undefined ); assert(radixTree.validateRoot() === true, "Radix Tree after " + str + " is not Valid"); assert(radixTree.validateParentsAndChildrenEdges() === true, "Radix Parents and Children Edges don't match"); @@ -27,7 +27,7 @@ class InterfaceTreeTestHelper { //radixTree.printLevelSearch(); radixData.forEach((str) => { - let result = radixTree.search(new Buffer(str, "ascii")); + let result = radixTree.search( Buffer.from(str, "ascii")); assert(result.result === true, "result " + str + " was not found"); }); @@ -39,7 +39,7 @@ class InterfaceTreeTestHelper { testSearch (radixData, radixTree, needToBeFound) { radixData.forEach((str) => { - let result = radixTree.search(new Buffer(str, "ascii")); + let result = radixTree.search( Buffer.from(str, "ascii")); assert(result.result === needToBeFound, "result " + str + " was not found"); }); @@ -49,18 +49,18 @@ class InterfaceTreeTestHelper { radixData.forEach((str, index) => { - let deleteResult = radixTree.delete(new Buffer(str, "ascii")); + let deleteResult = radixTree.delete( Buffer.from(str, "ascii")); assert(deleteResult === true, "delete " + str + " didn't work"); assert(radixTree.validateRoot() === true, "Radix Tree deleted after " + str + " is not Valid"); assert(radixTree.validateParentsAndChildrenEdges() === true, "Radix Parents and Children Edges don't match"); - let searchResult = radixTree.search(new Buffer(str, "ascii")); + let searchResult = radixTree.search( Buffer.from(str, "ascii")); assert(!searchResult.result, "result " + str + " was actually found..."); // the radix sort still, should detect all remaining strings for (let j = index + 1; j < radixData.length; j++) { - let searchResult = radixTree.search(new Buffer(radixData[j], "ascii")); + let searchResult = radixTree.search( Buffer.from(radixData[j], "ascii")); assert(searchResult.result === true, "result " + str + " was not found after " + str + " was deleted..."); } diff --git a/src/tests/trees/radix/accountant/helpers/Interface-Accountant-Radix-Tree.test.helper.js b/src/tests/trees/radix/accountant/helpers/Interface-Accountant-Radix-Tree.test.helper.js index c4d37e9d8..b6cb10e84 100644 --- a/src/tests/trees/radix/accountant/helpers/Interface-Accountant-Radix-Tree.test.helper.js +++ b/src/tests/trees/radix/accountant/helpers/Interface-Accountant-Radix-Tree.test.helper.js @@ -15,7 +15,7 @@ class InterfaceAccountantRadixTreeTestHelper { accountantData.forEach((data, index) => { - accountantTree.add( new Buffer(data.text, "ascii"), { + accountantTree.add( Buffer.from(data.text, "ascii"), { text: data.text, balances: data.value.toString() }); @@ -25,7 +25,7 @@ class InterfaceAccountantRadixTreeTestHelper { assert(accountantTree.validateRoot() === true, "validate Tree was not passed at " + index + " because " + JSON.stringify(data)); assert(accountantTree.validateParentsAndChildrenEdges() === true, "Accountant Tree Parents and Children Edges don't match"); - assert(accountantTree.search(new Buffer(data.text, "ascii")).result === true, "Accountant Tree couldn't find " + index + " " + data + " although it was added"); + assert(accountantTree.search(Buffer.from(data.text, "ascii")).result === true, "Accountant Tree couldn't find " + index + " " + data + " although it was added"); accountantData.forEach((data2, index2) => { @@ -35,7 +35,7 @@ class InterfaceAccountantRadixTreeTestHelper { if (index2 <= index) mustFind = true; - assert(accountantTree.search(new Buffer(str2, "ascii")).result === mustFind, "Accountant Tree couldn't find or not find " + str2 + " although it was added successfully"); + assert(accountantTree.search( Buffer.from(str2, "ascii")).result === mustFind, "Accountant Tree couldn't find or not find " + str2 + " although it was added successfully"); });"" }); @@ -64,7 +64,7 @@ class InterfaceAccountantRadixTreeTestHelper { let str = data.text; - accountantTree.delete(new Buffer(str, "ascii")); + accountantTree.delete( Buffer.from(str, "ascii")); if (showDebug) { console.log("deleted", str); @@ -74,7 +74,7 @@ class InterfaceAccountantRadixTreeTestHelper { assert(accountantTree.validateRoot() === true, "Accountant after " + str + " is not Valid"); assert(accountantTree.validateParentsAndChildrenEdges() === true, "Accountant Tree Parent and Children Edges don't match"); - assert(!accountantTree.search(new Buffer(str, "ascii")).result, "Radix Tree2 couldn't find " + index + " " + str + " although it was added"); + assert(!accountantTree.search( Buffer.from(str, "ascii")).result, "Radix Tree2 couldn't find " + index + " " + str + " although it was added"); accountantData.forEach((data2, index2) => { @@ -84,12 +84,12 @@ class InterfaceAccountantRadixTreeTestHelper { if (index2 <= index) mustFind = false; - if (accountantTree.search( new Buffer(str2, "ascii")).result !== mustFind) { + if (accountantTree.search( Buffer.from(str2, "ascii")).result !== mustFind) { console.log("accountant tree didn't work for deleting ", index, " str ", str, "and finding ", str2) accountantTree.printLevelSearch(); } - assert(accountantTree.search( new Buffer(str2, "ascii")).result === mustFind, "Accountant Tree couldn't find or not find '" + str2 + "' although it was added successfully"); + assert(accountantTree.search( Buffer.from(str2, "ascii")).result === mustFind, "Accountant Tree couldn't find or not find '" + str2 + "' although it was added successfully"); }); diff --git a/src/tests/trees/radix/merkle-tree/Interface-Merkle-Radix-Tree.test.js b/src/tests/trees/radix/merkle-tree/Interface-Merkle-Radix-Tree.test.js index 97fffce62..72d36cfe7 100644 --- a/src/tests/trees/radix/merkle-tree/Interface-Merkle-Radix-Tree.test.js +++ b/src/tests/trees/radix/merkle-tree/Interface-Merkle-Radix-Tree.test.js @@ -12,7 +12,7 @@ describe("Interface Merkle + Radix Tree", () => { it('creating merkle tree simple test', ()=>{ let radixTree = new InterfaceMerkleRadixTree(); - radixTree.add( new Buffer("aaa", "ascii"), {address: "aaa"} ); + radixTree.add( Buffer.from("aaa", "ascii"), {address: "aaa"} ); assert(radixTree.validateRoot() === true, "Radix Tree after " + "aaa" + " is not Valid"); @@ -23,12 +23,12 @@ describe("Interface Merkle + Radix Tree", () => { ["romanus"].forEach( (str)=>{ - radixTree.add( new Buffer(str, "ascii") , {address: str} ); + radixTree.add( Buffer.from(str, "ascii") , {address: str} ); //radixTree.printLevelSearch(); assert(radixTree.validateRoot() === true, "Merkle Tree is invalid!!!"); - radixTree.delete( new Buffer("romane", "ascii")) + radixTree.delete( Buffer.from("romane", "ascii")) //radixTree.printLevelSearch(); assert(radixTree.validateRoot() === true, "Merkle Tree is invalid after deletion!!!"); From 63443777befee5710544e6ca1032656a0d7a4e9d Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 21:24:32 +0300 Subject: [PATCH 101/132] v16 upgrade #2 more updates --- package.json | 14 +++++++------- scripts/windows/install.bat | 8 -------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 66b23cb87..3fae26c66 100644 --- a/package.json +++ b/package.json @@ -57,11 +57,11 @@ "console-error": "0.0.4", "console-info": "0.0.5", "console-warn": "0.0.4", - "cors": "^2.8.4", - "events": "^2.0.0", - "express": "^4.16.3", - "express-basic-auth": "^1.1.6", - "express-rate-limit": "^3.3.2", + "cors": "^2.8.5", + "events": "^3.3.0", + "express": "^4.17.1", + "express-basic-auth": "^1.2.0", + "express-rate-limit": "^5.3.0", "fs": "0.0.1-security", "get-random-values": "^1.2.0", "https": "^1.0.0", @@ -85,8 +85,8 @@ "request-promise": "^4.2.2", "safe-compare": "^1.1.2", "sanitizer": "^0.1.3", - "socket.io": "2.1.1", - "socket.io-client": "1.7.4", + "socket.io": "4.1.3", + "socket.io-client": "4.1.3", "tweetnacl": "^1.0.0", "uuid": "^3.2.1", "webworkify-webpack": "^2.1.1", diff --git a/scripts/windows/install.bat b/scripts/windows/install.bat index d4254c013..377062ee9 100644 --- a/scripts/windows/install.bat +++ b/scripts/windows/install.bat @@ -25,12 +25,4 @@ call npm install -g node-gyp call npm install pm2 -g --unsafe-perm call npm install -::Install x509 -::(dir 2>&1 *`|(echo CMD);&<# rem #>echo PowerShell -call npm install --python=python2.7 -git clone https://github.com/ReadyTalk/win32.git -call md C:\OpenSSL-Win64\lib\ -call copy /y .\win32\msvc\lib\libeay32.lib C:\OpenSSL-Win64\lib\ -call rd /s /q .\win32\ - cd %CRT_DIR% From 5a401e29ded43fc7399fc55217789b5cbdbf028a Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 21:54:51 +0300 Subject: [PATCH 102/132] cli menu not checking for errors --- src/node/menu/CLI-Menu.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/node/menu/CLI-Menu.js b/src/node/menu/CLI-Menu.js index 50fa1b91e..b789904e0 100644 --- a/src/node/menu/CLI-Menu.js +++ b/src/node/menu/CLI-Menu.js @@ -1,5 +1,6 @@ /* eslint-disable */ import {JsonRpcServer} from './../jsonRpc'; +var process = require('process'); let NodeExpress, NodeServer; @@ -16,6 +17,19 @@ import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; import Log from 'common/utils/logging/Log'; import CLICore from "./CLI-Core"; import CLIRunner from './CLI-Menu-non-interactive'; +import process from "process"; + +process.on('error', (err) => { + console.error(`Caught exception: ${err}`); +}); + +process.on('uncaughtException', (err) => { + console.error(`Caught exception: ${err}`); +}); + +process.on('unhandledRejection', (err) => { + console.error(`Caught exception: ${err}`); +}); class CLI { From f33539b7f305f6f1ee3c7e9fae8ccda8443f4776 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 22:24:24 +0300 Subject: [PATCH 103/132] new x509 --- package.json | 2 +- src/node/sockets/node-server/express/Node-Express.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3fae26c66..1bec30345 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "homepage": "https://github.com/WebDollar/Node-WebDollar#readme", "dependencies": { - "@ghaiklor/x509": "^1.1.0", + "@sardinefish/x509": "^1.2.1", "argon2": "^0.28.2", "argon2-browser": "1.1.0", "atob": "^2.0.3", diff --git a/src/node/sockets/node-server/express/Node-Express.js b/src/node/sockets/node-server/express/Node-Express.js index 022ad79f3..444de05f7 100644 --- a/src/node/sockets/node-server/express/Node-Express.js +++ b/src/node/sockets/node-server/express/Node-Express.js @@ -30,13 +30,14 @@ class NodeExpress{ _extractDomain( fileName ){ - const x509 = require('@ghaiklor/x509'); - const subject = x509.getSubject( fileName ); + const { Certificate } = require('@sardinefish/x509') - let domain = subject.commonName; + const file = fs.readFileSync(fileName) + const cert = Certificate.fromPEM(file) - if (!domain) domain = ''; + let domain = cert.subject.CN; + if (!domain) domain = ''; return domain.replace( "*.", "" ); } From 616d2f13f1e3e1f05cccf92ea6bfd332bb4e8459 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Tue, 10 Aug 2021 23:33:54 +0300 Subject: [PATCH 104/132] removing argon2 dependency --- .../webpack.terminal-worker.config.js | 29 - package.json | 4 +- .../mining/Interface-Blockchain-Mining.js | 88 --- .../backbone/Blockchain-Backbone-Mining.js | 75 +-- .../mining/backbone/Workers.js | 502 ------------------ .../backbone/workers/Backbone-Worker.js | 194 ------- .../backbone/workers/Process-Worker-CPP.js | 48 -- .../backbone/workers/Process-Worker-GPU.js | 42 -- .../mining/backbone/workers/Process-Worker.js | 268 ---------- src/common/crypto/Argon2/Argon2.js | 13 +- .../browser/web-assembly/antelle/calc.js | 2 +- 11 files changed, 4 insertions(+), 1261 deletions(-) delete mode 100644 build_webpack/webpack.terminal-worker.config.js delete mode 100644 src/common/blockchain/interface-blockchain/mining/backbone/Workers.js delete mode 100644 src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js delete mode 100644 src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-CPP.js delete mode 100644 src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-GPU.js delete mode 100644 src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker.js diff --git a/build_webpack/webpack.terminal-worker.config.js b/build_webpack/webpack.terminal-worker.config.js deleted file mode 100644 index 2b3283fa5..000000000 --- a/build_webpack/webpack.terminal-worker.config.js +++ /dev/null @@ -1,29 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); -const nodeExternals = require('webpack-node-externals'); - -module.exports = { - target: 'node', - - //define entry point - entry: { - app: "./src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js", - }, - - // send to distribution - output: { - filename: 'dist_bundle/terminal_worker.js', - }, - - resolve: { - alias: { - // 'src': path.resolve(__dirname + '/../src'), - 'applications': path.resolve(__dirname + '/../src/applications'), - 'main-blockchain': path.resolve(__dirname + '/../src/main-blockchain'), - 'node': path.resolve(__dirname + '/../src/node'), - 'consts': path.resolve(__dirname + '/../src/consts'), - 'common': path.resolve(__dirname + '/../src/common'), - } - }, - externals: nodeExternals({}) -}; diff --git a/package.json b/package.json index 1bec30345..665559656 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,7 @@ "show_mocha_report": "node src/tests/browser/show-mocha.test.js", "coverage": "npm run build_terminal && istanbul cover _mocha dist/tests/main.test.js -x *.test.js && npm run show_coverage", "show_coverage": "node src/tests/browser/show-coverage.test.js", - "build_terminal_worker": "webpack --config build_webpack/webpack.terminal-worker.config.js", - "commands": "npm run build_terminal_menu && npm run build_terminal_worker && node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js", + "commands": "npm run build_terminal_menu && node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js", "test": "mocha-webpack", "lint": "eslint --ext .js src/consts" }, @@ -43,7 +42,6 @@ "homepage": "https://github.com/WebDollar/Node-WebDollar#readme", "dependencies": { "@sardinefish/x509": "^1.2.1", - "argon2": "^0.28.2", "argon2-browser": "1.1.0", "atob": "^2.0.3", "babel-plugin-module-alias": "^1.6.0", diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js index 4d6f854f3..5f15e541e 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js @@ -390,94 +390,6 @@ class InterfaceBlockchainMining extends InterfaceBlockchainMiningBasic{ } - async _mineNonces( start, end ){ - - let nonce = start; - - if (start < 0 || end < 0 || start > end) - return { - result: false, - hash: Buffer.from(consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER), - nonce: -1, - }; - - try { - - while (nonce <= end && this.started && !this.resetForced && !(this.reset && this.useResetConsensus)) { - - let hash = await this.calculateHash(nonce); - - if (hash.compare(this.bestHash) < 0) { - - this.bestHash = hash; - this.bestHashNonce = nonce; - - if (this.bestHash.compare(this.difficulty) <= 0) { - - return { - result: true, - nonce: this.bestHashNonce, - hash: this.bestHash, - }; - - } - - } - - nonce++; - this._hashesPerSecond++; - } - - - } catch (exception){ - console.error("Error _mineNonces", "nonce", nonce, start, end ); - - if (Blockchain.MinerPoolManagement.minerPoolStarted) - this.resetForced = true; - } - - if (consts.DEBUG && Math.random() < 0.05 ) { - console.log("current bestHash -", this.bestHash.toString("hex"), " target -", this.difficulty.toString("hex")); - await this.blockchain.sleep( 5 ); - } - - return { - result: false, - hash: this.bestHash, - nonce: this.bestHashNonce - } - - } - - /** - * Simple Mining with no Workers - * @param block - * @param difficulty - * @returns {Promise.} - */ - async mine(block, difficulty, start, end, height){ - - if (start === undefined) start = 0; - if (end === undefined) end = 0xFFFFFFFF; - - this.block = block; - this.difficulty = difficulty; - - this.bestHash = consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER; - this.bestHashNonce = -1; - - try { - - await this._mineNonces(start, end); - - } catch (exception){ - console.log("Error Mining ", exception) - } - - } - - - } export default InterfaceBlockchainMining; diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js b/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js index 9982e0c78..487039d63 100644 --- a/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js +++ b/src/common/blockchain/interface-blockchain/mining/backbone/Blockchain-Backbone-Mining.js @@ -1,5 +1,4 @@ import InterfaceBlockchainMining from "../Interface-Blockchain-Mining"; -import Workers from './Workers'; import consts from 'consts/const_global' import BlockchainGenesis from 'common/blockchain/global/Blockchain-Genesis'; @@ -12,64 +11,13 @@ class BlockchainBackboneMining extends InterfaceBlockchainMining { super(blockchain, minerAddress, miningFeePerByte); - this.WORKER_NONCES_WORK = 700; - this.block = undefined; this.undefined = undefined; - this._workerResolve = undefined; this.end = 0; - this._workers = new Workers(this); - } - - - - async _mineNonces(start, end){ - - try { - - if (start > end ) return { - result: false, - hash: Buffer.from (consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER), - nonce: -1, - }; - - let answer = await InterfaceBlockchainMining.prototype._mineNonces.call(this, start, Math.min(this.end, start + this.WORKER_NONCES_WORK)); - - if (!answer.result && (start + this.WORKER_NONCES_WORK + 1 <= this.end) && this.started && !this.resetForced && !(this.reset && this.useResetConsensus)) { // in case I still have work to do - - let answer2 = await this._mineNonces( start + this.WORKER_NONCES_WORK + 1, Math.min(this.end, start + this.WORKER_NONCES_WORK + this.WORKER_NONCES_WORK)); - - if (answer2.hash !== undefined && answer2.hash.compare(answer.hash) < 0) - answer = answer2; - - } - - return answer; - - } catch (exception){ - - console.error("error _mince _nonces Backbone mining error"); - return { - result:false, - hash: Buffer.from (consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER), - nonce: -1, - }; - - } - } - async _mineNoncesWithWorkers(start, end) { - let promiseResolve = new Promise((resolve) => { - this._workerResolve = resolve; - - this._workers.run(start, end); - }); - - return promiseResolve; - } async mine(block, difficulty, start, end, height){ @@ -80,28 +28,7 @@ class BlockchainBackboneMining extends InterfaceBlockchainMining { this.bestHash = consts.BLOCKCHAIN.BLOCKS_MAX_TARGET_BUFFER; this.bestHashNonce = -1; - if ( BlockchainGenesis.isPoSActivated( height ) ) { - this._workers.stopMining(); - return this._minePOS(block, difficulty) ; - } - - if (consts.TERMINAL_WORKERS.CPU_MAX === -100) // NO POW MINING - return undefined; - - // multi threading - if (this._workers.haveSupport()) - return this._mineNoncesWithWorkers(start, end); - - // solo - return this._mineNonces(start, start + this.WORKER_NONCES_WORK); - - } - - stopMining(){ - - InterfaceBlockchainMining.prototype.stopMining.call(this); - - this._workers.stopMining(); + return this._minePOS(block, difficulty); } diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js b/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js deleted file mode 100644 index 298e9cddc..000000000 --- a/src/common/blockchain/interface-blockchain/mining/backbone/Workers.js +++ /dev/null @@ -1,502 +0,0 @@ -// Contributor: Adelin - -import Serialization from "common/utils/Serialization"; -import Argon2 from 'common/crypto/Argon2/Argon2' -import Log from 'common/utils/logging/Log'; -import Blockchain from "main-blockchain/Blockchain" - -const FS = require('fs'); -const OS = require('os'); -const { fork } = require('child_process'); -//const fkill = require('fkill'); - -import consts from 'consts/const_global' - -import ProcessWorkerCPP from "./workers/Process-Worker-CPP"; -import ProcessWorkerGPU from "./workers/Process-Worker-GPU"; - -class Workers { - /** - * @param {BlockchainBackboneMining} ibb - * - * @return {Workers} - */ - constructor(ibb) { - - this.ibb = ibb; - - this._abs_end = 0xFFFFFFFF; - - this._from_pool = undefined; - - this.workers_list = []; - - // workers setup - if (consts.TERMINAL_WORKERS.CPU_MAX === -100) { // NO POW MINING - - } else - if (consts.TERMINAL_WORKERS.TYPE === "cpu") { // MULTI THREADING MINING - - this._worker_path = consts.TERMINAL_WORKERS.PATH; - this._worker_path_file_name = ''; - - this.workers_max = consts.TERMINAL_WORKERS.CPU_MAX || this._maxWorkersDefault() || 1; - this.worker_batch = consts.TERMINAL_WORKERS.CPU_WORKER_NONCES_WORK || 500; - this.worker_batch_thread = this.worker_batch; - - this.ibb._intervalPerMinute = false; - - } else if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp") { //CPP MINER - - this._worker_path = consts.TERMINAL_WORKERS.PATH_CPP; - this._worker_path_file_name = consts.TERMINAL_WORKERS.PATH_CPP_FILENAME; - - this.workers_max = consts.TERMINAL_WORKERS.CPU_MAX || this._maxWorkersDefault() || 1; - this.worker_batch = consts.TERMINAL_WORKERS.CPU_CPP_WORKER_NONCES_WORK; - this.worker_batch_thread = consts.TERMINAL_WORKERS.CPU_CPP_WORKER_NONCES_WORK_BATCH || 500; - - - if (this.worker_batch === 0) - this.worker_batch = 10 * this.worker_batch_thread*this.workers_max; - - this.ibb._intervalPerMinute = true; - } - else if (consts.TERMINAL_WORKERS.TYPE === "gpu") { //GPU MINING - - this._worker_path = consts.TERMINAL_WORKERS.PATH_GPU; - this._worker_path_file_name = consts.TERMINAL_WORKERS.PATH_GPU_FILENAME; - - this.workers_max = (consts.TERMINAL_WORKERS.GPU_MAX * consts.TERMINAL_WORKERS.GPU_INSTANCES)||1; - this.worker_batch = consts.TERMINAL_WORKERS.GPU_WORKER_NONCES_WORK; - this.worker_batch_thread = consts.TERMINAL_WORKERS.GPU_WORKER_NONCES_WORK_BATCH; - - this.ibb._intervalPerMinute = true; - } else { - - Log.error('NO WORKER SPECIFIED. Specify "cpu", "cpu-cpp", "gpu" ', Log.LOG_TYPE.default); - - } - - - if (!FS.existsSync(this._worker_path + this._worker_path_file_name)) - Log.error('Worker build is missing.', Log.LOG_TYPE.default); - - this._working = 0; - this._silent = consts.TERMINAL_WORKERS.SILENT; - - // target - this.block = undefined; - this.difficulty = undefined; - - // current work - this._current = undefined; - this._current_max = undefined; - this._finished = false; - this._final_batch = false; - this._run_timeout = false; - - - if (!this.makeUnresponsiveThreadsTimeout) - this.makeUnresponsiveThreadsTimeout = setTimeout( this._makeUnresponsiveThreads.bind(this), 5000 ); - - } - - async _makeUnresponsiveThreads(){ - - try { - - let date = new Date().getTime(); - - if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp" || consts.TERMINAL_WORKERS.TYPE === "gpu") - for (let i = this.workers_list.length - 1; i >= 0; i--) - if ((date - this.workers_list[i].date ) > 60 * 1000) { - - await this.workers_list[i].restartWorker(); - this.workers_list[i].date = new Date().getTime(); - - // await this.workers_list[i].kill(); - // this.workers_list.splice(i, 1); - - Log.info("Restarting Worker", Log.LOG_TYPE.default); - - - } - - // if ( this._current >= this._current_max ) - // this._stopAndResolve(); - } catch (exception){ - - } - - this.makeUnresponsiveThreadsTimeout = setTimeout( this._makeUnresponsiveThreads.bind(this), 5000 ); - - } - - haveSupport() { - - // disabled by miner - if (consts.TERMINAL_WORKERS.TYPE === "cpu" ) { - - if (consts.TERMINAL_WORKERS.CPU_MAX === -1) - return false; - - // it needs at least 2 - if (this.workers_max <= 1) - return false; - - } - return true; - } - - stopMining(){ - - try { - - if (this.workers_list.length === 0) - return; - - console.log("Stop POW Mining!"); - - for (let i = 0; i < this.workers_list.length; i++){ - if (this.workers_list[i] !== undefined && typeof this.workers_list[i].kill === "function") - this.workers_list[i].kill('SIGINT'); - } - - this.workers_list = []; - - } catch (exception){ - - } - - } - - max() { - return this.workers_max; - } - - async run(start, end, loop_delay = 2) { - - this._current = start || 0; - this._current_max = (end) ? end : this._abs_end; - - this.block = this.ibb.block; - this.difficulty = this.ibb.difficulty; - this.height = this.ibb.block.height; - this.blockId = this.ibb.blockId || this.ibb.block.height; - - this._from_pool = true; - if (this.block.height) { - // if the given block has a height, it means it's mining solo. - this._from_pool = false; - } - - if ( !Buffer.isBuffer(this.block) ){ - - // solo mining - this.block = Buffer.concat([ - Serialization.serializeBufferRemovingLeadingZeros(Serialization.serializeNumber4Bytes(this.block.height)), - Serialization.serializeBufferRemovingLeadingZeros(this.block.difficultyTargetPrev), - this.block._computeBlockHeaderPrefix(true), - ]) ; - - } - - // resets8 - this._finished = false; - this._final_batch = false; - - this.ibb.bestHash = Buffer.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "hex"); - this.ibb.bestHashNonce = 0; - - await this._initiateWorkers(); - - if (this._loopTimeout === undefined) - this._loopTimeout = setTimeout( this._loop.bind(this, loop_delay), 1); - } - - _maxWorkersDefault() { - return Math.floor(OS.cpus().length / 2); - } - - async _initiateWorkers() { - - let count = this.workers_max; - - if ( consts.TERMINAL_WORKERS.TYPE === "cpu-cpp" ) - count = 1; - - - for (let index = this.workers_list.length ; index < count; index++) - await this._initializeWorker(index); - - return this; - } - - async _initializeWorker(index){ - - if (this.workers_list[index] && typeof this.workers_list[index].kill === "function") - this.workers_list[index].kill('SIGINT'); - - await this._createWorker(index); - } - - async _createWorker(index) { - // { execArgv: [`--max_old_space_size=${Math.floor(os.totalmem()/1024/1024)}`] } - - let worker; - let started = false; - - if (consts.TERMINAL_WORKERS.TYPE === "cpu") { - worker = fork( - this._worker_path, {}, {silent: this._silent} - ); - Log.info("CPU worker created", Log.LOG_TYPE.defaultLogger ); - started = worker.connected; - } else - if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp") { - - worker = new ProcessWorkerCPP( index, this.worker_batch, this.workers_max ); - started = await worker.start(this._worker_path , this._worker_path_file_name); - - Log.info("CPU CPP worker created", Log.LOG_TYPE.defaultLogger ); - - } else if (consts.TERMINAL_WORKERS.TYPE === "gpu") { - - worker = new ProcessWorkerGPU( index, this.worker_batch ); - started = await worker.start(this._worker_path, this._worker_path_file_name); - - Log.info("GPU worker created", Log.LOG_TYPE.defaultLogger ); - - } - - worker.date = new Date().getTime(); - if ( !started ) { - this.workers_list[index] = worker; - return worker; - } - - worker._is_batching = false; - - worker.on('message', async (msg) => { - - // if (this.ibb._hashesPerSecond === 0) - // console.info(msg.type); - - worker.date = new Date().getTime(); - - // hashing: hashed one time, so we are incrementing hashes per second - if (msg.type === 'h') { - this.ibb._hashesPerSecond += 3; - - return true; - } - - if (msg.type === 's' || msg.type === 'b'){ - //worker is batching now - worker._is_batching = false; - - // keep track of the ones that are working - this._working--; - - if ( msg.h ) - this.ibb._hashesPerSecond += parseInt(msg.h); - - - } - - // solved: stop and resolve but with a solution - if (msg.type === 's') { - - this._finished = true; - - //the blockId is not matching - if (msg.blockId && parseInt(msg.blockId) !== (this.ibb.blockId || this.ibb.block.height)) - return false; - - let hash; - - if (msg.hash.length === 64) hash = Buffer.from(msg.hash, "hex"); - else hash = Buffer.from(msg.hash); - - let nonce = parseInt(msg.nonce); - - if ( consts.DEBUG && !Blockchain.MinerPoolManagement.minerPoolStarted) - if (false === await this._validateHash( hash, nonce )) - return false; - - this._stopAndResolve(true, hash, nonce); - - // console.log("sol",Buffer.from(msg.hash).toString("hex")); - - return true; - } - - // batching: finished a batch of nonces - if (msg.type === 'b') { - - //the blockId is not matching - if (msg.blockId && parseInt(msg.blockId) !== (this.ibb.blockId || this.ibb.block.height)) - return false; - - let bestHash; - - if (msg.bestHash.length === 64) bestHash = Buffer.from(msg.bestHash, "hex"); - else bestHash = Buffer.from(msg.bestHash); - - let change = false; - for (let i = 0, l = this.ibb.bestHash.length; i < l; i++) - if (bestHash[i] < this.ibb.bestHash[i]) { - change = true; - break; - } - else if (bestHash[i] > this.ibb.bestHash[i]) - break; - - if ( change ) { - this.ibb.bestHash = bestHash; - this.ibb.bestHashNonce = parseInt(msg.bestNonce) - } - - - // if none of the threads are working and we finished the range, then we should stop and resolve - if (!this._working && this._current >= this._current_max) - this._stopAndResolve(); - - if (consts.DEBUG) - await this._validateHash(bestHash, parseInt(msg.bestNonce)); - - return true; - } - }); - - worker.date = new Date().getTime(); - this.workers_list[index] = worker; - return worker; - } - - async _validateHash(initialHash, nonce){ - - if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp" || consts.TERMINAL_WORKERS.TYPE === "gpu") { - //validate hash - let nonceBuffer = Buffer.from([nonce >> 24 & 0xff, nonce >> 16 & 0xff, nonce >> 8 & 0xff, nonce & 0xff]); - let block = Buffer.concat([this.block, nonceBuffer]); - - let hash = await Argon2.hash(block); - if (false === hash.equals(initialHash)) { - Log.error("HASH may be too old", Log.LOG_TYPE.default ); - return false; - } else { - Log.warn("HASH is OK!", Log.LOG_TYPE.default ); - } - } - - return true; - } - - _stop(){ - - this._finished = true; - - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = undefined; - } - - } - - _stopAndResolve( result = false, hash = undefined, nonce = undefined ) { - - this._stop(); - - this.ibb._workerResolve({ - result: result, - hash: hash || this.ibb.bestHash, - nonce: nonce || this.ibb.bestHashNonce - }); - - return this; - } - - async _loop(_delay = 1) { - - try { - - if (!this.ibb.started || this.ibb.resetForced || (this.ibb.reset && this.ibb.useResetConsensus)) { - - if (!this._finished) - this._stopAndResolve(); - - return false; - } - - - await this.workers_list.forEach( async (worker, index) => { - - if (this._finished) - return false; - - if (worker._is_batching) - return false; - - if (this._final_batch) { - - if (Blockchain.MinerPoolManagement && Blockchain.MinerPoolManagement.minerPoolStarted) - this.ibb.resetForced = true; - - return false; - } - - - - // add only the rest - if (this._current_max - this._current < this.worker_batch) - this._final_batch = this._current_max - this._current; - - // keep track of the ones that are working - this._working++; - - let batch = this._final_batch ? this._final_batch : this.worker_batch; - - worker.date = new Date().getTime(); - - this._current += this.worker_batch; - worker._is_batching = true; - - if (consts.TERMINAL_WORKERS.TYPE === "cpu") { - - worker.send({ - - command: 'start', - data: { - block: this.block, - difficulty: this.difficulty, - start: this._current, - batch: batch, - blockId: this.blockId, - } - - }); - - } else if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp" || consts.TERMINAL_WORKERS.TYPE === "gpu") { - - if ( false === await worker.send ( this.block.length, this.block, this.difficulty, this._current, this._current + batch, this.worker_batch_thread )) - return false; - - } - - }); - - - } catch (exception){ - - Log.error("_loop raised an error", Log.LOG_TYPE.BLOCKCHAIN_FORKS ) - - } - - // healthy loop delay - this._loopTimeout = setTimeout( this._loop.bind( this, _delay ), _delay ); - - } -} - -export default Workers; diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js b/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js deleted file mode 100644 index 5438c599b..000000000 --- a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Backbone-Worker.js +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Backbone Worker based on node-gyp and multi-threading in node.js - */ - -const argon2 = require('argon2'); - -const opt = { - salt: Buffer.from("Satoshi_is_Finney"), - timeCost: 2, - memoryCost: 256, - parallelism: 2, - type: 0, - hashLength: 32, - raw: true, -}; - -const MAX_TARGET = Buffer.from("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "hex"); - - -/** - * Send message to main process. - * - * @param {Object} msg - */ -var sendMessage = (msg) => { - try { - process.send(msg); - } catch (e) { - // console.log(e); - } -}; - -/** - * Loops through a batch of nonces. - * - * Notes on data: - * - All data gets serialised in an object or an array while pased through - * messages from main process to this child process. - * So all data needs to be adjusted to it's original state. - * - * Notes on workflow: - * - If data.block is false, then it means it mines solo - * and it reconstructs the block with all it's (Buffer) parts. - * - If it has a data.block it means it mines in a pool. - * - * - * @param {Object} data - * - * @return {Boolean} - */ - -var difficulty = Buffer.alloc(32); -var start = 0; -var end = 0; -var blockId = 0; -var length = 0; -var buffer = 0; -var bestHash = Buffer.alloc(32); -var bestNonce = 0; - -var mineNoncesBatch = (myBlock, myDifficulty, myStart, myBatch, myBlockId) => { - - myBlock = Buffer.from(myBlock); - difficulty = Buffer.from(myDifficulty); - - // pool mining - length = myBlock.length; - buffer = Buffer.concat([myBlock, Buffer.alloc(4) ]); - - start = parseInt(myStart); - end = parseInt(myStart) + parseInt(myBatch); - - blockId = myBlockId; - - // difficulty - bestHash = MAX_TARGET; - bestNonce = -1; - - return false; -}; - - -var executionLoop = async ()=>{ - - var nonce = 0; - var change, found; - - while (1===1){ - - if (start < end){ - - nonce = start; - start++; - - if (nonce > 0xFFFFFFFF) { - // batched: signal main process that it finished this batch - sendMessage({ type: 'b', bestHash:bestHash, bestNone: bestNonce, blockId: blockId }); - bestNonce = -1; - continue; - } - - try { - - buffer[length + 3] = nonce & 0xff; - buffer[length + 2] = nonce >> 8 & 0xff; - buffer[length + 1] = nonce >> 16 & 0xff; - buffer[length ] = nonce >> 24 & 0xff; - - let hash = await argon2.hash(buffer, opt ); - - // console.log(nonce, hash); - - change = false; - - for (let i = 0, l = bestHash.length; i < l; i++) - if (hash[i] < bestHash[i]) { - change = true; - break; - } - else if (hash[i] > bestHash[i]) - break; - - if ( change ) { - - bestHash = hash; - bestNonce = nonce; - - found = false; - for (let i = 0, l = difficulty.length; i < l; i++) - if (hash[i] < difficulty[i]) { - found = true; - break; - } - else if (hash[i] > difficulty[i]) - break; - - if (found) { - - // solved: signal main process that we got a solution - sendMessage({ type: 's', nonce:nonce, hash: hash, blockId: blockId }); - - start = end+1; - bestNonce = -1; - - continue; - - } - - } - - - // hashing: signal main process that we hashed one time - - if (nonce % 3 === 0) - sendMessage({ type: 'h' }); - - } catch (error) { - console.log(error); - } - - } else - if (bestNonce !== -1) { - // batched: signal main process that it finished this batch - sendMessage( { type: 'b', bestHash: bestHash, bestNonce: bestNonce, blockId: blockId } ); - bestNonce = -1; - } else - await sleep(3); - - } - -}; - -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} - -executionLoop(); - -/** - * Gets called by main process - * - * @param {String} 'message' - * @param {Object} (msg - * - */ -process.on('message', (msg) => { - if (msg.command === 'start') { - try { - mineNoncesBatch(msg.data.block, msg.data.difficulty, msg.data.start, msg.data.batch); - } catch (error) { - console.log(error); - } - } -}); diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-CPP.js b/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-CPP.js deleted file mode 100644 index 03782428e..000000000 --- a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-CPP.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * CPP miner - compiled in C - */ - -import Blockchain from "main-blockchain/Blockchain" -import ProcessWorker from "./Process-Worker" - -const uuid = require('uuid'); - -class ProcessWorkerCPP extends ProcessWorker{ - - constructor(id, noncesWorkBatch, cores){ - - super(id, noncesWorkBatch, false); - this.cores = cores; - - this._outputFilename = this._outputFilename+Math.random(); - - } - - _getProcessParams(){ - - return this._path+ ' -d 0 -c '+this.cores+ ' -b '+ this.noncesWorkBatch + ' -f ' + this._outputFilename + this.suffix; - - } - - async kill(param){ - - console.info("KILL!!"); - await this._writeWork("0 0"); - await Blockchain.blockchain.sleep(5000); - - ProcessWorker.prototype.kill.call( this ); - } - - // async restartWorker(){ - // - // this._is_batching = false; - // - // await this._writeWork("0 0"); - // - // return await Blockchain.blockchain.sleep(5000); - // } - - -} - -export default ProcessWorkerCPP; \ No newline at end of file diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-GPU.js b/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-GPU.js deleted file mode 100644 index 261971e5a..000000000 --- a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker-GPU.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Argon2d is GPU unfriendly, it means, it will be more profitable to mine using CPU than GPU due the fact that Argon2d is memory intensive and important is the speed of the memory. - * - * Argon2d GPU supports CUDA and NVIDIA. It requires to install the NVIDIA drivers, CUDA software and after that you could use it with the CUDA cores. - * opencl is not efficient from the initial tests - * - */ - -import consts from "consts/const_global" -const uuid = require('uuid'); - -import ProcessWorker from "./Process-Worker" - -class ProcessWorkerGPU extends ProcessWorker { - - constructor(gpuID, noncesWorkBatch){ - - super(gpuID, noncesWorkBatch); - - let gpuInstance; - - gpuInstance = gpuID % consts.TERMINAL_WORKERS.GPU_INSTANCES; - gpuID = Math.floor( gpuID / consts.TERMINAL_WORKERS.GPU_INSTANCES); - - this.gpuID = gpuID||0; - this.gpuInstance = gpuInstance || 0; - - this.suffix = this.gpuID+"_"+this.gpuInstance; - - } - - _getProcessParams(){ - - return ' '+this._path+ ' -m '+consts.TERMINAL_WORKERS.GPU_MODE+ ' -b '+ this.noncesWorkBatch + ' -d '+this.gpuID+ ' -r socket -f '+'./dist_bundle/GPU/input.txt'+this.suffix; - - } - - - -} - -export default ProcessWorkerGPU \ No newline at end of file diff --git a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker.js b/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker.js deleted file mode 100644 index d27867b97..000000000 --- a/src/common/blockchain/interface-blockchain/mining/backbone/workers/Process-Worker.js +++ /dev/null @@ -1,268 +0,0 @@ -var exec = require('child_process').exec; -var fs = require('fs'); - -import consts from "consts/const_global" -const uuid = require('uuid'); -import Utils from "common/utils/helpers/Utils" - -import AdvancedEmitter from "common/utils/Advanced-Emitter"; -import Blockchain from "main-blockchain/Blockchain" - -import Log from 'common/utils/logging/Log'; - -class ProcessWorker{ - - constructor(id, noncesWorkBatch, allowSendBeforeReadPreviously=true){ - - - this.id = id||0; - this.noncesWorkBatch = noncesWorkBatch; - this.allowSendBeforeReadPreviously = allowSendBeforeReadPreviously; - - this._outputFilename = 'input.txt'; - - this.suffix = this.id; - - this._child = undefined; - - this.emitter = new AdvancedEmitter(100); - - this._is_batching = false; - this._path = ''; - - this._start = 0; - this._end = -1; - this._data = undefined; - - this._lastData = undefined; - this._nextData = undefined; - - } - - _getProcessParams(){ - - return this._path+ ' -b '+ this.noncesWorkBatch + ' -f ' + this._outputFilename + this.suffix; - - } - - restartWorker(){ - this._is_batching = false; - } - - async start(path, filename) { - - - if (path !== undefined) { - this._path = path + filename; - this._outputFilename = path + this._outputFilename; - } - - try { - - await this._deleteFile(); - await this._deleteFile("output"); - - } catch (exception) { - - } - - this._child = exec(( Utils.isWin ? '' : '') + ' ' + this._getProcessParams(), async (e, stdout, stderr) => { - - //console.log(stdout); - console.log(stderr); - - if (e) { - console.error("Process Raised an error", e); - - // await this.start(path); - // this._is_batching = true; - - } - - }); - - await Blockchain.blockchain.sleep(1000); - - if (this._child.exitCode !== null) - return false; - - this._child.stdout.on('data', (data) => { - - }); - - this._child.on('close', () => { - console.log('done'); - console.info(); - }); - - this._prevHash = ''; - - await Blockchain.blockchain.sleep(1000); - - if (this._timeoutValidation === undefined) - this._timeoutValidation = setTimeout(this._validateWork.bind(this), 1000); - - // if (this._sendDataTimeout === undefined) - // this._sendDataTimeout = setTimeout(this._writeWork.bind(this), 10); - - return true; - } - - kill(param){ - - clearTimeout(this._timeoutValidation); - this._child.kill(param); - - } - - async send(length, block, difficulty, start, end, batch){ - - //this._child.send(data); - - let data = ''; - data += start + ' '; - data += length +' '; - - for (let i=0; i Date: Wed, 11 Aug 2021 00:15:40 +0300 Subject: [PATCH 105/132] using argon2-browser --- package.json | 6 +- src/common/crypto/Argon2/Argon2.js | 41 ++- .../crypto/Argon2/browser/Argon2-Browser.js | 99 ------ .../Argon2-Browser-WebAssembly.js | 173 ---------- .../browser/web-assembly/antelle/calc.js | 325 ------------------ .../browser/web-assembly/antelle/main.js | 142 -------- .../browser/web-assembly/antelle/readme.md | 10 - .../browser/web-assembly/antelle/worker.js | 45 --- src/common/crypto/Argon2/node/Argon2-Node.js | 59 ---- 9 files changed, 23 insertions(+), 877 deletions(-) delete mode 100644 src/common/crypto/Argon2/browser/Argon2-Browser.js delete mode 100644 src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js delete mode 100644 src/common/crypto/Argon2/browser/web-assembly/antelle/calc.js delete mode 100644 src/common/crypto/Argon2/browser/web-assembly/antelle/main.js delete mode 100644 src/common/crypto/Argon2/browser/web-assembly/antelle/readme.md delete mode 100644 src/common/crypto/Argon2/browser/web-assembly/antelle/worker.js delete mode 100644 src/common/crypto/Argon2/node/Argon2-Node.js diff --git a/package.json b/package.json index 665559656..8a0e497bb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "homepage": "https://github.com/WebDollar/Node-WebDollar#readme", "dependencies": { "@sardinefish/x509": "^1.2.1", - "argon2-browser": "1.1.0", + "argon2-browser": "1.18.0", "atob": "^2.0.3", "babel-plugin-module-alias": "^1.6.0", "big-integer": "^1.6.26", @@ -83,8 +83,8 @@ "request-promise": "^4.2.2", "safe-compare": "^1.1.2", "sanitizer": "^0.1.3", - "socket.io": "4.1.3", - "socket.io-client": "4.1.3", + "socket.io": "2.1.1", + "socket.io-client": "1.7.4", "tweetnacl": "^1.0.0", "uuid": "^3.2.1", "webworkify-webpack": "^2.1.1", diff --git a/src/common/crypto/Argon2/Argon2.js b/src/common/crypto/Argon2/Argon2.js index 1310fcfd5..78b2620e1 100644 --- a/src/common/crypto/Argon2/Argon2.js +++ b/src/common/crypto/Argon2/Argon2.js @@ -1,33 +1,32 @@ import BufferExtended from 'common/utils/BufferExtended'; +import consts from "../../../consts/const_global"; -const Argon2 = require('./browser/Argon2-Browser').default +const argon2 = require("argon2-browser"); -/** - * Verify Argon2 Hash - * @param data - * @param initialHash - * @returns {Promise.} - */ -Argon2.verify = async (initialHash, data) => { +export default { - let myHash; + async hash (data) { - if (Buffer.isBuffer(initialHash)) { - myHash = await Argon2.hash(data); + let result = await argon2.hash({ + salt: consts.HASH_ARGON2_PARAMS.salt, + time: consts.HASH_ARGON2_PARAMS.time, + mem: consts.HASH_ARGON2_PARAMS.memBytes, + parallelism: consts.HASH_ARGON2_PARAMS.parallelism, + type: consts.HASH_ARGON2_PARAMS.algoBrowser, + hashLen: consts.HASH_ARGON2_PARAMS.hashLen, + pass: data, + }); + + return Buffer.from(result.hash); + }, + + async verify (initialHash, data) { + + const myHash = await this.hash(data); //console.log("verify", myHash, initialHash) return BufferExtended.safeCompare(initialHash, myHash); } - else - if (typeof initialHash === 'string') { - myHash = await Argon2.hashString(data); - - return myHash === initialHash; - } - - return false; } - -export default Argon2 \ No newline at end of file diff --git a/src/common/crypto/Argon2/browser/Argon2-Browser.js b/src/common/crypto/Argon2/browser/Argon2-Browser.js deleted file mode 100644 index 1fea23820..000000000 --- a/src/common/crypto/Argon2/browser/Argon2-Browser.js +++ /dev/null @@ -1,99 +0,0 @@ -const argon2 = require('argon2-browser').argon2; -import consts from 'consts/const_global' - -import Argon2BrowserWebAssembly from './web-assembly/Argon2-Browser-WebAssembly' - -/* - TUTORIAL BASED ON https://github.com/antelle/argon2-browser/blob/master/docs/test.html - - last update: - - 14 Nov 2017 - https://github.com/antelle/argon2-browser/commit/2d37df355b76e7f1c261571393ad5350e8753a0b - */ - - -const HASH_ARGON2_OPTIONS = { - salt: consts.HASH_ARGON2_PARAMS.salt, - time: consts.HASH_ARGON2_PARAMS.time, - mem: consts.HASH_ARGON2_PARAMS.memBytes, - parallelism: consts.HASH_ARGON2_PARAMS.parallelism, - type: consts.HASH_ARGON2_PARAMS.algoBrowser, - hashLen: consts.HASH_ARGON2_PARAMS.hashLen, -} - -class Argon2Browser{ - - constructor(){ - - if (process.env.BROWSER) - window.argon2 = argon2; - - } - - async hash(data){ - - let result = await Argon2BrowserWebAssembly.hash(data); - - if (result) - return result; - - return this.hashJavascript(data); - } - - async hashString(data){ - - let result = await Argon2BrowserWebAssembly.hashString(data); - - if (result ) return result; - - return this.hashJavascriptString() - } - - async hashJavascript(data){ - - try{ - - let params = HASH_ARGON2_OPTIONS; - params.pass = data; - - let result = await argon2.hash(params); - - //console.log("ARgon2Browser", result.hash); - return Buffer.from(result.hash); - - } catch (Exception){ - console.log("Argon2 exception hashJavascript", Exception) - - throw Exception - } - - } - - async hashJavascriptString(data){ - - try{ - - let params = HASH_ARGON2_OPTIONS; - params.pass = data; - - let result = await argon2.hash( params ); - - let hash = result.encoded.substr(result.encoded.lastIndexOf("$")+1) - - //console.log("ARgon2Browser", result.encoded, hash); - - return hash; - - } catch (Exception){ - console.log("Argon2 exception hashJavascriptString", Exception) - - throw Exception - } - - } - - -} - -export default new Argon2Browser() diff --git a/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js b/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js deleted file mode 100644 index 8efe65373..000000000 --- a/src/common/crypto/Argon2/browser/web-assembly/Argon2-Browser-WebAssembly.js +++ /dev/null @@ -1,173 +0,0 @@ -import consts from 'consts/const_global' - -import Argon2WebAssemblyCalcClass from './antelle/calc.js' -let Argon2WebAssemblyCalc = new Argon2WebAssemblyCalcClass(); - -import Argon2WebAssemblyMain from './antelle/main.js' -import BufferExtended from "common/utils/BufferExtended"; -//require('antelle/worker.js') - -/* - TUTORIAL BASED ON https://github.com/antelle/argon2-browser/blob/master/docs/index.html - */ - -const HASH_ARGON2_OPTIONS = { - salt: consts.HASH_ARGON2_PARAMS.salt, - time: consts.HASH_ARGON2_PARAMS.time, - mem: consts.HASH_ARGON2_PARAMS.memBytes, - parallelism: consts.HASH_ARGON2_PARAMS.parallelism, - type: consts.HASH_ARGON2_PARAMS.algoBrowser, - hashLen: consts.HASH_ARGON2_PARAMS.hashLen, -} - -class Argon2BrowserWebAssembly{ - - - /* - Simple Hash - */ - - _calculateHash(method, params){ - - try { - let answer = Argon2WebAssemblyCalc.calc(method, params) - - return answer; - } catch (Exception){ - console.log( '_calculateHashWorker raised exception', Exception ); - return null; - } - } - - async _calcBest(params){ - let result; - - - try { - result = await this._calculateHash(Argon2WebAssemblyCalc.calcWasm, params); - if (result ) return result; - } catch (ex){ - - } - - try { - result = await this._calculateHash(Argon2WebAssemblyCalc.calcAsmJs, params); - if (result ) return result; - } catch (ex){ - - } - - - try { - result = await this._calculateHash(Argon2WebAssemblyCalc.calcBinaryenSexpr, params); - if (result ) return result; - } catch (ex){ - - } - - try { - result = await this._calculateHash(Argon2WebAssemblyCalc.calcBinaryenBin, params); - if (result ) return result; - } catch (ex){ - - } - - try { - result = await this._calculateHash(Argon2WebAssemblyMain.calcPNaCl, params); - if (result ) return result; - } catch (ex){ - - } - - return null; - } - - /* - Workers - */ - _calculateHashWorker(method, params){ - - - try { - return Argon2WebAssemblyCalc.calcWorker(method, params) - } catch (Exception){ - console.error('_calculateHashWorker raised exception', Exception) - return null; - } - } - - calcWorkerAsm(data){ - this._calculateHashWorker('asm', data) - } - - calcWorkerWasm(data){ - this._calculateHashWorker('wasm', data) - } - - calcWorkerBest(data) { - let result; - - result = this.calcWorkerAsm(data) - if (result !== null) return result; - - result = this.calcWorkerWasm(data) - if (result !== null) return result; - } - - async hash(data){ - - try{ - - let params = HASH_ARGON2_OPTIONS; - params.pass = data - - //console.log("params.pass", params.pass); - - //let result = await this._calcBest(params); - let result = await this._calculateHash(Argon2WebAssemblyCalc.calcAsmJs, params); - - if (result === null) throw {message: "Argon2 returned empty"}; - - //console.log("result", result) - - return Buffer.from(result.hash); - - } catch (Exception){ - console.error("Argon2 exception hash", Exception) - return null; - } - - } - - async hashString(data){ - - try{ - - let params = HASH_ARGON2_OPTIONS; - params.pass = data - - let result = await this._calcBest( params ); - - // console.log("ARgon2Browser String", result); - if (result === null) throw {message:"Argon2 returned empty"}; - - return Buffer.from(result.hash).toString("hex"); - - //let hash = result.encoded.substr( result.encoded.lastIndexOf("$")+1 ) - - // console.log("hash string ", "hash=", hash, "data=",data) - // console.log("hash string ", result.hash) - - // return hash - - } catch (Exception){ - console.error("Argon2 exception hashString", Exception); - return null; - } - - } - - -} - -export default new Argon2BrowserWebAssembly() \ No newline at end of file diff --git a/src/common/crypto/Argon2/browser/web-assembly/antelle/calc.js b/src/common/crypto/Argon2/browser/web-assembly/antelle/calc.js deleted file mode 100644 index a2fd73550..000000000 --- a/src/common/crypto/Argon2/browser/web-assembly/antelle/calc.js +++ /dev/null @@ -1,325 +0,0 @@ -/* - original source https://github.com/antelle/argon2-browser/blob/master/docs/js/calc.js - - Change to Class - Adopted to Return Promises - Removed setTimeOut... because we need it to be synchronized through promises - */ - -var global = typeof window === "undefined" ? {} : window; -//var root = window === undefined ? '../' : ''; - -var root = "https://webdollar.io/public"; -// var root = "https://antelle.net/argon2-browser"; - -class Argon2BrowserWebAssemblyCalc{ - - constructor(){ - - this._libraryLoadPromise = null; - this._librayLoaded = false; - - } - - calc(fn, arg) { - try { - return fn.call(this, arg); - } catch (e) { - console.log('Error Argon2', e); - //log('Error: ' + e); - return null; - } - } - - calcAsmJs(arg) { - - //this.clearLog(); - - let promise = new Promise( async (resolve) => { - - // this.log('Testing Argon2 using asm.js...'); - - if (global.Module && !global.Module.wasmJSMethod) { - - if (!this._librayLoaded) await this._libraryLoadPromise; - - resolve ( this.calcHash(arg) ); - return; - - } - - this._librayLoaded = false; - global.Module = { - print: this.log, - printErr: this.log, - setStatus: this.log - }; - - var ts = this.now(); - //this.log('Loading script...'); - - this.loadScript(root + '/dist/argon2/argon2-asm.min.js', () => { - //this.log('Script loaded in ' + Math.round(this.now() - ts) + 'ms'); - //this.log('Calculating hash....'); - - this._librayLoaded = true; - resolve(this.calcHash(arg)) - - }, () => { - - this._librayLoaded = true; - this.log('Error loading script'); - }); - - // this.calcBinaryen(arg, 'asmjs'); - - }); - - if (!this._librayLoaded) - this._libraryLoadPromise = promise; - - return promise; - } - - calcWasm(arg) { - return this.calcBinaryen(arg,'native-wasm'); - } - - calcBinaryenSexpr(arg) { - return this.calcBinaryen(arg,'interpret-s-expr'); - } - - calcBinaryenBin(arg) { - return this.calcBinaryen(arg, 'interpret-binary'); - } - - calcBinaryen(arg, method) { - - this.clearLog(); - - let promise = new Promise (async (resolve)=>{ - - if (!global.WebAssembly) { - - this.log('Your browser doesn\'t support WebAssembly, please try it in Chrome Canary or Firefox Nightly with WASM flag enabled'); - - resolve(null); // return - - return; - } - - const mem = arg.mem; - - //this.log('Testing Argon2 using Binaryen ' + method); - if (global.Module && global.Module.wasmJSMethod === method && global.Module._argon2_hash) { - //this.log('Calculating hash.... WASM optimized'); - - if (!this._librayLoaded) await this._libraryLoadPromise; - - resolve (this.calcHash(arg)); - return; - } - - this._librayLoaded = false; - - const KB = 1024 * 1024; - const MB = 1024 * KB; - const GB = 1024 * MB; - const WASM_PAGE_SIZE = 64 * 1024; - - const totalMemory = (2*GB - 64*KB) / 1024 / WASM_PAGE_SIZE; - const initialMemory = Math.min(Math.max(Math.ceil(mem * 1024 / WASM_PAGE_SIZE), 256) + 256, totalMemory); - - this.log('Memory: ' + initialMemory + ' pages (' + Math.round(initialMemory * 64) + ' KB)', totalMemory); - const wasmMemory = new WebAssembly.Memory({ - initial: initialMemory, - maximum: totalMemory - }); - - global.Module = { - print: this.log, - printErr: this.log, - setStatus: this.log, - wasmBinary: null, - wasmJSMethod: method, - asmjsCodeFile: root + '/dist/argon2/argon2-asm.min.asm.js', - wasmBinaryFile: root + '/dist/argon2/argon2.wasm', - wasmTextFile: root + '/dist/argon2/argon2.wast', - wasmMemory: wasmMemory, - buffer: wasmMemory.buffer, - TOTAL_MEMORY: initialMemory * WASM_PAGE_SIZE - }; - - this.log('Loading wasm...'); - var xhr = new XMLHttpRequest(); - xhr.open('GET', root + '/dist/argon2/argon2.wasm', true); - xhr.responseType = 'arraybuffer'; - xhr.onload = () => { - global.Module.wasmBinary = xhr.response; - global.Module.postRun = () => resolve(this.calcHash(arg)); - var ts = this.now(); - this.log('Wasm loaded, loading script...'); - - this.loadScript(root + '/dist/argon2/argon2.min.js', () => { - this.log('Script loaded in ' + Math.round(this.now() - ts) + 'ms'); - this.log('Calculating hash....'); - - this._librayLoaded = true; - - }, () => { - - this._librayLoaded = true; - this.log('Error loading script'); - - }); - }; - xhr.onerror = () => { - this.log('Error loading wasm'); - }; - xhr.send(null); - - }); - - if (!this._librayLoaded) - this._libraryLoadPromise = promise; - - return promise; - - } - - calcHash(arg) { - - if (!Module._argon2_hash) { - this.log('Error Calculate Hash'); - return null; - } - - let result = null; - - //this.log('Params: ' + Object.keys(arg).map(function(key) { return key + '=' + arg[key]; }).join(', ')); - - var dt = this.now(); - - var t_cost = arg && arg.time || 10; - var m_cost = arg && arg.mem || 1024; - var parallelism = arg && arg.parallelism || 1; - //var pwd = Module.allocate( arg.pass , 'i8', Module.ALLOC_NORMAL); - var pwd = this.allocateArray(arg && arg.pass || 'password'); - var pwdlen = arg && arg.pass ? arg.pass.length : 8; - //var salt = Module.allocate(Module.intArrayFromString(arg && arg.salt || 'somesalt'), 'i8', Module.ALLOC_NORMAL); - var salt =this.allocateArray(arg && arg.salt || 'somesalt'); - var saltlen = arg && arg.salt ? arg.salt.length : 8; - var hash = Module.allocate(new Array(arg && arg.hashLen || 32), 'i8', Module.ALLOC_NORMAL); - var hashlen = arg && arg.hashLen || 32; - var encoded = Module.allocate(new Array(512), 'i8', Module.ALLOC_NORMAL); - var encodedlen = 512; - var argon2_type = arg && arg.type || 0; - var version = 0x13; - var err; - try { - var res = Module._argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - hash, hashlen, encoded, encodedlen, - argon2_type, version); - } catch (e) { - err = e; - } - var elapsed = this.now() - dt; - if (res === 0 && !err) { - - /** - * changed by Alexandru Ionut Budisteanu - * to return UInt8Array aka Buffer - */ - - var hashArr = new Uint8Array(hashlen); - for (var i = hash; i < hash + hashlen; i++) { - hashArr[i-hash] = Module.HEAP8[i]; - } - - result = { - hash: hashArr, - //encoded:Module.Pointer_stringify(encoded), - elapsed: elapsed - }; - - //console.log('Encoded: ' + result.encoded); - // this.log('Hash: ' + result.hash); - // this.log('Elapsed: ' + result.elapsed); - - - - } else { - try { - if (!err) { - err = Module.Pointer_stringify(Module._argon2_error_message(res)) - } - } catch (e) { - } - this.log('Error: ' + res + (err ? ': ' + err : '')); - } - try { - Module._free(pwd); - Module._free(salt); - Module._free(hash); - Module._free(encoded); - } catch (e) { } - - return result; - } - - now() { - return typeof global.performance !== 'undefined' ? performance.now() : Date.now(); - } - - - log(msg){ - - } - clearLog(){ - - } - - loadScript(src, onload, onerror) { - - return new Promise( async (resolve)=>{ - - for (let i=0; i < 20; i++){ - - if ( document !== undefined && document.body !== undefined) - break; - - await this.sleep(10); - - } - - if (document !== undefined && document.body !== undefined){ - - let el = document.createElement("script"); - el.src = src; - el.onload = onload; - el.onerror = onerror; - document.body.appendChild(el); - - resolve(true); - - } else { - onerror("error"); - resolve(false); - } - - }); - } - - allocateArray(strOrArr) { - var arr = strOrArr instanceof Uint8Array || strOrArr instanceof Array ? strOrArr - : Module.intArrayFromString(strOrArr); - return Module.allocate(arr, 'i8', Module.ALLOC_NORMAL); - } - - sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - -} - -export default Argon2BrowserWebAssemblyCalc \ No newline at end of file diff --git a/src/common/crypto/Argon2/browser/web-assembly/antelle/main.js b/src/common/crypto/Argon2/browser/web-assembly/antelle/main.js deleted file mode 100644 index 57ac1a161..000000000 --- a/src/common/crypto/Argon2/browser/web-assembly/antelle/main.js +++ /dev/null @@ -1,142 +0,0 @@ -/* - original source https://github.com/antelle/argon2-browser/blob/master/docs/js/main.js - */ - -/* - Changed to Accept Arguments - Changed to Class Instance - */ - -class Argon2BrowserAntelleMain{ - - constructor(){ - - this.worker = null; - this.pnaclTs = null; - this.logTs = 0; - - } - - calcWorker(method, arg) { - - //this.clearLog(); - - if (this.worker) { - if (this.worker.method === method) { - //this.log('Using loaded worker'); - this.worker.postMessage({ calc: method, arg: arg }); - return; - } else { - this.worker.terminate(); - } - } - - //this.log('Starting worker...'); - this.worker = new Worker('js/worker.js'); - this.worker.method = method; - - var loaded = false; - - this.worker.onmessage = (e) => { - //this.log(e.data.msg); - if (!loaded) { - loaded = true; - this.worker.postMessage({ calc: method, arg: arg }); - } - }; - } - - - calcPNaCl(arg) { - - window.Module = null; - //this.clearLog(); - - if (!navigator.mimeTypes['application/x-pnacl']) { - throw 'PNaCl is not supported by your browser'; - } - - //this.log('Testing Argon2 using PNaCl'); - - var listener = document.getElementById('pnaclListener'); - var moduleEl = document.getElementById('pnacl-argon2'); - - this.pnaclTs = performance.now(); - if (moduleEl) { - moduleEl.postMessage(arg); - return; - } - - //this.log('Loading PNaCl module...'); - - moduleEl = document.createElement('embed'); - moduleEl.setAttribute('name', 'argon2'); - moduleEl.setAttribute('id', 'pnacl-argon2'); - moduleEl.setAttribute('width', '0'); - moduleEl.setAttribute('height', '0'); - moduleEl.setAttribute('src', 'argon2.nmf'); - moduleEl.setAttribute('type', 'application/x-pnacl'); - - listener.addEventListener('load', function() { - //this.log('PNaCl module loaded in ' + Math.round(performance.now() - this.pnaclTs) + 'ms'); - //this.log('Calculating hash....'); - this.pnaclTs = performance.now(); - moduleEl.postMessage(arg); - }, true); - listener.addEventListener('message', function(e) { - - var encoded = e.data.encoded; - var hash = e.data.hash; - if (e.data.res) { - //this.log('Error: ' + e.data.res + ': ' + e.data.error); - } else { - //this.log('Encoded: ' + encoded); - //this.log('Hash: ' + hash); - //this.log('Elapsed: ' + Math.round(performance.now() - pnaclTs) + 'ms'); - } - }, true); - listener.addEventListener('error', function() { console.log('Error'); }, true); - listener.addEventListener('crash', function() { console.log('Crash'); }, true); - - listener.appendChild(moduleEl); - moduleEl.offsetTop; // required by PNaCl - } - - // leftPad(str, len) { - // - // str = str.toString(); - // while (str.length < len) { - // str = '0' + str; - // } - // return str; - // } - - clearLog() { - - // this.logTs = performance.now(); - // - // let txtRes = document.getElementById('txtRes') - // - // if (txtRes !== null) - // txtRes.value = ''; - } - - log(msg) { - // if (!msg) { - // return; - // } - // - // var txtRes = document.getElementById('txtRes'); - // var elapsedMs = Math.round(performance.now() - this.logTs); - // var elapsedSec = (elapsedMs / 1000).toFixed(3); - // var elapsed = this.leftPad(elapsedSec, 6); - // - // if (txtRes !== null) - // txtRes.value += (txtRes.value ? '\n' : '') + '[' + elapsed + '] ' + msg; - } - - -} - - -export default new Argon2BrowserAntelleMain(); \ No newline at end of file diff --git a/src/common/crypto/Argon2/browser/web-assembly/antelle/readme.md b/src/common/crypto/Argon2/browser/web-assembly/antelle/readme.md deleted file mode 100644 index d6e4526e4..000000000 --- a/src/common/crypto/Argon2/browser/web-assembly/antelle/readme.md +++ /dev/null @@ -1,10 +0,0 @@ -# Argon2 Browser Web assembly - -Code based on Tutorial https://github.com/antelle/argon2-browser - -Last commit: - -``` -option to choose memory size; new wasm binary -November 14, 2017 -``` \ No newline at end of file diff --git a/src/common/crypto/Argon2/browser/web-assembly/antelle/worker.js b/src/common/crypto/Argon2/browser/web-assembly/antelle/worker.js deleted file mode 100644 index f99a83e64..000000000 --- a/src/common/crypto/Argon2/browser/web-assembly/antelle/worker.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - original source https://github.com/antelle/argon2-browser/blob/master/docs/js/worker.js - */ - -'use strict'; - -var calcHashArg; - -self.onmessage = (e) => { - self.postMessage('calc:' + e.data.calc); - calcHashArg = e.data.arg; - switch (e.data.calc) { - case 'asm': - calcAsmJs(calcHashArg); - break; - case 'wasm': - calcWasm(calcHashArg); - break; - } -}; - -function clearLog() { -} - -function log(msg) { - self.postMessage({ msg: msg }); -} - -function loadScript(script, callback, errorCallback) { - try { - importScripts(script); - } catch (e) { - console.error('Error loading script', script, e); - errorCallback(e); - return; - } - callback(); -} - -function getArg() { - return calcHashArg; -} - -importScripts('calc.js'); -self.postMessage({ msg: 'Worker started' }); \ No newline at end of file diff --git a/src/common/crypto/Argon2/node/Argon2-Node.js b/src/common/crypto/Argon2/node/Argon2-Node.js deleted file mode 100644 index f14d4903f..000000000 --- a/src/common/crypto/Argon2/node/Argon2-Node.js +++ /dev/null @@ -1,59 +0,0 @@ -const argon2 = require('argon2'); -import consts from 'consts/const_global' -//const argon2 = require('./node-argon2-master/'); - -const HASH_ARGON2_OPTIONS = { - salt: consts.HASH_ARGON2_PARAMS.saltBuffer, - timeCost: consts.HASH_ARGON2_PARAMS.time, - memoryCost: consts.HASH_ARGON2_PARAMS.memBytes, - parallelism: consts.HASH_ARGON2_PARAMS.parallelism, - type: consts.HASH_ARGON2_PARAMS.algoNode, - hashLength: consts.HASH_ARGON2_PARAMS.hashLen -}; - -class Argon2Node { - - async hash(data){ - - try{ - - let options = HASH_ARGON2_OPTIONS; - options.raw = true; - - return argon2.hash(data, options) - - } catch (Exception){ - console.log("Argon2 exception Argon2-Node.hash", Exception.message, Exception.code) - - throw Exception - } - - } - - async hashString(data){ - - try{ - - let options = HASH_ARGON2_OPTIONS; - options.raw = false; - - let encoded = await argon2.hash(data, options) - - let hash = encoded.substr(encoded.lastIndexOf("$")+1 ) - hash = hash.substr(hash).substr(hash.lastIndexOf('/')+1); - console.log(hash); - - return hash; - - - } catch (Exception){ - console.log("Argon2 exception Argon2-Node. hashString", Exception.message, Exception.code) - - throw Exception - } - - } - -} - -export default new Argon2Node() \ No newline at end of file From 5c201e8c7e9c2f93a9d6a27af8ee1ff3b03ddb4e Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 00:52:18 +0300 Subject: [PATCH 106/132] more fixes --- package.json | 4 ++-- .../sockets/node-clients/socket/Node-Client.js | 14 ++++---------- .../sockets/node-server/sockets/Node-Server.js | 3 ++- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 8a0e497bb..b105e7161 100644 --- a/package.json +++ b/package.json @@ -83,8 +83,8 @@ "request-promise": "^4.2.2", "safe-compare": "^1.1.2", "sanitizer": "^0.1.3", - "socket.io": "2.1.1", - "socket.io-client": "1.7.4", + "socket.io": "2.4.1", + "socket.io-client": "2.4.0", "tweetnacl": "^1.0.0", "uuid": "^3.2.1", "webworkify-webpack": "^2.1.1", diff --git a/src/node/sockets/node-clients/socket/Node-Client.js b/src/node/sockets/node-clients/socket/Node-Client.js index db1f47557..e5a08867e 100644 --- a/src/node/sockets/node-clients/socket/Node-Client.js +++ b/src/node/sockets/node-clients/socket/Node-Client.js @@ -78,7 +78,7 @@ class NodeClient { this.socket = socket = io( address, { reconnection: false, //no reconnection because it is managed automatically by the WaitList - maxHttpBufferSize: consts.SOCKET_MAX_SIZE_BYRES, + maxHttpBufferSize: consts.SETTINGS.PARAMS.MAX_SIZE.SOCKET_MAX_SIZE_BYRES, connection_timeout : timeoutTotal, timeout: timeoutTotal, @@ -104,25 +104,19 @@ class NodeClient { socket.on("error", response =>{ + //console.log("Client error", response); + resolve(false); }) socket.on("connect_error", response =>{ - //console.log("Client error connecting", address, response); resolve(false); - }); - socket.on("error", response =>{ - resolve(false); - }) - socket.on("connect_failed", response =>{ - //console.log("Client error connecting (connect_failed) ", address, response); resolve(false); - - }); + }) socket.on("disconnect", ()=>{ resolve(false); diff --git a/src/node/sockets/node-server/sockets/Node-Server.js b/src/node/sockets/node-server/sockets/Node-Server.js index 18977aad1..b5a253d2b 100644 --- a/src/node/sockets/node-server/sockets/Node-Server.js +++ b/src/node/sockets/node-server/sockets/Node-Server.js @@ -85,7 +85,7 @@ class NodeServer { try { server = io({ - maxHttpBufferSize:consts.SOCKET_MAX_SIZE_BYRES, + maxHttpBufferSize: consts.SETTINGS.PARAMS.MAX_SIZE.SOCKET_MAX_SIZE_BYRES, }); } catch(Exception){ @@ -239,6 +239,7 @@ class NodeServer { console.error( "Couldn't open server on port ", NodeExpress.port, " try next port") ; this.loaded = false + }); this.loaded = true; From 5ff5358a0123bba361edf3c7a5d12256aa1f6bb6 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 01:05:57 +0300 Subject: [PATCH 107/132] argon2 accept string as well --- src/common/crypto/Argon2/Argon2.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/common/crypto/Argon2/Argon2.js b/src/common/crypto/Argon2/Argon2.js index 78b2620e1..1bde38287 100644 --- a/src/common/crypto/Argon2/Argon2.js +++ b/src/common/crypto/Argon2/Argon2.js @@ -17,16 +17,26 @@ export default { pass: data, }); - return Buffer.from(result.hash); + if (Buffer.isBuffer(data) ) + return Buffer.from(result.hash); + else if (typeof data === "string" ) + result.hash + }, async verify (initialHash, data) { const myHash = await this.hash(data); - //console.log("verify", myHash, initialHash) - return BufferExtended.safeCompare(initialHash, myHash); + if (Buffer.isBuffer(initialHash)) + return BufferExtended.safeCompare(initialHash, myHash); + if (typeof initialHash === 'string') + return myHash === initialHash + + return false } + + } From 23265cbdd1540cbf2afbbbc01e22b72fc0ec4cc5 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 01:06:37 +0300 Subject: [PATCH 108/132] argon2 update #2 --- src/common/crypto/Argon2/Argon2.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/common/crypto/Argon2/Argon2.js b/src/common/crypto/Argon2/Argon2.js index 1bde38287..a528c0a16 100644 --- a/src/common/crypto/Argon2/Argon2.js +++ b/src/common/crypto/Argon2/Argon2.js @@ -17,10 +17,8 @@ export default { pass: data, }); - if (Buffer.isBuffer(data) ) - return Buffer.from(result.hash); - else if (typeof data === "string" ) - result.hash + if (typeof data === "string" ) result.hash + if (Buffer.isBuffer(data) ) return Buffer.from(result.hash); }, @@ -29,10 +27,8 @@ export default { const myHash = await this.hash(data); //console.log("verify", myHash, initialHash) - if (Buffer.isBuffer(initialHash)) - return BufferExtended.safeCompare(initialHash, myHash); - if (typeof initialHash === 'string') - return myHash === initialHash + if (Buffer.isBuffer(initialHash)) return BufferExtended.safeCompare(initialHash, myHash); + if (typeof initialHash === 'string') return myHash === initialHash return false } From 241f42e38de75ca54f4bc4b78d87617bed2328b6 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 01:17:22 +0300 Subject: [PATCH 109/132] fix argon2 error --- src/common/crypto/Argon2/Argon2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/crypto/Argon2/Argon2.js b/src/common/crypto/Argon2/Argon2.js index a528c0a16..569db8f3b 100644 --- a/src/common/crypto/Argon2/Argon2.js +++ b/src/common/crypto/Argon2/Argon2.js @@ -18,7 +18,7 @@ export default { }); if (typeof data === "string" ) result.hash - if (Buffer.isBuffer(data) ) return Buffer.from(result.hash); + if (Buffer.isBuffer(data) ) return Buffer.from(result.hash, "hex"); }, From eb1ab65d6154ef87b3b9e3efff9ea483b615de6b Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 01:32:41 +0300 Subject: [PATCH 110/132] some fixes --- src/common/crypto/WebDollar-Crypto-Data.js | 2 +- src/common/satoshmindb/Interface-SatoshminDB.js | 2 +- src/common/utils/Serialization.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/crypto/WebDollar-Crypto-Data.js b/src/common/crypto/WebDollar-Crypto-Data.js index 0f4e3a68e..dbc75dedb 100644 --- a/src/common/crypto/WebDollar-Crypto-Data.js +++ b/src/common/crypto/WebDollar-Crypto-Data.js @@ -24,7 +24,7 @@ class WebDollarCryptoData { if (WebDollarCryptoData.isWebDollarCryptoData(object)){ if (forceToCreate) - return new WebDollarCryptoData( Buffer.from(object.buffer) ); + return new WebDollarCryptoData( Buffer.from(object.buffer), "buffer" ); return object; } diff --git a/src/common/satoshmindb/Interface-SatoshminDB.js b/src/common/satoshmindb/Interface-SatoshminDB.js index 59a669949..592e3db85 100644 --- a/src/common/satoshmindb/Interface-SatoshminDB.js +++ b/src/common/satoshmindb/Interface-SatoshminDB.js @@ -136,7 +136,7 @@ class InterfaceSatoshminDB { if (process.env.BROWSER && Buffer.isBuffer(value)) attachment = new Blob([value.toString('hex')]); else //we are in node - attachment = Buffer.from( value.toString('hex'), "hex" ); + attachment = Buffer.from( value ); try { diff --git a/src/common/utils/Serialization.js b/src/common/utils/Serialization.js index 70d6cd3f6..e1b0d3650 100644 --- a/src/common/utils/Serialization.js +++ b/src/common/utils/Serialization.js @@ -194,18 +194,18 @@ class Serialization{ deserializeHashOptimized(buffer,offset){ - let hashPrefix = []; + let zeros = 0 let hashLength = this.deserializeNumber1Bytes(buffer, offset); offset += 1; - for (let i = 0; i < 32 - hashLength; i++) hashPrefix.push(0); + for (let i = 0; i < 32 - hashLength; i++) zeros += 1 let hashLeadingZero = BufferExtended.substr(buffer, offset, hashLength); offset += hashLength; let deserializedHash = Buffer.concat([ - Buffer.from(hashPrefix), + Buffer.alloc(zeros), hashLeadingZero ]); From 451e94f8a4231aaa58bec6b4610a1e82c4b864a2 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 01:43:53 +0300 Subject: [PATCH 111/132] changing pouchdb-node --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b105e7161..8cd10a534 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "node-gyp": "^8.1.0", "opn": "^5.2.0", "path": "^0.12.7", + "pouchdb-node": "^6.4.3", "pouchdb-browser": "^7.2.2", - "pouchdb-node": "^7.2.2", "public-ip": "^2.4.0", "raven": "^2.6.4", "readline": "^1.3.0", From 8ce22218aec18c92b94f761bcd62207fb93c9e3d Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 02:02:55 +0300 Subject: [PATCH 112/132] argon2 changes --- src/common/crypto/Argon2/Argon2.js | 11 ++++++++--- src/common/crypto/WebDollar-Crypto.js | 2 -- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/crypto/Argon2/Argon2.js b/src/common/crypto/Argon2/Argon2.js index 569db8f3b..59192e73c 100644 --- a/src/common/crypto/Argon2/Argon2.js +++ b/src/common/crypto/Argon2/Argon2.js @@ -17,18 +17,23 @@ export default { pass: data, }); - if (typeof data === "string" ) result.hash - if (Buffer.isBuffer(data) ) return Buffer.from(result.hash, "hex"); + if (!Buffer.isBuffer(result.hash)) return Buffer.from(result.hash) + return result.hash; }, + async hashString(data){ + const hash = await this.hash(data) + return hash.toString('hex') + }, + async verify (initialHash, data) { const myHash = await this.hash(data); //console.log("verify", myHash, initialHash) if (Buffer.isBuffer(initialHash)) return BufferExtended.safeCompare(initialHash, myHash); - if (typeof initialHash === 'string') return myHash === initialHash + if (typeof initialHash === 'string') return myHash.toString("hex") === initialHash return false } diff --git a/src/common/crypto/WebDollar-Crypto.js b/src/common/crypto/WebDollar-Crypto.js index b33ddc698..2dc3ec33b 100644 --- a/src/common/crypto/WebDollar-Crypto.js +++ b/src/common/crypto/WebDollar-Crypto.js @@ -157,7 +157,6 @@ class WebDollarCrypto { * @returns {Promise.} */ static hashPOW(data){ - return Argon2.hash(data); } @@ -167,7 +166,6 @@ class WebDollarCrypto { * @returns {Promise.} */ static hashPOW_String(data){ - return Argon2.hashString(data); } From 7ef021fef705c5b53f6fc47a013c32fc0f5cd7cc Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 02:20:41 +0300 Subject: [PATCH 113/132] satoshming db changes --- src/common/satoshmindb/Interface-SatoshminDB.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/satoshmindb/Interface-SatoshminDB.js b/src/common/satoshmindb/Interface-SatoshminDB.js index 592e3db85..fd5514b71 100644 --- a/src/common/satoshmindb/Interface-SatoshminDB.js +++ b/src/common/satoshmindb/Interface-SatoshminDB.js @@ -90,7 +90,7 @@ class InterfaceSatoshminDB { if (!response ) return null; else if ( !response._attachments ) return response.value; - else return Buffer.from( atob(response._attachments.key.data).toString('hex'), 'hex'); //get attachment + else return Buffer.from(atob(response._attachments.key.data).toString('hex'), 'hex'); //get attachment } catch (Exception) { @@ -136,7 +136,7 @@ class InterfaceSatoshminDB { if (process.env.BROWSER && Buffer.isBuffer(value)) attachment = new Blob([value.toString('hex')]); else //we are in node - attachment = Buffer.from( value ); + attachment = Buffer.from(value.toString('hex')); try { From 06781b1230da8b3b3f2d0ee0e8b9b53175bfc677 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 11 Aug 2021 03:01:38 +0300 Subject: [PATCH 114/132] change pouchdb node --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8cd10a534..8dcf6fd9b 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "node-gyp": "^8.1.0", "opn": "^5.2.0", "path": "^0.12.7", - "pouchdb-node": "^6.4.3", + "pouchdb-node": "^7.2.2", "pouchdb-browser": "^7.2.2", "public-ip": "^2.4.0", "raven": "^2.6.4", From 72ec73bd26b5356c399e1bfe51de2330a1d22ef8 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 18 Aug 2021 15:49:47 +0300 Subject: [PATCH 115/132] new version --- src/consts/const_global.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index c2a161b77..3336f02c3 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -269,10 +269,10 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.2", + VERSION: "1.3.21", - VERSION_COMPATIBILITY: "1.200.3", - VERSION_COMPATIBILITY_POOL_MINERS: "1.200.1", + VERSION_COMPATIBILITY: "1.3.2", + VERSION_COMPATIBILITY_POOL_MINERS: "1.3.2", VERSION_COMPATIBILITY_UPDATE: "", From c73a80f4450e9b66c2260e6b4b4fe385f2c4a333 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 18 Aug 2021 19:14:27 +0300 Subject: [PATCH 116/132] updating scripts --- Dockerfile.dev-env | 2 +- docs/Install-Debian.md | 6 +++--- install-fullnode.sh | 6 +++--- install-miner.sh | 6 +++--- install-pool.sh | 6 +++--- scripts/unix/debian-installation.sh | 6 +++--- tutorials/how-to-deploy-webdollar-pool.md | 6 +++--- tutorials/how-to-mine-webd-linux-terminal.md | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Dockerfile.dev-env b/Dockerfile.dev-env index 2d3dacb1f..eff63523b 100644 --- a/Dockerfile.dev-env +++ b/Dockerfile.dev-env @@ -10,7 +10,7 @@ WORKDIR /workspace/ ENV HOME /workspace/ ENV NVM_DIR /workspace/.nvm -ENV NODE_VERSION 8.2.1 +ENV NODE_VERSION 16 RUN apt-get update && apt-get install -y git curl wget build-essential software-properties-common clang cmake libtool autoconf psmisc opencl-headers ocl-icd-libopencl1 pciutils python2 diff --git a/docs/Install-Debian.md b/docs/Install-Debian.md index 2c990b946..6d743e475 100644 --- a/docs/Install-Debian.md +++ b/docs/Install-Debian.md @@ -28,12 +28,12 @@ bash install_nvm.sh ; source ~/.profile ; nvm ls-remote ; -nvm install 8.2.1 ; -nvm use 8.2.1; +nvm install 16 ; +nvm use 16; node -v ; nvm ls ; -nvm alias default 8.2.1 ; +nvm alias default 16 ; nvm use default ; ``` diff --git a/install-fullnode.sh b/install-fullnode.sh index b80a9abe4..67aa71b18 100755 --- a/install-fullnode.sh +++ b/install-fullnode.sh @@ -77,9 +77,9 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # shellcheck source=/dev/null if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then source ~/.profile; elif cat /etc/*release | grep -q -o -m 1 centos; then source ~/.bash_profile; fi -nvm install 8.2.1 -nvm use 8.2.1 -nvm alias default 8.2.1 +nvm install 16 +nvm use 16 +nvm alias default 16 } ### diff --git a/install-miner.sh b/install-miner.sh index ecbb8abaa..7ee535ae3 100755 --- a/install-miner.sh +++ b/install-miner.sh @@ -77,9 +77,9 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # shellcheck source=/dev/null if cat /etc/*release | grep -q -o -m 1 Ubuntu || cat /etc/*release | grep -q -o -m 1 Debian || cat /etc/*release | grep -q -o -m 1 Raspbian; then source ~/.profile; elif cat /etc/*release | grep -q -o -m 1 centos; then source ~/.bash_profile; fi -nvm install 8.2.1 -nvm use 8.2.1 -nvm alias default 8.2.1 +nvm install 16 +nvm use 16 +nvm alias default 16 } diff --git a/install-pool.sh b/install-pool.sh index 82bf96d38..0a67bab23 100755 --- a/install-pool.sh +++ b/install-pool.sh @@ -64,9 +64,9 @@ if [[ $(cat package.json | grep "name" | sed s'/[",]//g' | awk '{print $2}') == if cat /etc/*release | grep -q -o -m 1 Ubuntu; then sudo apt install -y linuxbrew-wrapper; elif cat /etc/*release | grep -q -o -m 1 Debian; then sudo apt-get install -y linuxbrew-wrapper; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then sudo apt install -y build-essential; elif cat /etc/*release | grep -q -o -m 1 Debian; then sudo apt-get install -y build-essential; elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum group install -y "Development Tools"; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then sudo apt install -y clang; elif cat /etc/*release | grep -q -o -m 1 Debian; then sudo apt-get install -y clang; elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum install -y clang; fi - if cat /etc/*release | grep -q -o -m 1 Ubuntu; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 8.2.1 && nvm use 8.2.1 && nvm alias default 8.2.1; fi \ - elif cat /etc/*release | grep -q -o -m 1 Debian; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 8.2.1 && nvm use 8.2.1 && nvm alias default 8.2.1; fi \ - elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.bash_profile && nvm install 8.2.1 && nvm use 8.2.1 && nvm alias default 8.2.1; fi fi + if cat /etc/*release | grep -q -o -m 1 Ubuntu; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 16 && nvm use 16 && nvm alias default 8.2.1; fi \ + elif cat /etc/*release | grep -q -o -m 1 Debian; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 16 && nvm use 16 && nvm alias default 8.2.1; fi \ + elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.bash_profile && nvm install 16 && nvm use 16 && nvm alias default 8.2.1; fi fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then npm install -g node-gyp; elif cat /etc/*release | grep -q -o -m 1 Debian; then npm install -g node-gyp; elif cat /etc/*release | grep -q -o -m 1 centos; then npm install -g node-gyp; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then npm install pm2 -g --unsafe-perm; elif cat /etc/*release | grep -q -o -m 1 Debian; then npm install pm2 -g --unsafe-perm; elif cat /etc/*release | grep -q -o -m 1 centos; then npm install pm2 -g --unsafe-perm ; fi echo "$showexecute Running npm install..." && npm install diff --git a/scripts/unix/debian-installation.sh b/scripts/unix/debian-installation.sh index 87c67f34a..a0d0cd9e7 100644 --- a/scripts/unix/debian-installation.sh +++ b/scripts/unix/debian-installation.sh @@ -17,12 +17,12 @@ bash install_nvm.sh source ~/.profile nvm ls-remote -nvm install 8.2.1 -nvm use 8.2.1 +nvm install 16 +nvm use 16 node -v nvm ls -nvm alias default 8.2.1 +nvm alias default 16 nvm use default npm install diff --git a/tutorials/how-to-deploy-webdollar-pool.md b/tutorials/how-to-deploy-webdollar-pool.md index 7f5a7ee8e..20e720b01 100644 --- a/tutorials/how-to-deploy-webdollar-pool.md +++ b/tutorials/how-to-deploy-webdollar-pool.md @@ -14,9 +14,9 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" source ~/.profile -nvm install 8.2.1 -nvm use 8.2.1 -nvm alias default 8.2.1 +nvm install 16 +nvm use 16 +nvm alias default 16 npm install -g node-gyp && npm install pm2 -g --unsafe-perm ``` ##### Note: it is recommended to clone WebDollar repo in your home user folder, eg: /home/YOUR_USER/ diff --git a/tutorials/how-to-mine-webd-linux-terminal.md b/tutorials/how-to-mine-webd-linux-terminal.md index 1ac347812..22deaf3e2 100644 --- a/tutorials/how-to-mine-webd-linux-terminal.md +++ b/tutorials/how-to-mine-webd-linux-terminal.md @@ -15,9 +15,9 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" source ~/.profile -nvm install 8.2.1 -nvm use 8.2.1 -nvm alias default 8.2.1 +nvm install 16 +nvm use 16 +nvm alias default 16 npm install -g node-gyp && npm install pm2 -g --unsafe-perm git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar1 # Note: it is recommended to clone WebDollar repo in your home user folder, eg: /home/YOUR_USER/ cd Node-WebDollar1 From c636eba0ff00f686c5849443eff50fac6cce4271 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 18 Aug 2021 19:37:18 +0300 Subject: [PATCH 117/132] fix readme.md --- README.md | 30 +++++------------------------- install-pool.sh | 6 +++--- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 5ef7c5f7a..0a27f8c17 100644 --- a/README.md +++ b/README.md @@ -62,34 +62,14 @@ npm install --global --production windows-build-tools npm install ``` -#### 3.2 node-gyp on Linux - -Installing Argon2 node.js -```shell -sudo apt install linuxbrew-wrapper -``` -In case you receive some errors, try ```sudo apt-get -f install``` - -To check the version `gcc --version` -In case the GCC is not installed, install gcc `brew install gcc` - -```shell -sudo apt-get install clang -npm install -g node-gyp -``` - -`gcc --version` will help you to find the version of GCC you have installed. Webdollar is known to work on GCC 5 and GCC 6. - -Replace `g++-5` with your version -Verify if you can access `g++-5` or whatever version you have. -then install -```shell -env CXX=g++-5 npm install -env CXX=g++-5 npm install argon2 -``` +#### 3.2 Error for updating to 1.3.21 Tutorial based on https://github.com/ranisalt/node-argon2/issues/29 +Install node v16 via nvm +`nvm install 16` +`nvm use 16` +`nvm use default 16` ## 4. SSL (Secure Socket Layer) Certificate diff --git a/install-pool.sh b/install-pool.sh index 0a67bab23..fd7674af3 100755 --- a/install-pool.sh +++ b/install-pool.sh @@ -64,9 +64,9 @@ if [[ $(cat package.json | grep "name" | sed s'/[",]//g' | awk '{print $2}') == if cat /etc/*release | grep -q -o -m 1 Ubuntu; then sudo apt install -y linuxbrew-wrapper; elif cat /etc/*release | grep -q -o -m 1 Debian; then sudo apt-get install -y linuxbrew-wrapper; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then sudo apt install -y build-essential; elif cat /etc/*release | grep -q -o -m 1 Debian; then sudo apt-get install -y build-essential; elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum group install -y "Development Tools"; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then sudo apt install -y clang; elif cat /etc/*release | grep -q -o -m 1 Debian; then sudo apt-get install -y clang; elif cat /etc/*release | grep -q -o -m 1 centos; then sudo yum install -y clang; fi - if cat /etc/*release | grep -q -o -m 1 Ubuntu; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 16 && nvm use 16 && nvm alias default 8.2.1; fi \ - elif cat /etc/*release | grep -q -o -m 1 Debian; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 16 && nvm use 16 && nvm alias default 8.2.1; fi \ - elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.bash_profile && nvm install 16 && nvm use 16 && nvm alias default 8.2.1; fi fi + if cat /etc/*release | grep -q -o -m 1 Ubuntu; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 16 && nvm use 16 && nvm alias default 16; fi \ + elif cat /etc/*release | grep -q -o -m 1 Debian; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.profile && nvm install 16 && nvm use 16 && nvm alias default 16; fi \ + elif cat /etc/*release | grep -q -o -m 1 centos; then if [[ -d $HOME/.nvm ]]; then echo "$showok NVM is already installed!"; elif [[ ! -d $HOME/.nvm ]]; then curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && source ~/.bash_profile && nvm install 16 && nvm use 16 && nvm alias default 16; fi fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then npm install -g node-gyp; elif cat /etc/*release | grep -q -o -m 1 Debian; then npm install -g node-gyp; elif cat /etc/*release | grep -q -o -m 1 centos; then npm install -g node-gyp; fi if cat /etc/*release | grep -q -o -m 1 Ubuntu; then npm install pm2 -g --unsafe-perm; elif cat /etc/*release | grep -q -o -m 1 Debian; then npm install pm2 -g --unsafe-perm; elif cat /etc/*release | grep -q -o -m 1 centos; then npm install pm2 -g --unsafe-perm ; fi echo "$showexecute Running npm install..." && npm install From 2a37320459d333bdedd40afe1a5c7386ecc71936 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Fri, 20 Aug 2021 17:37:09 +0300 Subject: [PATCH 118/132] minor update --- .../node-server/API/public/Node-API-Public-Blocks.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js index 71b5aa899..7e21a25a8 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js @@ -14,19 +14,21 @@ class NodeAPIPublicBlocks{ const startMin = Math.max(0, Blockchain.blockchain.blocks.length - LIMIT_BLOCKS); const endMax = Blockchain.blockchain.blocks.length; - let block_start = req.block_start || startMin; - let block_end = req.block_end || endMax; + let block_start = Number.parseInt(req.block_start) || startMin; + let block_end = Number.parseInt(req.block_end) || endMax; if (block_start < 0 || block_start > endMax) throw {message: "block start is not correct: " + block_start}; if (block_end < 0 || block_end > endMax ) throw {message: "block end is not correct: " + block_start}; if (block_end - block_start > LIMIT_BLOCKS) throw {message: "requested too many blocks: " + block_end - block_start }; - const blocks_to_send = []; + let blocks_to_send = []; for (let i=block_start; i it.toJSON() ) }; } catch (exception) { return {result: false, message: exception.message}; From a5857fbb796f07f52c93427214e884eeeff013e6 Mon Sep 17 00:00:00 2001 From: CryptoCoinGB <45538866+CryptoCoinGB@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:15:44 +0100 Subject: [PATCH 119/132] Update blockchain-bootstrap-locations.md Add HTTPs option for CryptoCoinGB server --- tutorials/blockchain-bootstrap-locations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/blockchain-bootstrap-locations.md b/tutorials/blockchain-bootstrap-locations.md index 93a32ec6f..e41636e9b 100644 --- a/tutorials/blockchain-bootstrap-locations.md +++ b/tutorials/blockchain-bootstrap-locations.md @@ -4,6 +4,8 @@ #### High speed backup source provided by CryptoCoinGB: http://webd-blockchain.ddns.net:9001/blockchainDB3.tar.gz +or HTTPS: +https://webd-blockchain.ddns.net/blockchainDB3.tar.gz Backups are created at 00:00, 06:00, 12:00 and 18:00 UTC. If your download is initiated at these times it may fail due to the file being updated. From 0191d60d1053f8ca220f96ad6a43fe81548a32cc Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Wed, 25 Aug 2021 23:53:46 +0300 Subject: [PATCH 120/132] minor update 1.3.22 --- src/build_terminal.js | 2 +- .../blockchain/global/Blockchain-Genesis.js | 10 +++------- .../global/Blockchain-Mining-Reward.js | 5 ++--- .../addresses/Interface-Blockchain-Address.js | 2 +- .../mining/Interface-Blockchain-Mining.js | 2 +- .../blockchain/Mini-Blockchain.js | 5 ----- src/common/utils/GZip.js | 4 ---- src/consts/const_global.js | 2 +- src/node/jsonRpc/Methods/GetBalance.js | 3 +-- .../node-server/API-router/Node-API-Router.js | 3 ++- .../node-server/API/Node-API-Private.js | 19 ++++++++----------- .../node-server/API/Node-API-Public.js | 5 +---- .../API/anti-dos/Node-API-Anti-Dos.js | 6 +----- .../API/public/Node-API-Public-Blocks.js | 8 ++++---- .../API/public/Node-API-Public-Nodes.js | 6 ++---- .../API/public/Node-API-Public-Pools.js | 1 - .../node-server/express/Node-Express.js | 5 +---- .../node-server/sockets/Node-Server.js | 2 +- .../webrtc/service/node-web-peers-service.js | 2 +- 19 files changed, 31 insertions(+), 61 deletions(-) diff --git a/src/build_terminal.js b/src/build_terminal.js index d7acd7d55..11e346f2a 100644 --- a/src/build_terminal.js +++ b/src/build_terminal.js @@ -1,4 +1,4 @@ -var process = require('process'); +const process = require('process'); import {Node, Blockchain} from './index'; import consts from 'consts/const_global'; diff --git a/src/common/blockchain/global/Blockchain-Genesis.js b/src/common/blockchain/global/Blockchain-Genesis.js index 89a0726e7..f2f3e1518 100644 --- a/src/common/blockchain/global/Blockchain-Genesis.js +++ b/src/common/blockchain/global/Blockchain-Genesis.js @@ -62,15 +62,12 @@ class BlockchainGenesis{ //0..19 pos //20..29 pow - if ( height % 30 < 20) return true; - else return false; + return height % 30 < 20; //29,0..19 pos //20..29 pow - } else - // pos 90% activated - if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { + } else if (height < consts.BLOCKCHAIN.HARD_FORKS.POS100_ACTIVATION) { // pos 90% activated //0..9 pos -10% //9..19 pos -10% @@ -88,8 +85,7 @@ class BlockchainGenesis{ // pos = 90 / 100 // pow = 10 / 100 - if (height % 100 < 90) return true; - else return false; + return height % 100 < 90; } else return true; // pos 100% diff --git a/src/common/blockchain/global/Blockchain-Mining-Reward.js b/src/common/blockchain/global/Blockchain-Mining-Reward.js index 91109fbff..7d3c7ab97 100644 --- a/src/common/blockchain/global/Blockchain-Mining-Reward.js +++ b/src/common/blockchain/global/Blockchain-Mining-Reward.js @@ -122,11 +122,10 @@ class BlockchainMiningReward{ if (typeof height !== "number") throw {message: 'height is not defined'}; - if (height <= consts.BLOCKCHAIN.HARD_FORKS.FORCED_HALVING ){ + if (height <= consts.BLOCKCHAIN.HARD_FORKS.FORCED_HALVING ) return this._getReward(height) - } else { + else return this._getRewardHalving(height) - } } diff --git a/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js b/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js index 521eec415..5e56e36a3 100644 --- a/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js +++ b/src/common/blockchain/interface-blockchain/addresses/Interface-Blockchain-Address.js @@ -80,7 +80,7 @@ class InterfaceBlockchainAddress{ return data; else { - let decr = null; + let decr; if (Array.isArray(password)) decr = MultiSig.getMultiAESDecrypt(data, password); diff --git a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js index 5f15e541e..8904fd400 100644 --- a/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js +++ b/src/common/blockchain/interface-blockchain/mining/Interface-Blockchain-Mining.js @@ -92,7 +92,7 @@ class InterfaceBlockchainMining extends InterfaceBlockchainMiningBasic{ if (!nextBlock){ console.warn("nextBlock couldn't be created"); - await Utils.sleep(1000); + await Utils.sleep(100); continue; } diff --git a/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain.js b/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain.js index e3ad1a6aa..854dceac2 100644 --- a/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain.js +++ b/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain.js @@ -7,7 +7,6 @@ import MiniBlockchainBlockData from '../blocks/Mini-Blockchain-Block-Data' import InterfaceBlockchainBlockCreator from 'common/blockchain/interface-blockchain/blocks/Interface-Blockchain-Block-Creator' import MiniBlockchainTransactions from "../transactions/Mini-Blockchain-Transactions" import RevertActions from "common/utils/Revert-Actions/Revert-Actions" -import global from "consts/global" import MiniBlockchainBlocks from "./../blocks/Mini-Blockchain-Blocks" let inheritBlockchain; @@ -119,14 +118,10 @@ class MiniBlockchain extends inheritBlockchain{ return true; } - - getBalances(address){ return this.accountantTree.getBalances(address); } - - } export default MiniBlockchain \ No newline at end of file diff --git a/src/common/utils/GZip.js b/src/common/utils/GZip.js index 357774141..ec53c4849 100644 --- a/src/common/utils/GZip.js +++ b/src/common/utils/GZip.js @@ -3,15 +3,11 @@ var zlib = require('zlib'); class GZip{ zip(buffer){ - return zlib.deflateSync(buffer); - } unzip(buffer){ - return zlib.unzipSync(buffer); - } } diff --git a/src/consts/const_global.js b/src/consts/const_global.js index 3336f02c3..b917d35fd 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -269,7 +269,7 @@ consts.SETTINGS = { NODE: { - VERSION: "1.3.21", + VERSION: "1.3.22", VERSION_COMPATIBILITY: "1.3.2", VERSION_COMPATIBILITY_POOL_MINERS: "1.3.2", diff --git a/src/node/jsonRpc/Methods/GetBalance.js b/src/node/jsonRpc/Methods/GetBalance.js index b0213249d..d739ab654 100644 --- a/src/node/jsonRpc/Methods/GetBalance.js +++ b/src/node/jsonRpc/Methods/GetBalance.js @@ -17,9 +17,8 @@ class GetBalance extends RpcMethod { sAddress = InterfaceBlockchainAddressHelper.getUnencodedAddressFromWIF(sAddress); if (sAddress === null) - { throw new Error('Address cannot be decoded'); - } + } catch (exception) { console.error(exception); diff --git a/src/node/sockets/node-server/API-router/Node-API-Router.js b/src/node/sockets/node-server/API-router/Node-API-Router.js index 57751525a..a9082710c 100644 --- a/src/node/sockets/node-server/API-router/Node-API-Router.js +++ b/src/node/sockets/node-server/API-router/Node-API-Router.js @@ -55,6 +55,8 @@ class NodeAPIRouter{ if (process.env.WALLET_SECRET_URL && typeof process.env.WALLET_SECRET_URL === "string" && process.env.WALLET_SECRET_URL.length >= 30) { + this._addRoute( process.env.WALLET_SECRET_URL+'/list', this.showRoutes.bind(this), nodeApiType, 200 , app, prefix, middleWare ); + this._addRoute( process.env.WALLET_SECRET_URL+'/blocks_complete/at/:block', NodeAPIPublicBlocks.blockComplete, nodeApiType, 20, app, prefix, middleWare ); this._addRoute(process.env.WALLET_SECRET_URL+'/mining/balance', NodeAPIPrivate.minerBalance, nodeApiType, 100, app, prefix, middleWare ); @@ -103,7 +105,6 @@ class NodeAPIRouter{ // respond with "ping" this._addRoute( 'ping', NodeAPIPublic.ping, nodeApiType, 1000, app, prefix, middleWare ); - this._addRoute( 'list', this.showRoutes.bind(this), nodeApiType, 200 , app, prefix, middleWare ); } diff --git a/src/node/sockets/node-server/API/Node-API-Private.js b/src/node/sockets/node-server/API/Node-API-Private.js index 44090f9ae..a0bb9e8cc 100644 --- a/src/node/sockets/node-server/API/Node-API-Private.js +++ b/src/node/sockets/node-server/API/Node-API-Private.js @@ -5,25 +5,22 @@ import InterfaceBlockchainAddressHelper from 'common/blockchain/interface-blockc class NodeAPIPrivate{ constructor(){ - } minerBalance(req, res){ - let addressString = Blockchain.blockchain.mining.minerAddress; let balance = Blockchain.blockchain.accountantTree.getBalance(addressString, undefined); balance = (balance === null) ? 0 : (balance / WebDollarCoins.WEBD); return {address: addressString, balance: balance}; - } async walletImport(req, res){ - let address = req.address; - let publicKey = req.publicKey; - let privateKey = req.privateKey; + const address = req.address; + const publicKey = req.publicKey; + const privateKey = req.privateKey; let content = { version: '0.1', @@ -53,16 +50,16 @@ class NodeAPIPrivate{ var from; var to; - if (req.from && req.from != 'null' && - req.to && req.to != 'null' && - req.amount && req.amount != 'null') { + if (req.from && req.from !== 'null' && + req.to && req.to !== 'null' && + req.amount && req.amount !== 'null') { from = req.from; to = req.to; - } else if(req.from && req.from != 'null') { + } else if(req.from && req.from !== 'null') { // fan out from = req.from; to = req.multiple_to; - } else if(req.to && req.to != 'null') { + } else if(req.to && req.to !== 'null') { // fan in from = req.multiple_from; to = req.to; diff --git a/src/node/sockets/node-server/API/Node-API-Public.js b/src/node/sockets/node-server/API/Node-API-Public.js index 64dfcfa17..8da01b32d 100644 --- a/src/node/sockets/node-server/API/Node-API-Public.js +++ b/src/node/sockets/node-server/API/Node-API-Public.js @@ -28,9 +28,8 @@ class NodeAPIPublic{ let nSecondsBehind = currentTimestamp - blockTimestamp; const UNSYNC_THRESHOLD = 600 * 1000; // ~ 15 blocks - if (nSecondsBehind < UNSYNC_THRESHOLD) { + if (nSecondsBehind < UNSYNC_THRESHOLD) is_synchronized = true; - } return { @@ -79,11 +78,9 @@ class NodeAPIPublic{ } return { - top: Blockchain.blockchain.blocks.length, is_synchronized: is_synchronized, secondsBehind : nSecondsBehind / 1000 - } } diff --git a/src/node/sockets/node-server/API/anti-dos/Node-API-Anti-Dos.js b/src/node/sockets/node-server/API/anti-dos/Node-API-Anti-Dos.js index 6c52da051..35843c2f3 100644 --- a/src/node/sockets/node-server/API/anti-dos/Node-API-Anti-Dos.js +++ b/src/node/sockets/node-server/API/anti-dos/Node-API-Anti-Dos.js @@ -3,7 +3,6 @@ class NodeAPIAntiDos{ constructor(){ this.waitlist = []; - this.totalWeights = {}; setInterval(this._reduceWeights.bind(this), 1000); @@ -40,8 +39,7 @@ class NodeAPIAntiDos{ protectRoute(route, callback){ let element = this.totalWeights[route]; - - if (element === undefined) return callback(); + if (!element) return callback(); if (element.weight >= element.max ) return {result:false, message: "TOO MANY REQUESTS"}; @@ -49,8 +47,6 @@ class NodeAPIAntiDos{ element.weight++; return callback(); - - } } diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js index 7e21a25a8..2abddd7b4 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Blocks.js @@ -38,10 +38,10 @@ class NodeAPIPublicBlocks{ async block(req, res){ - let index = req.block; - try { + let index = req.block; + if (index < Blockchain.blockchain.blocksStartingPoint) throw {message: "Invalid index."}; if (index > Blockchain.blockchain.blocks.length) throw {message: "Block not found."}; @@ -55,10 +55,10 @@ class NodeAPIPublicBlocks{ async blockComplete(req, res){ - let index = req.block; - try { + let index = req.block; + if (index < Blockchain.blockchain.blocksStartingPoint) throw {message: "Invalid index."}; if (index > Blockchain.blockchain.blocks.length) throw {message: "Block not found."}; diff --git a/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js b/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js index 07948d4c1..25ac76f0f 100644 --- a/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js +++ b/src/node/sockets/node-server/API/public/Node-API-Public-Nodes.js @@ -10,16 +10,14 @@ class NodeAPIPublicNodes{ try{ - let clients = [], servers=[]; + const clients = [], servers = []; for (let i=0; i{ + Blockchain.onLoaded.then( (answer)=>{ // in case the Blockchain was not loaded, I will not be interested in transactions From f1cc13bc2ebb37ec35df736140d52fdebcb385fa Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 28 Aug 2021 10:24:48 +0300 Subject: [PATCH 121/132] @lazypillow update --- src/node/menu/CLI-Menu.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/node/menu/CLI-Menu.js b/src/node/menu/CLI-Menu.js index b789904e0..7fd2be0b8 100644 --- a/src/node/menu/CLI-Menu.js +++ b/src/node/menu/CLI-Menu.js @@ -17,7 +17,6 @@ import NodeServer from 'node/sockets/node-server/sockets/Node-Server'; import Log from 'common/utils/logging/Log'; import CLICore from "./CLI-Core"; import CLIRunner from './CLI-Menu-non-interactive'; -import process from "process"; process.on('error', (err) => { console.error(`Caught exception: ${err}`); From ef4bcf4fc4947d4697d8e1fcb11e1ed0a5f399be Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 28 Aug 2021 10:36:02 +0300 Subject: [PATCH 122/132] @lazyipillow update 2 --- .../blockchain/interface-blockchain/addresses/MultiSig.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/blockchain/interface-blockchain/addresses/MultiSig.js b/src/common/blockchain/interface-blockchain/addresses/MultiSig.js index d29debc1e..4386789d0 100644 --- a/src/common/blockchain/interface-blockchain/addresses/MultiSig.js +++ b/src/common/blockchain/interface-blockchain/addresses/MultiSig.js @@ -2,7 +2,6 @@ * Copyright (c) Silviu Stroe 2018. */ const BitcoinJS = require('bitcoinjs-lib'); -const Bigi = require('bigi'); const Crypto = require('crypto'); import WebDollarCrypto from 'common/crypto/WebDollar-Crypto'; @@ -200,4 +199,4 @@ class MultiSig { } -export default MultiSig; \ No newline at end of file +export default MultiSig; From 81cdcefe86ff83757d796bf84e24e285e79cc12f Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 28 Aug 2021 22:26:36 +0300 Subject: [PATCH 123/132] @lazypillow suggestions --- src/consts/const_global.js | 2 -- src/node/sockets/node-server/express/Node-Express.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/consts/const_global.js b/src/consts/const_global.js index b917d35fd..24029770d 100644 --- a/src/consts/const_global.js +++ b/src/consts/const_global.js @@ -272,7 +272,6 @@ consts.SETTINGS = { VERSION: "1.3.22", VERSION_COMPATIBILITY: "1.3.2", - VERSION_COMPATIBILITY_POOL_MINERS: "1.3.2", VERSION_COMPATIBILITY_UPDATE: "", @@ -545,7 +544,6 @@ if ( consts.DEBUG === true ) { consts.SETTINGS.NODE.VERSION = "1.210.9" ; consts.SETTINGS.NODE.VERSION_COMPATIBILITY = "1.210.9"; - consts.SETTINGS.NODE.VERSION_COMPATIBILITY_POOL_MINERS = "1.210.9"; } diff --git a/src/node/sockets/node-server/express/Node-Express.js b/src/node/sockets/node-server/express/Node-Express.js index 7ef8cc6de..0cef8588d 100644 --- a/src/node/sockets/node-server/express/Node-Express.js +++ b/src/node/sockets/node-server/express/Node-Express.js @@ -243,8 +243,8 @@ class NodeExpress{ close(){ - if (this.app) - this.app.close(); + if (this.server) + this.server.close(); } } From fd0ee8bb7e91645d8fb4c59ec7d9a5b85cab7df2 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Mon, 30 Aug 2021 13:18:44 +0300 Subject: [PATCH 124/132] request package missing --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8dcf6fd9b..35e984e5f 100644 --- a/package.json +++ b/package.json @@ -75,11 +75,12 @@ "node-gyp": "^8.1.0", "opn": "^5.2.0", "path": "^0.12.7", - "pouchdb-node": "^7.2.2", "pouchdb-browser": "^7.2.2", + "pouchdb-node": "^7.2.2", "public-ip": "^2.4.0", "raven": "^2.6.4", "readline": "^1.3.0", + "request": "^2.88.2", "request-promise": "^4.2.2", "safe-compare": "^1.1.2", "sanitizer": "^0.1.3", From 3c372fc5b3e29703efec52037cd7d9e48b34db14 Mon Sep 17 00:00:00 2001 From: tomonetml <34745293+tomonetml@users.noreply.github.com> Date: Thu, 9 Sep 2021 16:43:15 +0200 Subject: [PATCH 125/132] Update fallback_nodes_list.js --- .../service/discovery/fallbacks/fallback_nodes_list.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index 0e08bedfb..9ed960dc4 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -8,7 +8,8 @@ export default { //--------------------------------------------------------- //--------------Community FallBack Nodes------------------- //--------------------------------------------------------- - + + {"addr": ["https://webd.serverworks.ro:443"]}, // Thanks to TomCat @javra_the_mutt {"addr": ["https://webd.5q.ro:8443"]}, // Thanks to Sorin M From 64afd235a336b388522f143f8cd2d9e1aa269838 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Thu, 9 Sep 2021 14:44:18 -0600 Subject: [PATCH 126/132] Update .nvmrc to use node v16 --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index e51c059b1..6f7f377bf 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v8.2.1 +v16 From 5d695ae466bd9b98615aa9721338333efb71c194 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Thu, 9 Sep 2021 20:02:34 -0600 Subject: [PATCH 127/132] Fix core Dockerfile build, update README.md on node versioning. --- Dockerfile | 6 +++--- README.md | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b0547c80..c80c07b00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM node:8-alpine +FROM node:16-alpine # Install build packages and npm global packages RUN apk update && \ - apk add --no-cache make gcc g++ python certbot && \ + apk add --no-cache make gcc g++ python2 certbot && \ npm install -g cross-env webpack webpack-cli pm2 # Copy files @@ -15,7 +15,7 @@ RUN npm install RUN npm run build_terminal # Clean Everything -RUN apk del make gcc g++ python && \ +RUN apk del make gcc g++ python2 && \ rm -rf /tmp/* /var/cache/apk/* && \ npm cache clean --force diff --git a/README.md b/README.md index 0a27f8c17..0f4c5225a 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,10 @@ docker run -d --restart=always -v /webdollar/data:/blockchainDB3 -e NOSSL=true - ## 0. Node.js -**Required: v8.x** -It doesn't work with the new version 9.x +**Required: v16.x** + +[nvm](https://github.com/nvm-sh/nvm) is the recommended tooling to get the right version. Simply run `nvm use` from the root of this project. + **Windows**: You can download Node.js from this URL: https://nodejs.org/en/download/ From 6ccd9d9ddf45e4ea72cb1def758548b320e9f2d6 Mon Sep 17 00:00:00 2001 From: Brandon Ward Date: Thu, 9 Sep 2021 20:34:35 -0600 Subject: [PATCH 128/132] Attempt to fix wrecker build --- wercker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wercker.yml b/wercker.yml index 432fbfb79..996ff536f 100644 --- a/wercker.yml +++ b/wercker.yml @@ -32,7 +32,7 @@ build: code: npm run build_terminal_menu - script: name: build worker - code: npm run build_terminal_worker + code: npm run build_terminal deploy_branch: steps: From 78b16ca9c9a0ce3b770bd0009e706e2c2650b08d Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 11 Sep 2021 11:35:03 +0300 Subject: [PATCH 129/132] new fallback node --- .../service/discovery/fallbacks/fallback_nodes_list.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js index 0e08bedfb..dbee899b7 100644 --- a/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js +++ b/src/node/sockets/node-clients/service/discovery/fallbacks/fallback_nodes_list.js @@ -20,7 +20,8 @@ export default { {"addr": ["https://webdmine.io:8443"]}, // USA WEBDmine pools ( free nodes forever ) {"addr": ["https://pool.maison:8443"]}, // EUROPE WEBDmine pools ( free nodes forever ) {"addr": ["https://europe.pool.maison:8443"]}, // EUROPE WEBDmine pools ( free nodes forever ) - + {"addr": ["https://node.spyclub.ro:8080/"]}, // @emsici + //{"addr": ["https://webdollar-vps1.ddns.net:80"]}, {"addr": ["https://node1.petreus.ro:443"]}, // Thanks to Dani Petreus From 81c37aba28dd0790df4863e2b376cb0d611fab82 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Thu, 23 Sep 2021 10:48:22 +0300 Subject: [PATCH 130/132] new pool --- src/common/mining-pools/miner/Miner-Pool-Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/mining-pools/miner/Miner-Pool-Settings.js b/src/common/mining-pools/miner/Miner-Pool-Settings.js index e4f917ed6..1109e1174 100644 --- a/src/common/mining-pools/miner/Miner-Pool-Settings.js +++ b/src/common/mining-pools/miner/Miner-Pool-Settings.js @@ -235,6 +235,7 @@ class MinerPoolSettings { await this.addPoolList("/pool/1/LOFT/0.01/777b64f4425cf319cd6f178d890178e6c5d5d367d65f100a3c8d71d815fef0d4/https:$$pool.maison:8443", undefined, true); await this.addPoolList("/pool/1/Balanel_si_Miaunel/0.02/cd7217ad76118df5357ae7a094aa48096daae8a67767bd3acbc8638dc68955ac/https:$$webd.pool.coffee:8443", undefined, true); await this.addPoolList("pool/1/EuroPool/0.02/f06b4720a725eb4fe13c06b26fca4c862b2f2f2ddc831e411418aceefae8e6df/https:$$webd-europool.ddns.net:2222", undefined, true); + await this.addPoolList("/pool/1/SpyClub/0.02/401c8f09a1fd93ea11737bffe062b9f51b7b2e793cea499084b7752948d5d21f/https:$$node.spyclub.ro:8080", undefined, true); await this.addPoolList("/pool/1/WMP/0.02/d02e26e60a5b0631a0b71e7dc72bb7492fd018dad64531498df369ec14f87962/https:$$server.webdollarminingpool.com:443", undefined, true); await this.addPoolList("/pool/1/Timi/0.001/7d863060bc5bf81695f53c5e61c79677ad6cb3b5fd48dafebbabb25f7dca8797/https:$$pool.timi.ro:443", undefined, true); await this.addPoolList("/pool/1/WMP-ASIA/0.02/773a8d5f7ce3c0dba0b7216c35d2768b1a6abef716fa2a46d875d6ca0e2c115e/https:$$singapore.webdollarminingpool.com:443", undefined, true); From 9b2c6acaf9f79602d3acb707b30f73bb2c40edf2 Mon Sep 17 00:00:00 2001 From: CryptoCoinGB <45538866+CryptoCoinGB@users.noreply.github.com> Date: Mon, 4 Oct 2021 07:02:55 +0100 Subject: [PATCH 131/132] Update blockchain-bootstrap-locations.md Often people would miss the . at the end of the command structure, this has now been replaced with the folder name to make it simpler. I've also removed the now unnecessary step of CD'ing into the folder. --- tutorials/blockchain-bootstrap-locations.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tutorials/blockchain-bootstrap-locations.md b/tutorials/blockchain-bootstrap-locations.md index e41636e9b..3465781d5 100644 --- a/tutorials/blockchain-bootstrap-locations.md +++ b/tutorials/blockchain-bootstrap-locations.md @@ -12,10 +12,9 @@ If your download is initiated at these times it may fail due to the file being u Instructions (from within your WebDollar folder): + delete the old blockchainDB3 directory if it exists (command: sudo rm -r blockchainDB3) -+ make a new empty blockchainDB3 directory (command: mkdir blockchainDB3) -+ open the new directory (command: cd blockchainDB3) + use 'wget' to download the file from the link above (command: wget http://webd-blockchain.ddns.net:9001/blockchainDB3.tar.gz) -+ extract the file (command: tar -zxvf blockchainDB3.tar.gz -C .) ++ make a new empty blockchainDB3 directory (command: mkdir blockchainDB3) ++ extract the file (command: tar -zxvf blockchainDB3.tar.gz -C blockchainDB3) ----------- @@ -27,9 +26,8 @@ If your download is initiated at these times it may fail due to the file being u Instructions (from within your WebDollar folder): + delete the old blockchainDB3 directory if it exists (command: sudo rm -r blockchainDB3) -+ make a new empty blockchainDB3 directory (command: mkdir blockchainDB3) -+ open the new directory (command: cd blockchainDB3) + use 'wget' to download the file from the link above (command: wget http://blockchain.timi.ro/blockchainDB3.tar.gz) -+ extract the file (command: tar -zxvf blockchainDB3.tar.gz -C .) ++ make a new empty blockchainDB3 directory (command: mkdir blockchainDB3) ++ extract the file (command: tar -zxvf blockchainDB3.tar.gz -C blockchainDB3) ----------- From f4331c161531420a1b194bbf3c412ba68f2e8082 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Budisteanu Date: Sat, 23 Oct 2021 18:11:18 +0300 Subject: [PATCH 132/132] displaying more info --- .../blockchain/Mini-Blockchain-Advanced.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain-Advanced.js b/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain-Advanced.js index 2fd3efc7a..c12b1e92c 100644 --- a/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain-Advanced.js +++ b/src/common/blockchain/mini-blockchain/blockchain/Mini-Blockchain-Advanced.js @@ -96,17 +96,23 @@ class MiniBlockchainAdvanced extends MiniBlockchain{ Log.info('Accountant Tree Saving ', Log.LOG_TYPE.SAVING_MANAGER); console.info("accountant tree", this.accountantTree.root.hash.toString("hex")); - console.info("accountant tree", this.accountantTree.root.edges.length); + console.info("accountant tree", this.accountantTree.root.edges.length, serialization.length ); if (!(await this.accountantTree.saveMiniAccountant(true, "accountantTree", serialization))) throw {message: "saveMiniAccountant couldn't be saved"}; + console.info("accountant tree saving blockchain length", length ); + if ( !(await this.blocks.saveBlockchainLength(length)) ) throw {message: "save blockchain length couldn't be saved"}; + console.info("accountant tree saving profs"); + if ( !(await this.prover.provesCalculated._saveProvesCalculated()) ) throw { message: "save proves calculated couldn't be saved" }; + console.info("accountant tree profs saved"); + this._miniBlockchainSaveBlocks = length; return true;