Skip to content
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

ensure payee and add expected payout height #31

Open
wants to merge 12 commits into
base: jssdwt-swap-size
Choose a base branch
from

Conversation

JssDWt
Copy link
Collaborator

@JssDWt JssDWt commented Jan 17, 2025

The client adds a random invoice to the create_swap request.
From that random invoice the final cltv, the destination and the expected route to the destination are extracted.
Now create_swap returns the expected last payout height for indication when the last payout time is.
Also it is now enforced that the destination of the swap payout is the same as the one that created it.

@JssDWt JssDWt force-pushed the jssdwt-ensure-payee branch from decfb78 to a2b04ed Compare January 17, 2025 14:37
@JssDWt JssDWt force-pushed the jssdwt-ensure-payee branch 2 times, most recently from 3ed44ef to 7521067 Compare January 17, 2025 15:09
@JssDWt JssDWt force-pushed the jssdwt-ensure-payee branch from 7521067 to d68e6f9 Compare January 17, 2025 15:57
@@ -259,6 +289,10 @@ where

let hash = invoice.payment_hash();
let swap_state = self.swap_repository.get_swap_by_hash(hash).await?;
if swap_state.swap.destination != invoice.get_payee_pub_key() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for validating the destination? Should we validate the payout window by calculating the route again?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make sure that only the swap requester can get paid for the swap. Thinking about it again maybe the preimage is enough certainty and we don't even have to check the destination?

// invoice should have equivalent values for routing hints and
// min_final_cltv_expiry_delta as the eventual invoice used for payout, so
// the swap server can give a good estimate of fees and timeouts.
string invoice = 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do understand the explanation above but it seems a bit odd to require the client to pass two invoices. One here and a different one in the pay_swap. Perhaps we can make the second one optional?

Copy link
Collaborator Author

@JssDWt JssDWt Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's odd. Just an invoice contains the information we want to use. Destination, route hints, min_final_cltv_expiry delta, signature.

We could make the invoice for payout optional, but actually the client would always send the invoice for payout I think. Now the swap server doesn't have to persist the invoice along with the swap. I think that's a feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants