sc/deposit.js
function getBalanceOfAllDepositContract(conn, roundIndex, cb){
    var conn = conn || db;
    if(!validationUtils.isPositiveInteger(roundIndex))
        return cb("param roundIndex is not a positive integer");
    round.getMaxMciByRoundIndex(conn, roundIndex, function(lastRoundMaxMci){
        conn.query("SELECT deposit_address FROM supernode", 
        function(rowsDepositAddress) {
            var arrDepositAddress = rowsDepositAddress.map(function(row){ return row.deposit_address; });
            var strDepositAddress = arrDepositAddress.map(db.escape).join(', ');
            conn.query("SELECT sum(amount) AS sumBanlance  \n\
                FROM outputs JOIN units USING(unit) \n\
                WHERE asset IS NULL AND sequence='good' AND is_stable=1 AND main_chain_index<=? \n\
                AND address IN("+strDepositAddress+")", 
            [lastRoundMaxMci], 
            function(rowsOutputs) {
                if (rowsOutputs.length === 0)
                    return cb(null, 0);
               
                cb(null, parseInt(rowsOutputs[0].sumBanlance));
            });
        });
    });
}
function getBalanceOfAllDepositContract(conn, roundIndex, cb){
    var conn = conn || db;
    if(!validationUtils.isPositiveInteger(roundIndex))
        return cb("param roundIndex is not a positive integer");
    round.getMaxMciByRoundIndex(conn, roundIndex, function(lastRoundMaxMci){
        conn.query("SELECT deposit_address FROM supernode", 
        function(rowsDepositAddress) {
            var arrDepositAddress = rowsDepositAddress.map(function(row){ return row.deposit_address; });
            var strDepositAddress = arrDepositAddress.map(db.escape).join(', ');
            conn.query("SELECT sum(amount) AS sumBanlance  \n\
                FROM outputs JOIN units USING(unit) \n\
                WHERE asset IS NULL AND sequence='good' AND is_stable=1 AND main_chain_index<=? \n\
                AND address IN("+strDepositAddress+")", 
            [lastRoundMaxMci], 
            function(rowsOutputs) {
                if (rowsOutputs.length === 0)
                    return cb(null, 0);
               
                cb(null, parseInt(rowsOutputs[0].sumBanlance));
            });
        });
    });
}
function getBalanceOfAllDepositContract ( conn , roundIndex , cb ) { var conn = conn || db ; if ( ! validationUtils . isPositiveInteger ( roundIndex ) ) return cb ( "param roundIndex is not a positive integer" ) ; round . getMaxMciByRoundIndex ( conn , roundIndex , function ( lastRoundMaxMci ) { conn . query ( "SELECT deposit_address FROM supernode" , function ( rowsDepositAddress ) { var arrDepositAddress = rowsDepositAddress . map ( function ( row ) { return row . deposit_address ; } ) ; var strDepositAddress = arrDepositAddress . map ( db . escape ) . join ( ', ' ) ; conn . query ( "SELECT sum(amount) AS sumBanlance  \n\
                FROM outputs JOIN units USING(unit) \n\
                WHERE asset IS NULL AND sequence='good' AND is_stable=1 AND main_chain_index<=? \n\
                AND address IN(" + strDepositAddress + ")" , [ lastRoundMaxMci ] , function ( rowsOutputs ) { if ( rowsOutputs . length === 0 ) return cb ( null , 0 ) ; cb ( null , parseInt ( rowsOutputs [ 0 ] . sumBanlance ) ) ; } ) ; } ) ; } ) ; }
Get all deposit address stable balance, Before the roundIndex

@param	{obj}	    conn      if conn is null, use db query, otherwise use conn.
@param   {String}    roundIndex
@param   {function}	cb( err, balance ) callback function

@return {"base":{"stable":{Integer},"pending":{Integer}}} balance
Get all deposit address stable balance Before the roundIndex