rippled icon indicating copy to clipboard operation
rippled copied to clipboard

Request: filter by direction in account_objects

Open mDuo13 opened this issue 7 years ago • 2 comments

Many of the types of objects that you can look up with account_objects have a sending/outgoing side and a receiving/incoming side, but there's not currently any way to look up just one or the other. So, for example, looking up incoming escrows involves an extra step of filtering out all the outgoing escrows in the response.

I'd like to be able to request rippled do this filtering automatically. This potentially

I propose a new optional field in the account_objects request called direction. The value of direction, if provided, would be "in", "out", or "any". If provided, it would filter the returned objects based on whether those objects were "incoming" or "outgoing" from the perspective of the account from the request. The value "any" would be the same as not filtering, the current behavior. The default if the direction field is omitted would be the same as the current behavior, with no filtering.

In general, objects that show up if you do account_objects with "direction": "out" would be objects you created, whereas objects with "direction": "in" would be objects that others created.

The incoming/outgoing status of all objects would be defined as follows:

  • Escrow, PayChannel, and Check objects would be considered "outgoing" from the perspective of the account in their Account field, and "incoming" from the perspective of the account in their Destination field. Escrows to oneself would, therefore, be both incoming and outgoing.
  • Offer objects would always be considered "outgoing" from the perspective of the account in their Account field.
  • SignerList objects would always be considered "outgoing" from the perspective of their owner. A theoretical future implementation could show you accounts who've added your account's address to their signer list(s), but we'll forget about that for now since those signer lists won't be in your owner directory.
  • RippleState objects would be considered "outgoing" if the limit on this account's side is greater than 0. Would be considered "incoming" if the limit on the peer account's side is greater than 0. In this way, a bidirectional trust line would be both incoming and outgoing.

Note: This sort of filtering could be very inefficient, especially on trust lines. For example, looking up outgoing trust lines from a popular issuer's issuing address could mean going through many pages of the owner directory and reading thousands of objects while finding very few to no outgoing trust lines for the response. We should set a reasonable limit on the work that can be done on a non-admin connection. (Perhaps it still looks at the same number of pages / objects as the unfiltered response, and simply returns less data? So it may frequently return less than the limit on non-admin connections. Optionally, on an admin connection, you could have it go through more pages to try and actually fill the limit.)

mDuo13 avatar Mar 20 '18 21:03 mDuo13

Bonus: add similar direction filtering to account_channels and account_lines.

mDuo13 avatar Aug 06 '19 04:08 mDuo13

@mDuo13 Can you confirm please if this is still useful / relevant?

vlntb avatar Jun 13 '25 15:06 vlntb

This would still be helpful, I think, yes.

mDuo13 avatar Jul 01 '25 18:07 mDuo13