Elijah

How to calculate the minimum satoshis amount for an UTXO

Developing on bitcoin, we are used to hear that there’s an absolute minimum of satoshis that an UTXO should have in order to be accepted and not considered “dust”. If you google, that value is said to be 546 satoshis.

But that’s actually not a fixed value, but it’s calculated based on the size of the UTXO. What happens is that on bitcoin, almost all UTXO are the same because they are mostly P2PKH scripts.

Working with custom scripts on the Bitcoin SV network, I started to see the 64: dust error returned for some of my transactions that had variable UTXO size. I was puzzled by this because of my previous idea that every UTXO with more than 546 satoshis was not a dust UTXO.

I couldn’t find much information about this, so I ended up diving into the BSV node code. I found that:

So I wrote the following function:

This function should return (on the safe side) the minimum amount of satoshis that a UTXO should hold in the Bitcoin SV network so it’s not considered dust.