Using bitcoin's RPC and txindex=0
is it possible to tell the difference between an existing output being already spent and a non existing transaction output (or transaction id)? Looking at gettxout
it's not enough as it would return empty data in both scenarios.
There’s functionally no distinction between an output which doesn’t exist, and one which hasn’t existed from the perspective of validation. The node never needs to consider this so by default it stores no information about it.