ckb-cell / rgbpp-sdk

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

The INSUFFICIENT_UTXO error is not clear enough #260

Open ShookLyngs opened 1 month ago

ShookLyngs commented 1 month ago

Issue

The reasons triggering the INSUFFICIENT_UTXO error are clear:

  1. Not enough satoshi collected to cover the needs of the outputs and fee
  2. Not enough satoshi collected to generate a change output (change output value < minUtxoSatoshi)

However, it's hard to prompt a specific reason that causes the error because there could be indirect causes:

  1. Small value UTXOs (value < minUtxoSatoshi) of an address will be excluded as they're considered dust
  2. If ckbVirtualResult.needPaymasterCell == true, there's an extra payment to the paymaster
  3. The change output's defined value must be >= minUtxoSatoshi

Possible Resolutions

Flouse commented 1 month ago
  • For the indirect cause 3 mentioned above, we could add an option to allow treating the change value as fee if the value is smaller than the minUtxoSatoshi, instead of always generating a change output for that. Related issue: Don't create change output if not worthy #183.

Ideas about making the BTC tx cost as low as possible

  1. 546 <= changeValue < minUtxoSatoshi create the change output directly with changeValue.

  2. changeValue < 546 The change could be treated as a fee, as it may not be economically viable to create a change output for such a small amount. => https://github.com/ckb-cell/rgbpp-sdk/issues/183