In this article we talk about coin selection, fees optimization and ways to optimize use of blockchain transactions deciding when an onchain transaction is better to be used than a lightning network one and vice versa.
So i am going to provide some suggestions in order to be be effective while executing onchain transactions. Onchain transactions are different from lightning network ones, because they are written on the blockchain; lightning network ones, instead, take place on layer 2 and only opening and closing channels are written on the blockchain.
Nowadays with the current development of lightning network it makes little sense to make onchain transactions for small amounts because the price of the fee impacts greatly and it makes no sense also “ethically” to occupy space on the blockchain for payments that could be made without such use and with great scalability.
The first advice is therefore always to use mainly LN in order to preserve the blockchain. It’s important to always think if an onchain transaction is really needed or it’s better to privilege lightning network.
Bitcoin blockchain is an important public resource for everyone, so it’s integrity must be preserved as much as possible. it guarantees our financial data and our security forever.
The bitcoin blockchain is the only public, universal, distributed, decentralized, immutable ledger of financial transactions on the planet. It has great important and this importance is increasing more and more when bitcoin progressively becomes the global resource of wealth. For these reasons it must be kept perfect, saved, optimized, distributed with the largest possible number of nodes, being a public resource available to all, without censorship.
HOW TO MAKE A TX
Onchain transactions must be confirmed, or (better said) must be written onto a block. When we make a transaction in fact, we do the following steps:
- preparing and verifying the transaction by choosing inputs and outputs and setting the right fee;
- signing with out private keys;
- broadcasting to the network;
- finally the transaction arrives in the mempool where it waits to be added by a miner to a block and it is here that the fee comes into play. The amount of fees, as a bottom line, determines the speed of such a verification and add.
A transaction shall set fees, which are paid as the difference between inputs and outputs. The fee is a kind of subjective offer on how much we are willing to pay to have the transaction put in a block. In the mempool the fees play like in an auction: the highest will cause the transaction to be put in a block first (ie faster) because it will be chosen more favorably by the miner. Fees are a kind of payment for the space used by your transaction on the block and a reward paid by the miner for the service of validating your transaction. So the longer your transaction is (in byte) and the higher the fee will be (in absolute terms). By the way there is no effect of the amount of transaction. A very low worth fee, will cost exactly the same of a ten bitcoin one, if the byte size is the same.
TIPS TO MINIMIZE COSTS
- evaluate the moment of the day and the day of the week; infact often, for example, on sunday mempool is more free and therefore fees are lower;
- evaluate if the transaction involves the right inputs or if these inputs could be rearranged to be less and therefore less space;
- where possible always use bech32 native Segwit addresses to optimize the size of the transaction;
- take in consideration the possibility to consolidate small utxtos in larger ones when fees are lower. Before doing that evaluate impact on privacy and check if this is ok for your profile.