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
Conversation
Codecov Report
@@ 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 |
bigchaindb/common/transaction.py
Outdated
@@ -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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
bigchaindb/common/transaction.py
Outdated
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Fixes #1012
This is done so that transactions with large amounts can be safely constructed in Javascript.
To be merged with #1225