Browse Source

fix for pool wallet and possibly help for XT

tags/v3.3.0
jojapoppa 9 months ago
parent
commit
3fde28d00e
14 changed files with 8214 additions and 77 deletions
  1. +23
    -0
      .eslintrc.json
  2. +1
    -0
      .gitignore
  3. +6
    -0
      main.js
  4. +8085
    -28
      package-lock.json
  5. +11
    -3
      package.json
  6. +1
    -2
      src/html/about.html
  7. +3
    -0
      src/js/extras/cjdnsadmin.js
  8. +2
    -0
      src/js/ws_api.js
  9. +9
    -3
      src/js/ws_manager.js
  10. +9
    -8
      src/js/ws_session.js
  11. +11
    -0
      src/js/ws_syncworker.js
  12. +1
    -0
      src/js/ws_utils.js
  13. +35
    -24
      src/js/wsui_main.js
  14. +17
    -9
      src/js/wsui_updater.js

+ 23
- 0
.eslintrc.json View File

@@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018
},
"plugins": [
"react"
],
"rules": {
}
}

+ 1
- 0
.gitignore View File

@@ -5,3 +5,4 @@
/dist
/node_modules
/bower_components
/bin

+ 6
- 0
main.js View File

@@ -14,6 +14,8 @@ const ip2int = require('ip2int');
const associativeArray = require('associative-array');
const alerts = require('alert');

const Buffer = require('buffer/').Buffer;

const minMemory = 4; // GB
const minStorage = 20; // GB

@@ -56,8 +58,12 @@ const forge = require('node-forge');
const { autoUpdater } = require("electron-updater");
const { setIntervalAsync } = require('set-interval-async/fixed');

const process = require('process');
process.env.UV_THREADPOOL_SIZE = 128;

//const filedirname = require('filedirname').default;
//const [__filename, __dirname] = filedirname();

const IS_DEV = (process.argv[1] === 'dev' || process.argv[2] === 'dev');
const IS_DEBUG = IS_DEV || process.argv[1] === 'debug' || process.argv[2] === 'debug';
const LOG_LEVEL = IS_DEBUG ? 'debug' : 'warn';


+ 8085
- 28
package-lock.json
File diff suppressed because it is too large
View File


+ 11
- 3
package.json View File

