sweep, rpcserver: optimize SendAll cost wise#8936
Conversation
The first CraftSweepAllTx call is not expected to respect reserved amount.
If there is a coin of value equal to the amount reserved for anchor bumping (e.g. 100k sats), SendAll used to spend it and to create another coin of such size. Now it just does not touch the coin in this scenario. To achieve this, added argument skipInputAmount to fn sweep.CraftSweepAllTx. If it is not 0, it looks for an input of that value and skips it. If it can't find an input, it skips locking UTXOs and returns ErrMissingInputToSkip. Added unit test for new functionality of CraftSweepAllTx. Added itest to test the optimization in SendAll. SendAll is used by `lncli sendcoins --sweepall`.
|
Important Review skippedAuto reviews are limited to specific labels. Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
|
An example tx. |
|
Superseded by #8955 |
Change Description
If there is a coin of value equal to the amount reserved for anchor bumping (e.g. 100k sats), SendAll used to spend it and to create another coin of such size. Now it just does not touch the coin in this scenario.
To achieve this, added argument
skipInputAmountto fnsweep.CraftSweepAllTx. If it is not 0, it looks for an input of that value and skips it. If it can't find an input, it skips locking UTXOs and returnsErrMissingInputToSkip.Added unit test for new functionality of
CraftSweepAllTx.Added itest to test the optimization in SendAll.
SendAll is used by
lncli sendcoins --sweepall.Steps to Test
lncli sendcoins --sweepallmoving all the funds to an external addresslncli sendcoins --sweepallagain moving all the funds to an external addressPull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.Example transaction
If this PR was applied, the transaction wouldn't include its last input and first output (0.001 BTC each).