-
Notifications
You must be signed in to change notification settings - Fork 118
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
work-in-progress! loopout: can set exact amount #313
Conversation
1f7dceb
to
16bbae8
Compare
16bbae8
to
f8f6e46
Compare
Conflicts resolved and release_notes.md updated. |
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.
Gave this a high-level review because the author asked me to. Thanks for your work!
I like the idea of specifying a destination amount and using a change address for the rest. I think this is easier to implement than trying to scale the swap amount in order to send a specific amount to an address without change.
I do think this needs quite some work, though. I feel like there are quite a few edge cases lingering that need to be handled, especially in high fee environments.
And the database persistence of the parameters is also missing.
// Calculate weight for this tx. | ||
var weightEstimate input.TxWeightEstimator | ||
switch destAddr.(type) { | ||
return feeOnlyDest, feeOnlyChange, feeBoth, nil |
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.
I think instead of returning three different fees and checking them all in loopout.go
, this method should already decide what destination(s) to use and only return the fee for that. Otherwise this code is quite hard to follow with passing the data back and forth.
|
||
return feeRate.FeeForWeight(int64(weight)), nil | ||
return []destination{ |
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.
I'm not sure if silently failing here is good UX. Especially if the command line flag doesn't mention the behavior. Perhaps we should instead make sure that the swap amount is sufficiently larger than the destination amount?
Perhaps swap_amt >= max_sweep_fee + dest_amt
?
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.
max_sweep_fee
is actually known as max_miner_fee
|
||
// Where to send change in case DestAmount is specified. Optional. | ||
// Used together with DestAmount. | ||
ChangeAddr btcutil.Address |
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.
This data also needs to be stored in the swap database. Otherwise if you restart before sweeping, it will be lost.
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.
Should deserializeLoopOutContract
and serializeLoopOutContract
be updated?
They use some custom binary format. I guess the change of the format should be backward-compatible, so that strings produced by old serializeLoopOutContract
are successfully decoded by new deserializeLoopOutContract
. I'll add two new fields in the end and in deserializeLoopOutContract
if I get EOF trying to read the first field, I'll consider that ok, because it is an old format.
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.
if I get EOF trying to read the first field, I'll consider that ok, because it is an old format.
I see migration files. I think, I should add a migration.
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.
Done
This was proposed here: lightninglabs#234 (comment)
f8f6e46
to
3eeb121
Compare
Found and fixed another issue: in loopOut when making QuoteRequest we should pass WithChange depending on dest_amount. |
Concept ACK! As explained on Slack, I think we do want this feature but are going to hold off on further review until the "work in progress" state is removed to hopefully reduce the number of review iterations needed.
Thank you for your time and effort. |
@ratpoison4, remember to re-request review from reviewers for your latest update |
1 similar comment
@ratpoison4, remember to re-request review from reviewers for your latest update |
Closing due to inactivity. |
This was proposed here: #234 (comment)
I implemented logic of another Tx output here: sweep/sweeper.go
The logic of when to add which output is quite complex, so I added unit test for this (TestDeduceDestinations).
I am not familiar with the code, but I tried to pass everywhere new parameters. in OutRequest: DestAmount and ChangeAddr. In LoopOutQuoteRequest: WithChange. Careful review is required.
Also I don't know how to add an integration test and to test it in the wild (on testnet). Could you help me with this, please?
Pull Request Checklist
release_notes.md
if your PR contains major features, breaking changes or bugfixes