astroband / ruby-stellar-base

The stellar-base library is the lowest-level stellar helper library. It consists of classes to read, write, hash, and sign the xdr structures that are used in stellar-core
Apache License 2.0
21 stars 19 forks source link

Amount input for native accepts integer but not floating point numbers #15

Closed sacarlson closed 9 years ago

sacarlson commented 9 years ago

It seems I can do a native payment using an integer of 1 but if I use 1.234 the transaction fails. The work around I found is enter the amount when floating point is needed in string format "1.234" then it works. this is using ruby-stellar-base version 0.4.0.

nullstyle commented 9 years ago

Could you please include some further explanatory info?

For example, in what way does the transaction fail? Are you getting an error raised? If so, please paste the stack trace. If it's failing in stellar-core, it's probably a different cause then if an error raised.

I'll try to repro now, but including more direct information about how the system is responding to your script in future reports really makes things quicker to fix and would be much appreciated.

nullstyle commented 9 years ago

The following snippet does not repro the error:

require 'stellar-base'
master      = Stellar::KeyPair.master
destination = Stellar::KeyPair.random

tx = Stellar::Transaction.payment({
  account:     master,
  destination: destination,
  sequence:    1,
  amount:      [:native, 1.234] 
})

b64    = tx.to_envelope(master).to_xdr(:base64)
puts b64

In addition, inspecting the resulting transaction, it does properly set the amount to 12340000 from the input of 1.234.

sacarlson commented 9 years ago

yes sorry even after pulling my older version of my code I can no longer duplicate this problem. my best guess is I still was running ruby-stellar-base 0.3.0. In the future I'll be sure to capture more details. I think you can close this