lib/database.js
/*
 * update spentHeight from remove tx vin
 */
update spentHeight from remove tx vin
update spentHeight from remove tx vin
function tx_update_spent_coin(txid, cb) {
  lib.get_rawtransaction(txid, function(tx){
    if (tx != 'There was an error. Check your console.') {
      console.log('coins in tx: %d', tx.vin.length);
        lib.syncLoop(tx.vin.length, function(loopIn) {
          var j = loopIn.iteration();
          if(tx.vin[j].coinbase){
            console.log("coinbase tx");
            loopIn.next();
          } else {
            var coinid=tx.vin[j].txid + '-' + tx.vin[j].vout;
            Coin.updateOne({coinid:coinid}, {
              spendHeight: 0
            }, function() {
              console.log("UNDO SPEND: " + coinid);
              loopIn.next();
            });
          }
        }, function(){
          return cb();
        });
    } else {
      return cb('tx not found: ' + txid);
    }
  });
}
function tx_update_spent_coin ( txid , cb ) { lib . get_rawtransaction ( txid , function ( tx ) { if ( tx != 'There was an error. Check your console.' ) { console . log ( 'coins in tx: %d' , tx . vin . length ) ; lib . syncLoop ( tx . vin . length , function ( loopIn ) { var j = loopIn . iteration ( ) ; if ( tx . vin [ j ] . coinbase ) { console . log ( "coinbase tx" ) ; loopIn . next ( ) ; } else { var coinid = tx . vin [ j ] . txid + '-' + tx . vin [ j ] . vout ; Coin . updateOne ( { coinid : coinid } , { spendHeight : 0 } , function ( ) { console . log ( "UNDO SPEND: " + coinid ) ; loopIn . next ( ) ; } ) ; } } , function ( ) { return cb ( ) ; } ) ; } else { return cb ( 'tx not found: ' + txid ) ; } } ) ; }
update spentHeight from remove tx vin
update spentHeight from remove tx vin
//end loop vin, vout