Skip to content

Commit

Permalink
Merge pull request #99 from VerusCoin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Asherda committed May 8, 2021
2 parents e801564 + 4147ea2 commit 22018b1
Show file tree
Hide file tree
Showing 68 changed files with 2,897 additions and 1,403 deletions.
28 changes: 26 additions & 2 deletions .gitlab-ci.yml
Expand Up @@ -8,8 +8,8 @@ stages:
variables:
DOCKER_DRIVER: overlay2
DEFAULT_VERUSCOIN_BRANCH: release
VERUS_VERSION: 0.7.2-9
VERUSCOIN_VERSION: 0.7.2-8
VERUS_VERSION: 0.7.3
VERUSCOIN_VERSION: 0.7.3
KOMODO_VERSION: 0.6.1
BINARY_SOURCE: VerusCoin
VERUS_APPIMAGE_X64: Verus-Desktop-v${VERUS_VERSION}-x86_64.AppImage
Expand Down Expand Up @@ -54,13 +54,18 @@ build:linux:
- tar -xzvf Verus-CLI-Linux-v${VERUSCOIN_VERSION}-x86_64.tar.gz --strip=1 --directory assets/bin/linux64/verusd
- rm Verus-CLI-Linux-v${VERUSCOIN_VERSION}-x86_64.tar.gz
- mkdir -p assets/bin/linux64/komodod
- mkdir -p assets/bin/linux64/pirated
- wget https://github.com/KomodoPlatform/komodo/releases/download/${KOMODO_VERSION}/komodo_linux_${KOMODO_VERSION}.tar.gz
- tar -xzvf komodo_linux_${KOMODO_VERSION}.tar.gz --strip=1 --directory assets/bin/linux64/komodod
- rm komodo_linux_${KOMODO_VERSION}.tar.gz
- strip --strip-unneeded assets/bin/linux64/komodod/komodod && strip --strip-unneeded assets/bin/linux64/komodod/komodo-cli
- gsutil cp $STAGING/VerusCoin/Zcash/zcashd-linux-x86_64.tar.gz .
- tar -xzvf zcashd-linux-x86_64.tar.gz --directory assets/bin/linux64/
- rm zcashd-linux-x86_64.tar.gz
- wget https://github.com/PirateNetwork/pirate/releases/download/v5.0.0/pirate-cli-ubuntu1804-v5.0.0.zip
- unzip pirate-cli-ubuntu1804-v5.0.0.zip -d assets/bin/linux64/pirated
- rm pirate-cli-ubuntu1804-v5.0.0.zip
- sed -i "s/process.env.INFURA_PROJECT_ID/'${INFURA_PROJECT_ID}'/g" keys/infura.js
- sed -i "s/process.env.ETHERSCAN_API_KEY/'${ETHERSCAN_KEY}'/g" keys/etherscan.js
- yarn install
script:
Expand Down Expand Up @@ -93,12 +98,17 @@ build:linux:arm64:
- yarn run build
- cd ../../..
- mkdir -p assets/bin/linux64/verusd
- mkdir -p assets/bin/linux64/pirated
- gsutil cp $STAGING/$VERUS_CLI_LINUX .
- tar -xzvf Verus-CLI-Linux-v${VERUSCOIN_VERSION}-arm64.tar.gz --strip=1 --directory assets/bin/linux64/verusd
- rm Verus-CLI-Linux-v${VERUSCOIN_VERSION}-arm64.tar.gz
- gsutil cp $STAGING/VerusCoin/Zcash/zcashd-linux-arm64.tar.gz .
- tar -xzvf zcashd-linux-arm64.tar.gz --directory assets/bin/linux64/
- rm zcashd-linux-arm64.tar.gz
- wget https://github.com/PirateNetwork/pirate/releases/download/v5.0.0/pirate-cli-aarch64-v5.0.0.zip
- unzip pirate-cli-aarch64-v5.0.0.zip -d assets/bin/linux64/pirated
- rm pirate-cli-aarch64-v5.0.0.zip
- sed -i "s/process.env.INFURA_PROJECT_ID/'${INFURA_PROJECT_ID}'/g" keys/infura.js
- sed -i "s/process.env.ETHERSCAN_API_KEY/'${ETHERSCAN_KEY}'/g" keys/etherscan.js
- yarn install
script:
Expand Down Expand Up @@ -134,6 +144,7 @@ build:windows:
- yarn run build
- cd ../../..
- mkdir -p assets/bin/win64/komodod
- mkdir -p assets/bin/win64/pirated
- wget https://github.com/KomodoPlatform/komodo/releases/download/${KOMODO_VERSION}/komodo_windows_${KOMODO_VERSION}.zip
- unzip komodo_windows_${KOMODO_VERSION}.zip
- mv win64/komodod.exe win64/komodo-cli.exe assets/bin/win64/komodod
Expand All @@ -147,6 +158,10 @@ build:windows:
- gsutil cp $STAGING/VerusCoin/Zcash/zcashd-win.tar.gz .
- tar -xzvf zcashd-win.tar.gz --directory assets/bin/win64/
- rm zcashd-win.tar.gz
- wget https://github.com/PirateNetwork/pirate/releases/download/v5.0.0/pirate-cli-windows-v5.0.0.zip
- unzip pirate-cli-windows-v5.0.0.zip -d assets/bin/win64/pirated
- rm pirate-cli-windows-v5.0.0.zip
- sed -i "s/process.env.INFURA_PROJECT_ID/'${INFURA_PROJECT_ID}'/g" keys/infura.js
- sed -i "s/process.env.ETHERSCAN_API_KEY/'${ETHERSCAN_KEY}'/g" keys/etherscan.js
- yarn install
script:
Expand All @@ -169,6 +184,10 @@ build:mac:
stage: build
tags: ["Mojave"]
before_script:
- echo "$AUTH_KEY" > AUTH_KEY.json &&
gcloud auth activate-service-account
--key-file AUTH_KEY.json &&
rm AUTH_KEY.json
- if [ -z "${UPSTREAM_CLI_BRANCH}" ]; then export
VERUS_CLI_MACOS="${BINARY_SOURCE}/${DEFAULT_VERUSCOIN_BRANCH}/MacOS/Verus-CLI-MacOS-v${VERUSCOIN_VERSION}.tar.gz";
POST_COMMENT="${POST_COMMENT}Using ${BINARY_SOURCE}/${DEFAULT_VERUSCOIN_BRANCH} binaries.";
Expand All @@ -182,13 +201,18 @@ build:mac:
- wget https://github.com/KomodoPlatform/komodo/releases/download/${KOMODO_VERSION}/komodo_macos_${KOMODO_VERSION}.tar.gz
- mkdir -p assets/bin/osx/verusd
- mkdir -p assets/bin/osx/komodod
- mkdir -p assets/bin/osx/pirated
- tar -xzf Verus-CLI-MacOS-v${VERUSCOIN_VERSION}.tar.gz --strip=1 --directory assets/bin/osx/verusd
- tar -xzvf komodo_macos_${KOMODO_VERSION}.tar.gz --strip=1 --directory assets/bin/osx/komodod
- rm komodo_macos_${KOMODO_VERSION}.tar.gz
- rm Verus-CLI-MacOS-v${VERUSCOIN_VERSION}.tar.gz
- gsutil cp $STAGING/VerusCoin/Zcash/zcashd-macos.tar.gz .
- tar -xzvf zcashd-macos.tar.gz --directory assets/bin/osx/
- rm zcashd-macos.tar.gz
- wget https://github.com/PirateNetwork/pirate/releases/download/v5.0.0/pirate-cli-MacOS-v5.0.0.zip
- unzip pirate-cli-MacOS-v5.0.0.zip -d assets/bin/osx/pirated
- rm pirate-cli-MacOS-v5.0.0.zip
- sed -i -e "s/process.env.INFURA_PROJECT_ID/'${INFURA_PROJECT_ID}'/g" keys/infura.js
- sed -i -e "s/process.env.ETHERSCAN_API_KEY/'${ETHERSCAN_KEY}'/g" keys/etherscan.js
- yarn install
script:
Expand Down
2 changes: 1 addition & 1 deletion gui/Verus-Desktop-GUI
Submodule Verus-Desktop-GUI updated 354 files
8 changes: 8 additions & 0 deletions keys/infura.js
@@ -0,0 +1,8 @@
// THIS IS SENSITIVE DATA, DO NOT PUSH TO GIT!

// API Keys for infura are stored here, if you fork Verus-Desktop, you need to use your
// own here or ETH/ERC20 coins will not work

module.exports = {
INFURA_PROJECT_ID: process.env.INFURA_PROJECT_ID
}
6 changes: 0 additions & 6 deletions main.js
Expand Up @@ -316,7 +316,6 @@ function createWindow(status) {
mainWindow = new BrowserWindow({
width: 500,
height: 355,
frame: false,
icon: agamaIcon,
show: false,
webPreferences: {
Expand Down Expand Up @@ -379,11 +378,6 @@ function createWindow(status) {
});

function appExit() {
if (((api.appConfig.general.main.dev || process.argv.indexOf('devmode') > -1) && api.appConfig.general.electrum.cache) ||
(!api.appConfig.general.main.dev && process.argv.indexOf('devmode') === -1)) {
api.saveLocalSPVCache();
}

const CloseDaemons = () => {
return new Promise((resolve, reject) => {
api.log('Closing Main Window...', 'quit');
Expand Down
16 changes: 10 additions & 6 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "verus-desktop",
"productName": "Verus-Desktop",
"version": "0.7.2-9",
"version": "0.7.3",
"description": "Verus Desktop Wallet App",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -50,7 +50,6 @@
"arch": "^2.1.0",
"async": "^2.6.0",
"bigi": "^1.4.2",
"bip39": "^2.5.0",
"bitgo-utxo-lib": "git+https://github.com/VerusCoin/bitgo-utxo-lib.git",
"blake2b": "https://github.com/michaeltout/blake2b.git",
"bluebird": "^3.4.7",
Expand All @@ -60,13 +59,15 @@
"create-hash": "git://github.com/pbca26/createHash#electron-v4",
"crypto-js": "^4.0.0",
"csv-writer": "^1.6.0",
"ethers": "^4.0.44",
"ethers": "^5.1.0",
"ethers-michaeltout": "github:michaeltout/ethersjs-package",
"express": "^4.14.0",
"fix-path": "^2.1.0",
"fs-extra": "^9.1.0",
"graceful-fs": "^4.1.11",
"iocane": "^1.0.0",
"js-sha256": "^0.7.1",
"node-cache": "^5.1.2",
"nodejs-aes256": "^1.0.1",
"passwd-strength": "https://github.com/michaeltout/passwd-strength.git",
"portscanner": "^2.1.1",
Expand Down Expand Up @@ -147,18 +148,21 @@
}
},
"resolutions": {
"lodash": "^4.17.20",
"lodash": "^4.17.21",
"js-yaml": "^3.13.1",
"tar": "^4.4.8",
"https-proxy-agent": "2.2.4",
"mem": "4.0.0",
"bin-links": "1.1.6",
"yargs-parser": "^13.1.2",
"minimist": "^1.2.5",
"elliptic": "^6.5.3",
"elliptic": "^6.5.4",
"bn.js": "^4.11.8",
"dot-prop": "^5.2.0",
"npm-registry-fetch": "^4.0.5",
"ini": "1.3.8"
"ini": "1.3.8",
"ssri": "8.0.1",
"y18n": "5.0.5",
"hosted-git-info":"3.0.8"
}
}
46 changes: 28 additions & 18 deletions routes/api.js
Expand Up @@ -12,7 +12,7 @@ api.assetChainPortsDefault = require('./ports.js');
api._appConfig = require('./appConfig.js');
api.chainParams = require('./chainParams')

api.coinsInitializing = [];
api.coinsInitializing = {};
api.startedDaemonRegistry = {};
api.confFileIndex = {};
api.logFileIndex = {};
Expand Down Expand Up @@ -83,14 +83,17 @@ api = require('./api/utility_apis/checkUpdates')(api);
api.createAgamaDirs();
api.appConfig = api.loadLocalConfig();

api = require('./api/utility_apis/cache')(api);

api.appConfigSchema = api._appConfig.schema;
api.defaultAppConfig = Object.assign({}, api.appConfig);
api.kmdMainPassiveMode = false;
api.native = {
startParams: {},
cache: {
tx_cache: {},
addr_balance_cache: {}
addr_balance_cache: {},
currency_definition_cache: api.create_sub_cache("native.cache.currency_definition_cache"),
}
};

Expand Down Expand Up @@ -142,12 +145,14 @@ api = require('./api/native/getTransaction.js')(api);
api = require('./api/native/transactions')(api);
api = require('./api/native/zoperations')(api);
api = require('./api/native/remove')(api);
api = require('./api/native/restart')(api);
api = require('./api/native/send.js')(api);
api = require('./api/native/sendcurrency.js')(api);
api = require('./api/native/reservetransfers.js')(api);
api = require('./api/native/nameRegistration.js')(api);
api = require('./api/native/idRegistration.js')(api);
api = require('./api/native/idRevocation.js')(api);
api = require('./api/native/idUpdate.js')(api);
api = require('./api/native/idInformation.js')(api);
api = require('./api/native/getCurrencies.js')(api);
api = require('./api/native/getCurrency.js')(api);
Expand Down Expand Up @@ -190,25 +195,36 @@ api = require('./api/kv.js')(api);

// eth
api.eth = {
coins: {},
connect: {},
gasPrice: {},
tokenInfo: {},
abi: {},
wallet: null,
interface: null,
temp: {
pending_txs: {}
}
};
api = require('./api/eth/contracts/contracts.js')(api);

// erc20
api.erc20 = {
wallet: null,
contracts: {}
}

api = require('./api/eth/auth.js')(api);
api = require('./api/eth/keys.js')(api);
api = require('./api/eth/network.js')(api);
api = require('./api/eth/balances.js')(api);
api = require('./api/eth/addresses')(api);
api = require('./api/eth/info')(api);
api = require('./api/eth/transactions.js')(api);
api = require('./api/eth/coins.js')(api);
api = require('./api/eth/gasPrice.js')(api);
api = require('./api/eth/remove')(api);
api = require('./api/eth/send.js')(api);
api = require('./api/eth/contracts/rfox/migration')(api);

api = require('./api/erc20/auth.js')(api);
api = require('./api/erc20/balances.js')(api);
api = require('./api/erc20/addresses')(api);
api = require('./api/erc20/info')(api);
api = require('./api/erc20/transactions.js')(api);
api = require('./api/erc20/coins.js')(api);
api = require('./api/erc20/send.js')(api);
api = require('./api/erc20/rfox/migration.js')(api);

api.printDirs();

Expand All @@ -226,12 +242,6 @@ api.setVar = (_name, _body) => {
api[_name] = _body;
};

// spv
if (((api.appConfig.general.main.dev || process.argv.indexOf('devmode') > -1) && api.appConfig.general.electrum.cache) ||
(!api.appConfig.general.main.dev && process.argv.indexOf('devmode') === -1)) {
api.loadLocalSPVCache();
}

if (api.appConfig.general.electrum &&
api.appConfig.general.electrum.customServers) {
api.loadElectrumServersList();
Expand Down
24 changes: 22 additions & 2 deletions routes/api/auth.js
@@ -1,6 +1,7 @@
const passwdStrength = require('passwd-strength');
const CryptoJS = require("crypto-js");
var blake2b = require('blake2b')
var blake2b = require('blake2b');
const { randomBytes } = require('crypto');

const decrypt = (data, key) => CryptoJS.AES.decrypt(data, key).toString(CryptoJS.enc.Utf8);
const encrypt = (data, key) => CryptoJS.AES.encrypt(data, key).toString()
Expand Down Expand Up @@ -31,6 +32,10 @@ module.exports = (api) => {

api.setPost = (url, handler, forceEncryption = false) => {
api.post(url, async (req, res, next) => {
if (api.appConfig.general.main.livelog) {
api.writeLog(`POST, url: ${url}, forceEncryption: ${forceEncryption}`, 'api.http.request')
}

const encrypted = req.body.encrypted || forceEncryption

try {
Expand Down Expand Up @@ -81,7 +86,7 @@ module.exports = (api) => {

api.setGet = (url, handler) => {
api.get(url, async (req, res, next) => {
try {
try {
if (
!api.checkToken(
req.query.validity_key,
Expand All @@ -90,6 +95,21 @@ module.exports = (api) => {
)
)
throw new Error("Incorrect API validity key");

if (api.appConfig.general.main.livelog) {
let req_id = randomBytes(8).toString('hex')

handler(req, {
send: (jsonString) => {
api.writeLog(
JSON.stringify(JSON.parse(jsonString), null, 2),
`api.http.response ${req_id}`
);
}
}, next)

api.writeLog(`GET, url: ${url}`, `api.http.request ${req_id}`)
}

handler(req, res, next)
} catch(e) {
Expand Down
21 changes: 21 additions & 0 deletions routes/api/binsUtils.js
Expand Up @@ -42,5 +42,26 @@ module.exports = (api) => {
});
}

api.isDaemonRunning = (daemonName) => {
return new Promise((resolve, reject) => {
let platform = os.platform();
let cmd = '';
switch (platform) {
case 'win32' : cmd = `tasklist`; break;
case 'darwin' : cmd = `ps -ax | grep ${daemonName}`; break;
case 'linux' : cmd = `ps -A`; break;
default: break;
}

exec(cmd, (err, stdout, stderr) => {
if (platform === 'darwin') {
resolve(stdout.toLowerCase().indexOf(`assets/bin/osx/${daemonName}`) > -1)
} else {
resolve(stdout.toLowerCase().indexOf(daemonName.toLowerCase()) > -1)
}
});
})
}

return api;
};

0 comments on commit 22018b1

Please sign in to comment.