Jitender
Jitender

Reputation: 330

Issue in sending Below 100 XRP to the server

I am sending XRP using this NodeJs program it's sending 100 or greater than 100 XRP to the server correctly but when I send below 100 XRP it displays only 10 XRP transaction complete. Is there anybody who could tell me what is the reason behind that and how I could resolve it.

var RippleAPI = require('ripple-lib').RippleAPI

var api = new RippleAPI({ server: 'wss://s.altnet.rippletest.net:51233' 
}) 

var myAddress = 'rhMhKToAwTyrSgeRXRUispp6hNGaR7Am5a'
var mySecret  = 'shFGQDTPdHSA9mKgATM4seuRoajF7'

api.on('error', function (errorCode, errorMessage) {
console.log(errorCode + ': ' + errorMessage)
})
 api.on('connected', function () {
console.log('connected')


console.log('getting account info for', myAddress)
api.getAccountInfo(myAddress).then(function(info){
console.log('getAccountInfo done, info: ', info)

var serverstate = api.getServerInfo().then(function (ss) {

  console.log('getServerState', ss)

  var _fee = (ss.validatedLedger.baseFeeXRP*1000*1000)+""

  api.getFee().then(function(e){
    console.log('Estimated fee= ', parseFloat(e)*1000*1000)
  })

  if(parseInt(_fee) > 12){
    _fee = 12
  }

  var transaction = {
      "TransactionType" : "Payment",
      "Account" : myAddress,
      "Fee" : _fee,
      "Destination" : "rLarfrfDe7fqtoVjk9HYS1aUENPekVEwEr",
      "DestinationTag" : 133,
      "Amount" : (1*100*1000)+ "99",
      "LastLedgerSequence" : ss.validatedLedger.ledgerVersion+4,
      "Sequence" : info.sequence
       //"Amount" : {
         //"currency" : "XRP",
         //"issuer" : "r4vEs94PiqBbPvDjqgZiomEdExeYStPt3r",
         //"value" : (1*1000*1000)+"50"
      // }
    }

   // transaction = {"tx_json" : transaction }

   console.log('Transaction: ', transaction)

   var txJSON = JSON.stringify(transaction)
   console.log(txJSON)

   var transactionSigned = api.sign(txJSON,mySecret)

   console.log('Signed Transaction: ', transactionSigned)
   // console.log(transactionSigned.signedTransaction)
   // transactionSigned.id (eg 884A6C2F0340EFAC231AAB20627C58CB9890EDA66E2FEA9B175BB61FE3CA2916)
   // = required to check details

   api.submit(transactionSigned.signedTransaction).then(function(data){
      console.log(data)

      console.log('Tentative Result: ', data.resultCode);
      console.log('Tentative Message: ', data.resultMessage);


      var checkTransactionStatus = setInterval(function(){
          console.log('Checking Transaction Resutls')

           api.getLedgerVersion().then(function(d){
            var ledgerVersion = parseInt(d)
            console.log('Ledger = @ version ', ledgerVersion)

            if(ledgerVersion > ss.validatedLedger.ledgerVersion && ledgerVersion <= ss.validatedLedger.ledgerVersion+4){
              console.log('... getting transaction ... ')

                 api.getTransaction(transactionSigned.id, {
                    minLedgerVersion: ss.validatedLedger.ledgerVersion,
                    maxLedgerVersion: ledgerVersion
                 }).then(function(d){

                    clearInterval(checkTransactionStatus)
                    console.log('<<<<<< getTransaction results: >>>>')
                    // console.dir(d, { depth: null })
                    console.dir(d.outcome, { depth: null })

                 }).catch(function(e){
                  console.log('Error getting Transaction: ', e)
                 })

            }
            if(ledgerVersion > ss.validatedLedger.ledgerVersion+4){
              console.log('>>>>>> EXPIRED <<<<<<<')
              clearInterval(checkTransactionStatus)
            }

           })

      }, 1000);

    }).catch(console.error);

  }).catch(console.error)
  }).catch(console.error)
})

api.on('disconnected', function (code) {  

console.log('disconnected, code: ', code)   
})

 api.connect()

 setTimeout(function(){
   api.disconnect()
 }, 100*1000)

Upvotes: 1

Views: 142

Answers (1)

Tomas Bisciak
Tomas Bisciak

Reputation: 2851

 "Amount" : (100*1000)+ "99",

XRP is represented as 1000000 drops. You are missing additional 0 . ? Your transaction is 9.9xrp

Upvotes: 1

Related Questions