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

Decimal Precision error when signing TrustSet with maximum limit value #425

Open
nkramer44 opened this issue Aug 19, 2022 · 3 comments
Open
Assignees

Comments

@nkramer44
Copy link

nkramer44 commented Aug 19, 2022

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!

@dangell7
Copy link
Contributor

dangell7 commented Sep 27, 2022

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)

@intelliot
Copy link
Collaborator

@nkramer44 any thoughts on this? Should we close this issue?

@nkramer44
Copy link
Author

@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.

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

No branches or pull requests

6 participants