@@ -2,13 +2,13 @@
"name": "FedoraGoldWallet",
"productName": "FedoraGoldWallet",
"description": "FedoraGold (FED) GUI Wallet",
"version": "v3.2.5",
"version": "v3.2.7",
"homepage": "https://github.com/jojapoppa/fedoragold-wallet-electron",
"repository": "https://github.com/jojapoppa/fedoragold-wallet-electron",
"main": "main.js",
"nodejs": true,
"scripts": {
"start": "electron . --max-old-space-size=6076 ",
"start": "electron . --max-old-space-size=8096 ",
"debug": "electron . debug",
"dev": "electron . dev",
"dist-win": "./node_modules/.bin/electron-builder --x64 --win",
@@ -27,22 +27,28 @@
"electron": "^9.4.4",
"electron-builder": "^22.10.5",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react": "^7.25.1",
"jshint": "^2.12.0"
},
"dependencies": {
"@trodi/electron-splashscreen": "^0.3.4",
"acebase": "^1.8.4",
"acebase-client": "^1.5.1",
"acebase-server": "^1.4.0",
"alert": "^5.0.10",
"arr-union": "^3.1.0",
"associative-array": "^1.0.2",
"axios": "^0.21.1",
"blake2s": "^1.1.0",
"bottleneck": "^2.19.5",
"buffer": "^6.0.3",
"cross-spawn": "^7.0.3",
"csv-writer": "^1.6.0",
"diskusage": "^1.1.3",
"electron-log": "^2.2.17",
"electron-store": "^2.0.0",
"electron-updater": "^4.3.9",
"filedirname": "^2.7.0",
"forge": "^2.3.0",
"fs-extra": "^9.1.0",
"ip2int": "^1.0.1",
@@ -50,6 +56,7 @@
"keypair": "^1.0.3",
"navigator": "^1.0.1",
"node-forge": "^0.10.0",
"node-sessionstorage": "^1.0.0",
"nthen": "^0.1.10",
"pidusage-tree": "^2.0.5",
"ps-node": "^0.1.6",
@@ -62,6 +69,7 @@
"source-map-support": "^0.5.19",
"ssh2": "^0.8.9",
"system-sleep": "^1.3.7",
"timers": "^0.1.1",
"tree-kill": "^1.2.2",
"ts-socks": "^0.9.3",
"typescript": "^4.3.2",


+ 1
- 2
src/html/about.html View File

@@ -36,8 +36,7 @@
Backlog for FED: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex="3">https://github.com/jojapoppa/fedoragold-wallet-electron/issues</span><br/>
Primary Mining Pool: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex="4">https://fed.cryptonote.club/</span><br/>
Markets: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex= "7">https://explorer.fedoragold.com/#markets</span><br/>
Wallet Sourcecode: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex="8">https://github.com/jojapoppa/fedoragold-wallet-electron</span><br/>
Backend Sourcecode: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex="9">https://github.com/jojapoppa/fedoragold</span><br/>
Sourcecode: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex="8">https://git.fedoragold.com.com/jojapoppa</span><br/>
Block Explorer: <span class="text-center" style="user-select:all;-webkit-user-select:all" tabindex="10">http://explorer.fedoragold.com</span><br/>
</center>
</p>


+ 3
- 0
src/js/extras/cjdnsadmin.js View File

@@ -21,6 +21,9 @@ var Fs = require('fs');
var nThen = require('nthen');
var Semaphore = require('./Semaphore.js');

const Buffer = require('buffer/').Buffer;
const process = require('process');

var TIMEOUT_MILLISECONDS = 10000;

var sendmsg = function (sock, addr, port, msg, txid, callback) {


+ 2
- 0
src/js/ws_api.js View File

@@ -1,5 +1,7 @@
"use strict";

const Buffer = require('buffer/').Buffer;

class WalletShellApi {

constructor(args) {


+ 9
- 3
src/js/ws_manager.js View File

@@ -16,6 +16,11 @@ const wsutil = require('./ws_utils');
const config = require('./ws_config');
const remote = require('electron').remote;
const platform = require('os').platform();
const process = require('process');
const setImmediate = require('timers/').setImmediate;

//const filedirname = require('filedirname').default;
//const [__filename, __dirname] = filedirname();

//const idleTimer = require('idle-timer');
//let FUSION_IN_PROGRESS = false;
@@ -781,7 +786,7 @@ function checkWalletdTimer(inst) {

if (procID == 0) {
//log.warn(procStr);
//log.warn("walletd process no longer detected: runWalletdProc()...");
//log.warn("walletd process no longer detected: runWalletdProc()... with aargu length="+aargu.length);
if ((aargu.length > 0) && !global.terminateServiceMode) {

try {
@@ -839,8 +844,9 @@ WalletShellManager.prototype.terminateService = function(force) {
}
}
}
global.runBin = "";
aargu = "";
//global.runBin = "";
global.serviceProcess = null;
servicePid = null;
};


+ 9
- 8
src/js/ws_session.js View File

@@ -3,6 +3,7 @@ const path = require('path');
const remote = require('electron').remote;
const Store = require('electron-store');
const settings = new Store({name: 'Settings'});
const node_sessionStorage = require('node-sessionstorage');

const DEFAULT_TITLE = 'FedoraGold (FED) Wallet';
const SESSION_KEY = 'fedwlshell';
@@ -50,22 +51,22 @@ var WalletShellSession = function(){
};

// initialize
if(!sessionStorage.getItem(this.sessKey)){
sessionStorage.setItem(this.sessKey, JSON.stringify(this.sessDefault));
if(!node_sessionStorage.getItem(this.sessKey)){
node_sessionStorage.setItem(this.sessKey, JSON.stringify(this.sessDefault));
}
};

WalletShellSession.prototype.get = function(key){
key = key || false;
if(!key){
return JSON.parse(sessionStorage.getItem(this.sessKey)) || this.sessDefault;
return JSON.parse(node_sessionStorage.getItem(this.sessKey)) || this.sessDefault;
}
if(!Object.prototype.hasOwnProperty.call(this.sessDefault, key)){
throw new Error(`Invalid session key: ${key}`);
}

return JSON.parse(sessionStorage.getItem(this.sessKey))[key];
return JSON.parse(node_sessionStorage.getItem(this.sessKey))[key];
};

WalletShellSession.prototype.getDefault = function(key){
@@ -82,7 +83,7 @@ WalletShellSession.prototype.set = function(key, val){

let sessData = this.get(); // all current data obj
sessData[key] = val; // update value
return sessionStorage.setItem(this.sessKey, JSON.stringify(sessData));
return node_sessionStorage.setItem(this.sessKey, JSON.stringify(sessData));
};

WalletShellSession.prototype.reset = function(key){
@@ -92,13 +93,13 @@ WalletShellSession.prototype.reset = function(key){
}
let sessData = this.get(); // all current data obj
sessData[key] = this.sessDefault[key]; // set to default value
return sessionStorage.setItem(this.sessKey, JSON.stringify(sessData[key]));
return node_sessionStorage.setItem(this.sessKey, JSON.stringify(sessData[key]));
}
return sessionStorage.setItem(this.sessKey, JSON.stringify(this.sessDefault));
return node_sessionStorage.setItem(this.sessKey, JSON.stringify(this.sessDefault));
};

WalletShellSession.prototype.destroy = function(){
return sessionStorage.removeItem(this.sessKey);
return node_sessionStorage.removeItem(this.sessKey);
};

module.exports = WalletShellSession;

+ 11
- 0
src/js/ws_syncworker.js View File

@@ -8,6 +8,7 @@ const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const killer = require('tree-kill');
const platform = require('os').platform();
const process = require('process');

let DEBUG=false;
//log.transports.file.maxSize = 5 * 1024 * 1024;
@@ -402,6 +403,7 @@ function updateTransactionsList(startIndexWithMargin, requestNumBlocks) {
return true;
}

var alreadysorting = false;
function checkTransactionsUpdate(){
if(STATE_SAVING || !STATE_CONNECTED || wsapi === null || STATE_PAUSED || !bSynchedMode ) return false;

@@ -447,6 +449,15 @@ function checkTransactionsUpdate(){
// top block, and then backtrack with the optimal overlap
if (requestNumBlocks > ((2*blockMargin)+1)) {
startIndexWithMargin += searchCount;

// a convenient spot to trigger a sort on the transaction list
if (!alreadysorting) {
alreadysorting = true;
setTimeout(function() {
process.send({type: 'sortTransactions', data: ''});
alreadysorting = false;
}, 15000);
}
}

// this stops it from blowing past the top block at the end


+ 1
- 0
src/js/ws_utils.js View File

@@ -6,6 +6,7 @@ const {nativeImage} = require('electron');
const log = require('electron-log');
const qr = require('qr-image');
const config = require('./ws_config');
const Buffer = require('buffer/').Buffer;

const ADDRESS_REGEX_STR = `^${config.addressPrefix}(?=[aA-zZ0-9]*$)(?:.{${config.addressLength-config.addressPrefix.length}}|.{${config.integratedAddressLength-config.addressPrefix.length}})$`;
const ADDRESS_REGEX = new RegExp(ADDRESS_REGEX_STR);


+ 35
- 24
src/js/wsui_main.js View File

@@ -11,6 +11,9 @@ const fs = require('fs');
const log = require('electron-log');
const randomBytes = require('randombytes');

const { setIntervalAsync } = require('set-interval-async/dynamic');
const { clearIntervalAsync } = require('set-interval-async')

const {dialog, clipboard, remote, ipcRenderer, shell} = require('electron');
const Store = require('electron-store');
const childproc = require('child_process');
@@ -1569,15 +1572,17 @@ function handleWalletOpen(){

formMessageSet('load','warning', "Starting wallet service...<br><progress></progress>");
setTimeout(() => {
formMessageSet('load','warning', "Opening wallet, please be patient...<br><progress></progress>");

//log.warn("calling startService...");
// this line effectively "debounces" the Open button...
if (!WALLET_OPEN_IN_PROGRESS) return;

formMessageSet('load','warning', "Opening wallet, please be patient...<br><progress></progress>");
log.warn("calling startService from wsui_main...");
wsmanager.startService(walletFile, walletPass, onError,
onSuccess, onDelay, daemonsynchronizedok);
}, 800, walletFile, walletPass, onError, onSuccess, onDelay, daemonsynchronizedok);
}).catch((err) => {
console.log(err);
log.warn("failed to start service");
formMessageSet('load','error', "Unable to start service");
WALLET_OPEN_IN_PROGRESS = false;
setOpenButtonsState(false);
@@ -2385,17 +2390,14 @@ function handleTransactions(){
setTxFiller(true);
}

var alreadySorting=false;
function runSort(sorder) {
if (alreadySorting) return;

alreadySorting = true;
TXLIST_OBJ.sort('timestamp', {order: sorder});
alreadySorting = false;
}

var misses = 0;
var transactionStack = [];
let uiTimer = setIntervalAsync(() => {
let txx = transactionStack.shift(); // shift take it from the front of the queue
if (txx !== undefined)
TXLIST_OBJ.add(txx);
}, 50, transactionStack);
function listTransactions(){

let txs = wsession.get('txNew');
let txLen = wsession.get('txLen');
//log.warn('listTransactions Len:', txLen);
@@ -2409,27 +2411,20 @@ function handleTransactions(){
if (TXLIST_OBJ === null) {
txListOpts.page = txsPerPage;
txListOpts.pagination = [{
order: 'desc',
valueName: 'timestamp',
innerWindow: 2,
outerWindow: 1
}];

TXLIST_OBJ = new List('transaction-lists', txListOpts, txs);
TXLIST_OBJ = new List('transaction-lists', txListOpts, []); //, txs);

resetTxSortMark();
txButtonSortDate.classList.add('desc');
txButtonSortDate.dataset.dir = 'desc';
}

// This guarantees that we don't have any duplicates in the transaction list...
for (var i=0; i<txs.length; i++) {
//log.warn("eval trx: "+txs[i].amount.toString());
if (TXLIST_OBJ.get('rawHash', txs[i].rawHash).length > 0) {
TXLIST_OBJ.remove('rawHash', txs[i].rawHash);
}
}

TXLIST_OBJ.add(txs);
setTimeout(()=>{ runSort('desc'); }, 500);
transactionStack.push(txs);
}

function exportAsCsv(mode){
@@ -2563,6 +2558,22 @@ function handleTransactions(){
listTransactions();
txInputUpdated.value = 0;
});
txInputUpdated.addEventListener('sortnow', (event) => {

if (TXLIST_OBJ != null) {
//TXLIST_OBJ.on('sortComplete', { settings.set('alreadysorting', false); log.warn("done sorting"); });
//log.warn("run the default sort now...");
resetTxSortMark();
TXLIST_OBJ.sort('timestamp', {order: 'desc'});
//sortFunction: function (a, b) {
// return a.timestamp > b.timestamp ? 1 :
// a.timestamp < b.timestamp ? -1 : 0;
//}
//});
}

txInputUpdated.value = 0;
});
// listen to tx notify
txInputNotify.addEventListener('change', (event)=>{
let notify = parseInt(event.target.value, 10) === 1;


+ 17
- 9
src/js/wsui_updater.js View File

@@ -9,6 +9,9 @@ const wsutil = require('./ws_utils');
const WalletShellSession = require('./ws_session');
const config = require('./ws_config');

//remove from node module folder...
//const union = require('arr-union');

const brwin = remote.getCurrentWindow();
const settings = new Store({name: 'Settings'});
const wsession = new WalletShellSession();
@@ -300,7 +303,6 @@ var txlistExisting = [];
function updateTransactions(blockItems){

//log.warn("updateTransactions result items received: "+blockItems.length);

if(!txlistExisting.length && !blockItems.length){
document.getElementById('transaction-export').classList.remove('hidden');
document.getElementById('transaction-export').classList.add('hidden');
@@ -347,16 +349,17 @@ function updateTransactions(blockItems){
wsession.set('txLastHash',newLastHash);
wsession.set('txLastTimestamp', newLastTimestamp);

// Checks if each element is unique
let existing = txlistExisting.map(el=>el.rawHash);
let txList = txListNew.filter((e)=>{return !existing.includes(e.rawHash);});

// Records the new records inside the list of existing transactions
txlistExisting = txList.concat(txlistExisting);
// // Checks if each element is unique
// let existing = txlistExisting.map(el=>el.rawHash);
// let txList = txListNew.filter((e)=>{return !existing.includes(e.rawHash);});
//
// // Records the new records inside the list of existing transactions
// //txlistExisting = txList.concat(txlistExisting);
// txlistExisting = union(txList, txlistExisting); // concat runs out of memory...

//waitTransactionListUpdate();
wsession.set('txNew', txList);
wsession.set('txLen', txlistExisting.length);
wsession.set('txNew', txListNew); //txList);
wsession.set('txLen', txListNew.length); //txlistExisting.length);
triggerTxRefresh();

// Desktop notification logic begins here...
@@ -498,6 +501,11 @@ function updateUiState(msg){
case 'walletReset':
txlistExisting = [];
break;
case 'sortTransactions':
var txUpdateInputFlag = document.getElementById('transaction-updated');
txUpdateInputFlag.value = 1;
txUpdateInputFlag.dispatchEvent(new Event('sortnow'));
break;
case 'blockUpdated':
//log.warn("updateSyncProgress...");
updateSyncProgress(msg.data);


Loading…
Cancel
Save