ckb-cell / rgbpp-sdk

Utilities for Bitcoin and RGB++ asset integration
ISC License
52 stars 16 forks source link

Don't create change output if not worthy #183

Open ShookLyngs opened 2 months ago

ShookLyngs commented 2 months ago

Idea

When paying fee in the BTC TX building process, there will be an extra collection if the change amount is in range of:

0 < changeAmount < minUtxoSatoshi

Here we have a new suggestion to NOT create a change output if the changeAmount is less than the cost of creating a change output, which generally equals to the value of minUtxoSatoshi. Currently, the default value of minUtxoSatoshi on the mainnet is 10,000 shannon, therefore the overall logic here is as follow:

if (changeAmount >= 10000) {
  createChangeOutput(changeAmount);
} else {
  // don't create a change output
  // treat the changeAmount as an extra fee to the miner
}

Reference

The idea was originally posted here: https://github.com/ckb-cell/rgbpp-sdk/pull/176#discussion_r1608069118