BOLSHOI - comprehensive IOTA Wallet - Follow Up - Getting Balance from correct SEED and initial formatssteemCreated with Sketch.

in iota •  7 years ago 

Small report on the BOLSHOI

Getting and formatting the value from a SEED

Screenshot_20170708_160534.png

That is coming from a test wallet with 224 Miotas. Here's the caller and the parser for interested parties


app.service( 'tangle', function( $rootScope, seed ) {

  console.log( "Running tangle service" );
  console.log( "Testing Seed from tanble service: " + seed.value );

  this.balance = "0 i";

  this.iota = new IOTA({
    'provider' : 'http://service.iotasupport.com:14265'
    //'provider' : 'http://iota.bitfinex.com:80'
  });

  this.getNodeInfo = function() {
    this.iota.api.getNodeInfo( function( error, success ) {
      if( error ) {
        console.error( error );
      } else {
        console.log( success );
      }
    });
  };

  this.getNodeInfo();

  this.format = ( balance )=>{
    var formatted;

    var div = document.createElement( "div" );
    div.innerHTML = balance;
    formatted = $( div ).mask( "9'999'999'999'999'999", {reverse:true} )[0].innerText;

    console.log( formatted );
    return formatted;
  }

  this.getInputs = function() {
    $rootScope.$emit( 'tangleEvent', "gettingInputs" );
    console.log( "Trying to get input with seed: " + seed.value );
    this.iota.api.getInputs( seed.value, ( error, success )=>{
      if( error ) {
        console.error( error );
      } else {
        console.log( success );
        this.balance = "" + this.format( success.totalBalance ) + " i";
        $rootScope.$emit( 'tangleEvent', "balance" );
      }
    });
  };


  // this.getBalance = ()=>{
  //   return this.balance;
  // }


});


Cheers! Upvote to donate! thanks :)


EDUARDO CAPANEMA
@bitworkers

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!