Questions about Account Balance endpoint

We are currently working on the /account/balance endpoint for an UTXO and we have to questions:

  1. Let’s suppose an account has several UTXOs, when building the Amount object, do we need to return all of them or just a single value with the total amount? The doco mentions something but regarding supporting multiple currencies A single account may have a balance in multiple currencies.

  2. When building a transaction you will need to specify the txId and index for each input … we aren’t returning such values neither here nor when returning transaction operations (as we understood the index is not related to that) … where is that info supposed to be returned?


1 Like

:wave: @alan.verbner

  1. You should return the sum of all UTXOs “owned” by the address. We recommend returning all UTXOs in the AccountBalanceResponse.Metadata so that clients can construct transactions without needing to index the chain. In the future, we will likely make this a “first-class” field in the AccountBalanceResponse. Would love to see you guys create an issue around this!
  1. We are about to release our Automated Construction API tester which can infer the txId and index based on where the output Operation is present. For it to work correctly, the OperationIdentifier.NetworkIndex should be populated with the index needed to construct a transaction with the output (you should still populate OperationIdentifier.Index). This will be clearer once the testing suite is released!

from this doc

I found

If a blockchain is UTXO-based, all unspent Coins owned by an account_identifier should be returned alongside the balance. It is highly recommended to populate this field so that users of the Rosetta API implementation don’t need to maintain their own indexer to track their UTXOs.

so the UTXOs should be populated in coins field?

Yes, that is correct @kingstone! As access to UTXOs is often needed to compute balance, I hope this doesn’t impose any additional burden.

Usually there is no problem, but there may be too many UTXOs under one address, such as 2000 UTXO. Will there be performance issues? @patrick.ogrady

We set pretty generous timeouts on our clients to mitigate issues like this right now.

However, you are completely right that there could be performance issues when accessing accounts with this many UTXOs. Maybe it makes sense to have a separate UTXO endpoint that allows for paging? Curious what your thoughts are here @kingstone?

In the meantime, I’d assume no performance issues and we can triage if something comes up.

Indeed, there is no real performance issue yet, so that we can ignore the performance issue for now and keep watching.

But in the long run, it should be perfect if there is a separate pageable UTXO endpoint. @patrick.ogrady :star_struck:

You should open an issue on the spec!


1 Like