Jump to content
Sign in to follow this  
devnullprod

Question pertaining to high/low account sorting

Recommended Posts

Good day! Apologies if this question has already been asked but I wasn't able to find the answer anywhere in the documentation / support.

 

According to the documentation, Balances and TrustLines in the ledger are represented though 'RippleState' objects which record the two accounts associated together along with a balance:

https://developers.ripple.com/ripplestate.html

Quote

Since no account is privileged in the XRP Ledger, a RippleState object sorts their account addresses numerically, to ensure a canonical form. Whichever address is numerically lower is deemed the "low account" and the other is the "high account"

 

Looking at the example RippleState JSON provided, this doesn't seem to be as described as the "HighLimit" corresponds to "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn" and the "LowLimit" corresponds to "rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW".

 

This doesn't make sense as ascii / unicode table assigns 0x66 to "f" which is lower than the 0x73 assigned to "s".

 

Thinking about it, I next thought that perhaps accounts were sorted in accordance to the ripple alphabet:

Quote

rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz

 

Which would make sense in the above example but if we look at another one, this does not hold up. Here we see the "HighLimit" is "r9g5TLjM4P9ijgAAVVsf8KDPWSroeHjE4q" and the "LowLimit" is "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B" which wouldn't be correct in either the ascii or ripple-alphabet sorting schemes.

 

Could someone please elaborate exactly how addresses are numerically assigned such that they are ordered in the manner described above.

Thank you greatly.

Share this post


Link to post
Share on other sites

Ahhh it was so simple all along! The obvious was right infront of us, converting to an int via base58  & the ripple alphabet resulting in the correct sorting.

Thank you for the quick response! We're going to grab another cup of coffee!

coffee2.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...