janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.48k stars 1.11k forks source link

Loop over getAddressDetails in /xyzpub handler #519

Closed Thierry61 closed 1 year ago

Thierry61 commented 1 year ago

The aim is to get all transactions of an address

Note that I didn't test the case where the loop is executed twice. My test cases have only 0, 1 or 2 transactions. I tried lowering limit parameter to 1 but in this case getAddressDetails unexpectedly returns a count greater than the limit.

The txCount == limit condition terminates the loop when:

The latter is a correct termination in my test cases, but I am not sure this is generally true.

To secure the code the condition could be changed to txCount > 0, but this would double the number of getAddressDetails requests (with one useless call for each address).

Edit: I tried txCount > 0 but I came across an infinite loop because getAddressDetails still returns data when passed an offset just after the last transactions, at least in my test case:

With this problem + the fact that getAdresssDetails can return more transactions than limit value as mentioned above, it is difficult to find a sure solution.

Thierry61 commented 1 year ago

Too unsafe in my opinion.