sublimator / ripple-lib-java

Java version of ripple-lib (work in progress)
ISC License
7 stars 7 forks source link

Destination Tag max int32 value limitation #21

Open argz7 opened 6 years ago

argz7 commented 6 years ago

In the SignTransaction example, I tried adding a destination tag object, and it works pretty well. But unfortunately, the destination tag is limited to the max int32 value. Is there anyway to increase the limit? Because it seems that some exchanges have a more longer destination tag than others.

Below is my sample code

    Payment payment = new Payment();

    // Put `as` AccountID field Account, `Object` o
    payment.as(AccountID.Account, account);
    payment.as(AccountID.Destination, destination);
    payment.as(Amount.Amount, amount);
    payment.as(UInt32.Sequence, sequence);
    payment.as(Amount.Fee, "10000");
    payment.as(UInt32.DestinationTag, destinationTag);
sublimator commented 6 years ago

Will look at these properly on weekend ...

Note u can use a Long for uint32 ...

100L

argz7 commented 6 years ago

Thanks!

Also I did some tests.

I still get an issue if I use Long, java.lang.IllegalArgumentException: standard length exceeded for value

If I use integer, the max length I can input without getting an error is (2,147,483,648)

while if I use Long, the max between (4,000,000,000 - 5,000,000,000), so not much difference from both int and long, the destination tag is still limited to 10 digits.

sublimator commented 6 years ago

Well it is uint32 .... if gateways use more than 32 bits ... there is a problem

argz7 commented 5 years ago

Sorry for bugging you right after New year, but I just want to follow up if it's possible to fix this issue.

sublimator commented 5 years ago

huh? I don't actually understand the issue

use a Long literal if your number greater than max of a signed integer

sublimator commented 5 years ago

Note the field is binary serialized as 32 bits maximum ... it can't be exceeded ...

Can u give some examples of the destination tags you want to use? Which gateway?

argz777 commented 3 years ago

Hello! Sorry I've been busy for the longest time. Well a few exchanges like Bitfinex has destination tags which are around 10 digits or more, thus it exceeds the 32 bit maximum limit. Given that this is the case, I'm not sure how I can change the this section of the code below.

`Payment payment = new Payment();

    // Put `as` AccountID field Account, `Object` o
    payment.as(AccountID.Account, account);
    payment.as(AccountID.Destination, destination);
    payment.as(Amount.Amount, amount);
    payment.as(UInt32.Sequence, sequence);
    payment.as(Amount.Fee, "10000");
    payment.as(UInt32.DestinationTag, destinationTag);`
sublimator commented 3 years ago

hrmmmm, I am not sure, but ALL transactions must at some point be serialized into the canonical format, and the destination tag must fit into a 32 bit big endian (IIRC) unsigned integer.

Can you give me an example of a dest tag that doesn't fit ?

If the gateway uses destination tags, of course it's ill advised to send one without

argz777 commented 3 years ago

Hello, that is an interesting insight. Does it mean that all platforms such as iOS, web apps have the same limit of the destination tag being 32 bit big endian since all transactions are serialized the same way?

a few test case scenarios I've tested was using the following destination tags.

  1. 4278602064 -> result passed
  2. 4290000000 -> result passed
  3. 4300000000 -> result failed
  4. 7894561231 -> result failed

I'm not sure if there are destination tags greater than 4290000000

sublimator commented 3 years ago

2 ** 32 - 1 4294967295

largest uint32

sublimator commented 3 years ago

all transactions are serialized the same way?

At some point, yes

argz777 commented 3 years ago

Oh I guess that makes sense, given if they are all serialized the same way, maybe all exchanges will have the same largest limit uint32. Thank you for all the help and information!

sublimator commented 3 years ago

You're welcome