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:
- There’s a
dustRelayFee
that actually controls how this will be calculated - There’s a hardcoded input size that gets added to the calculation
- Everything then is multiplied by a dust limit factor
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.