resources/assets/js/custom.js
/**
	 * Asks the server for the last blocks and balance for each account
	 */
Asks the server for the last blocks and balance for each account
Asks the server for the last blocks and balance for each account
function checkChains(callback)
	{
		var accs = wallet.getAccounts();
		console.log(accs);
		var r = [];
		for (let i in accs)
			if(accs[i].lastHash === false)
				r.push(accs[i].account);
		$.post('/wallet/chains', 'accs='+JSON.stringify(r), function(data) {
			if(data.status == 'success')
			{
				for(let acc in data.accounts)
				{
					let blocks = data.accounts[acc].blocks;
					blocks.reverse();
					for(let i in blocks)
					{
						var blk = new Block();
						blk.buildFromJSON(blocks[i].contents);
						blk.setAccount(acc);
						blk.setAmount(blocks[i].amount)
						blk.setImmutable(true);
						wallet.importBlock(blk, acc, false);
					}
					wallet.useAccount(acc);
					wallet.setAccountBalancePublic(data.accounts[acc].balance, acc);
				}
			}	
			else
			{
				console.error(data.msg);
				alertError(data.msg);
			}
			callback();
		});
	}
function checkChains ( callback ) { var accs = wallet . getAccounts ( ) ; console . log ( accs ) ; var r = [ ] ; for ( let i in accs ) if ( accs [ i ] . lastHash === false ) r . push ( accs [ i ] . account ) ; $ . post ( '/wallet/chains' , 'accs=' + JSON . stringify ( r ) , function ( data ) { if ( data . status == 'success' ) { for ( let acc in data . accounts ) { let blocks = data . accounts [ acc ] . blocks ; blocks . reverse ( ) ; for ( let i in blocks ) { var blk = new Block ( ) ; blk . buildFromJSON ( blocks [ i ] . contents ) ; blk . setAccount ( acc ) ; blk . setAmount ( blocks [ i ] . amount ) blk . setImmutable ( true ) ; wallet . importBlock ( blk , acc , false ) ; } wallet . useAccount ( acc ) ; wallet . setAccountBalancePublic ( data . accounts [ acc ] . balance , acc ) ; } } else { console . error ( data . msg ) ; alertError ( data . msg ) ; } callback ( ) ; } ) ; }
Asks the server for the last blocks and balance for each account
Asks the server for the last blocks and balance for each account