Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transaction.outputs.amount as string #1286

Merged
merged 15 commits into from Apr 24, 2017
Merged

transaction.outputs.amount as string #1286

merged 15 commits into from Apr 24, 2017

Conversation

ssadler
Copy link
Contributor

@ssadler ssadler commented Mar 15, 2017

Fixes #1012

This is done so that transactions with large amounts can be safely constructed in Javascript.

  • transaction.outputs.amount is now a string
  • Capped at 9000000000000000000 (9 with 18 zeros) as per @ttmc's suggestion

To be merged with #1225

@ssadler ssadler requested review from ttmc and r-marques March 15, 2017 09:20
@codecov-io
Copy link

codecov-io commented Mar 15, 2017

Codecov Report

Merging #1286 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1286      +/-   ##
==========================================
- Coverage   98.37%   98.34%   -0.04%     
==========================================
  Files          56       56              
  Lines        2588     2595       +7     
==========================================
+ Hits         2546     2552       +6     
- Misses         42       43       +1

@@ -229,6 +229,8 @@ def __init__(self, fulfillment, public_keys=None, amount=1):
raise TypeError('`amount` must be an int')
if amount < 1:
raise AmountError('`amount` must be greater than 0')
if amount > 9 * 10 ** 18:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a const somewhere so that we don't need to recalculate this value everytime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

validate_raises(tx)
del tx['asset']['data']
tx['asset']['id'] = 'b' * 63
validate_raises(tx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the asset have no data field?
Is this raising because asset has no data field or because it has a malformed hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transfers don't have asset.data.

if amount > 9 * 10 ** 18:
raise AmountError('`amount` must be <= 9000000000000000000')
if amount > self.MAX_AMOUNT:
raise AmountError('`amount` must be <= %s' % self.MAX_AMOUNT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it matters much but shouldn't it be %d

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be, but I've never done it that way. Always worked with %s.

@ssadler ssadler changed the title transaction.outputs.amount as string [Delay] transaction.outputs.amount as string Mar 15, 2017
@ssadler ssadler changed the title [Delay] transaction.outputs.amount as string transaction.outputs.amount as string Apr 24, 2017
@ssadler ssadler merged commit 4b057ad into master Apr 24, 2017
@ssadler ssadler deleted the tx-amount-string branch April 24, 2017 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants