-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow selecting coins in sendcoins
#8955
Allow selecting coins in sendcoins
#8955
Conversation
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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up @yyforyongyu! I've checked out the test cases you added and left a suggestion. Since the original commits did not change and were already approved I will only aim for a tAck in my next review round.
|
||
// Since the first two UTXOs have been sent to an address outside her | ||
// wallet, Alice should see a single UTXO now. | ||
ht.AssertNumUTXOs(alice, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we further check that the remaining coin can't be selected and spent in its entirety so that the required reserves are not violated?
On this note, should the API allow to spend the coin up until the required reserve and not return an error unless other constraints like the dust limit of the sending amount are reached? Maybe further tests can document behavior here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I like it, added a test to show how it behaves atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too far off I think, mainly some code style changes on the wish list.
sweep/walletsweep.go
Outdated
@@ -260,6 +267,15 @@ func CraftSweepAllTx(feeRate, maxFeeRate chainfee.SatPerKWeight, | |||
|
|||
log.Trace("[WithCoinSelectLock] finished fetching UTXOs") | |||
|
|||
// Use select utxos, if provided. | |||
if len(selectUtxos) > 0 { | |||
utxos, err = fetchUtxosFromOutpoints(utxos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
6ccb920
to
0cb2739
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional itest that documents the utxo selection and channel reserves.
I've tested multiple scenarios in regtest that I also confirmed in the first version of this PR, tACK ✅
EDIT: The test failures seem unrelated to this PR.
itest/lnd_misc_test.go
Outdated
// also checks that change outputs will be created automatically if `SendAll` | ||
// flag is set. | ||
func testSendSelectedCoinsChannelReserve(ht *lntest.HarnessTest) { | ||
chanAmt := btcutil.Amount(100000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 100_000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
itest/lnd_misc_test.go
Outdated
tx := ht.GetNumTxsFromMempool(1)[0] | ||
|
||
// Assert the tx has the expected shape. It should have 2 inputs and 2 | ||
// output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: outputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM 🎉
Signed-off-by: Ononiwu Maureen <[email protected]>
This commit updates the interface methods from `lnwallet.WalletController` to take optional input set which can be used to create the tx.
Signed-off-by: Ononiwu Maureen <[email protected]>
Signed-off-by: Ononiwu Maureen <[email protected]>
Signed-off-by: Ononiwu Maureen <[email protected]>
Also rename the send all coins test for clarity.
0cb2739
to
dcd8269
Compare
@@ -288,10 +288,11 @@ var sendCoinsCommand = cli.Command{ | |||
}, | |||
cli.BoolFlag{ | |||
Name: "sweepall", | |||
Usage: "if set, then the amount field will be ignored, " + |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Replaces #8516, fixes #6949