The following content was written by dkbit98 on March 30, 2021, 06:12:44 PM in the thread How to cancel Bitcoin transaction?. All content is owned by the author of the bitcointalk.org post. (original)
When you send Bitcoin from your wallet to some other address it needs some time for transaction confirmation in the blockchain, and after confirmation it’s impossible to cancel any transaction and they are irreversible.
It would be wise to double check and make sure you are sending correct amount of coins to the right address before clicking send button, and make sure you used correct fee for transaction.
If transaction is unconfirmed and you made some mistake or used lower fee than you may still be able to cancel your Bitcoin transaction.
How to cancel unconfirmed Bitcoin transaction?
There are few ways you can use to cancel and replace your transaction and for that purpose you should use wallets like Electrum and enable RBF option before sending your transaction.
RBF means that you will pay higher fees to get transaction confirmed faster by replacing your transaction with new one.
Open your Electrum (or other wallet supporting RBF), go to Tools-Preferences-Transactions, make sure you enable and check option Use Replace-By-Fee, and now your transactions are flagged as replaceable until confirmed.
You will now be able to replace your original transaction with new one with higher transaction fee, if you right click on your unconfirmed transaction and click option Increase Fee
Double spend with higher fee
Double spending with higher fee works in similar way but you are sending transaction to yourself with a higher transaction fee.
In Electrum wallet you can go to your unconfirmed transaction and right click will give you option Cancel (double-spend)
Child Pays For Parent (CPFP)
This is mostly used by miners when receiver pays the higher fee by incentivizing miners and you can enable it in Electrum with right clicking on your unconfirmed transaction and click option Child Pays For Parent.
Wallets supporting RBF Replace-By-Fee:
More information about RBF can be found on Bitcoin Core website