-walletnotify notifications are now sent for wallet transactions that are removed from the mempool because they conflict with a new block
I tested this by creating a double-spend transaction on testnet. First I created and broadcasted a low fee tx, to an address in my Bitcoin Core wallet. Then broadcasted a higher fee tx, from the same input and with the same amount, to an address somewhere else.
After the first broadcast, walletnotify is triggered correctly.
However after I broadcast the second one, the conflict doesn't trigger walletnotify.
I verified with
bitcoin-cli -rpcwallet="" getrawmempool that the first transaction wasn't listed. I also verified on a block explorer that the first transaction wasn't valid anymore.
In the debug.log I see entries relating to the conflict:
[default wallet] Transaction xxxtx2 (in block xxxblock1) conflicts with wallet transaction xxxtx1 (both spend xxxhash1:1) [default wallet] Transaction xxxtx2 (in block xxxblock1) conflicts with wallet transaction xxxtx1 (both spend xxxhash2:0)
Why isn't walletnotify triggered by such conflicts?
Any other way to be notified about every conflict? (I'm thinking debug.log scanning)
I looked a bit through the source code, found
MemPoolRemovalReason as being relevant, but I'm unable to find an answer.
Running Bitcoin Core version 0.22 on Linux.