Bitcoin
What is the best way to check the use of Bitcoin Core RPC when the JSON RPC-transaction starts again?

The current approach is to check the following:
fn is_orphaned(..)
let res = get_raw_transaction(txid)
return confirmations == 0 && blockhash != null
Is the above length correct? And is there a more direct way to check whether the deal is going back? TXINDEX = 1 is running Bitcoin Core