With -txindex used, you are able to build your own database of all transactions.
Then a simple search for the desired address can yield the result you are interested in.
This wouldn't even be lots of coding, just a small script to store and search for the required information.
Yes, but then I would need to add an own database. In this case I guess I could also simply scan all the blocks and build the database from there, which would be not that much more resource consuming.
I've searched the Web a bit and found
this pull request review for Bitcoin Core from January. This would add the "search by address" feature needed for this kind of query. But it's still not implemented, and there seem to be some valid arguments against it (mostly, that an address index does not scale).
I have realized that without this kind of index the request I wanted is simply not possible in an efficient way, due to the structure of the Bitcoin Core database, because a transaction, apart from the address/pubkeyhash, doesn't hold information which could be useful to query subsequent transactions.
The only other strategy which could be possible is to build a database of TXIDs used in inputs of other transactions, which would make this query also possible ("query al txes where the TXID of Transaction A was used in inputs"), but I haven't found any information about that.
The best strategy without address database and without additional tools for now imo would be this one:
- if the transaction was recently, try scantxoutset
- if this gives no results: from the timestamp of Transaction A on, scan all blocks.