Decimal Precision error when signing TrustSet with maximum limit value
I'm trying to sign the following transaction using the xrpl.transaction.safe_sign_transaction method:
TrustSet(
account="rLcJhU1Ww2yLK13CMbyKwS1uGxYp6tC348",
sequence=9858020,
fee="10",
flags=TrustSetFlag.TF_SET_NO_RIPPLE,
last_ledger_sequence=9858346,
signing_pub_key="ED8B224F3FBACBB96CBA3C076D36BF0AEA441B15C99507EC216892475893825500",
limit_amount=IssuedCurrencyAmount(
issuer="rhCvFsN7oAvcbrfTjUJYZq3iGHDtq8h99u",
currency="us1",
value="999999999999999900000000000000000000000000000000000000000000000000000000000000000000000000000000")
)
That limit_amount.value value is the documented maximum Trustline limit amount (9999999999999999e80) so should be serializable and signable. I'm able to serialize, sign and successfully submit similar TrustSet transactions in xrpl4j, so I'm sure the value is valid. However, when I call safe_sign_transaction, I get the following error:
raise XRPLBinaryCodecException(
xrpl.core.binarycodec.exceptions.XRPLBinaryCodecException: Error processing LimitAmount: Decimal precision out of range for issued currency value.
My guess is that Decimal isn't a large enough data type to hold that value, but I'm not familiar enough with python to know what the correct data type is. See this method in amount.py:
def verify_iou_value(issued_currency_value: str) -> None:
"""
Validates the format of an issued currency amount value.
Raises if value is invalid.
Args:
issued_currency_value: A string representing the "value"
field of an issued currency amount.
Returns:
None, but raises if issued_currency_value is not valid.
Raises:
XRPLBinaryCodecException: If issued_currency_value is invalid.
"""
decimal_value = Decimal(issued_currency_value)
if decimal_value.is_zero():
return
exponent = decimal_value.as_tuple().exponent
if (
(_calculate_precision(issued_currency_value) > MAX_IOU_PRECISION)
or (exponent > MAX_IOU_EXPONENT)
or (exponent < MIN_IOU_EXPONENT)
):
raise XRPLBinaryCodecException(
"Decimal precision out of range for issued currency value."
)
_verify_no_decimal(decimal_value)
Thank you!
You need to pass in the scientific notation. You cannot pass in variables at that length.
The error received is Decimal precision out of range for issued currency value. and you can see that is the error response from:
(_calculate_precision(issued_currency_value) > MAX_IOU_PRECISION)
or (exponent > MAX_IOU_EXPONENT)
or (exponent < MIN_IOU_EXPONENT)
@nkramer44 any thoughts on this? Should we close this issue?
@intelliot @JST5000 Sorry I never followed up on this. I believe this is still an issue. Even if you pass in an IssuedCurrencyAmount with a value in scientific notation (ie 9999999999999999e80), the above error is thrown. I haven't debugged this myself, but my guess is _calculate_precision is returning an incorrect value, or the Decimal class isn't parsing the value correctly/is normalizing it somehow.