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

loopout: allow per-swap confirmation targets for server HTLC #258

Merged
merged 3 commits into from Aug 5, 2020

Conversation

carlaKC
Copy link
Contributor

@carlaKC carlaKC commented Jul 24, 2020

This PR allows setting of the number of confirmations we require for the loop out htlc that is published by the server on a per-swap basis. This allows setting of higher confirmation targets for larger value swaps (reducing counterparty risk of being double spent).

On the cli, we fail for 0 values because one would need to specifically set a 0 value (the flag defaults to 1), but rpc side we just bump 0 values up to the default of 1 conf so that older clients don't start failing when the server introduces this new parameter. Conf targets are persisted so that we remember them across restarts.

@carlaKC carlaKC requested review from bhandras and halseth July 24, 2020 08:29
Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

only nits :)

cmd/loop/loopout.go Show resolved Hide resolved
cmd/loop/loopout.go Outdated Show resolved Hide resolved
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

Looks good, straightforward changes. I'd also split the cli part to a separate commit.

cmd/loop/loopout.go Show resolved Hide resolved
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM! 🥇

cmd/loop/loopout.go Show resolved Hide resolved
interface.go Outdated
@@ -64,6 +64,10 @@ type OutRequest struct {
// client sweep tx.
SweepConfTarget int32

// HtlcConfTarget specifies the number of confirmations we require for
// on chain loop out htlcs.
HtlcConfTarget int32
Copy link
Contributor

Choose a reason for hiding this comment

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

related to the discussion on the CLI flag name: why do we call it conf target here? Make it sound more like a fee estimation param, maybe we should be consistent in using something like HtlcRequiredConfs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah def, I think my mind just saw sweep target and went with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

should this one be renamed as well?

@carlaKC
Copy link
Contributor Author

carlaKC commented Aug 3, 2020

@halseth renamed that last var, PTAL :)

interface.go Outdated
@@ -175,7 +175,7 @@ type LoopInRequest struct {
// call.
MaxMinerFee btcutil.Amount

// HtlcConfTarget specifies the targeted confirmation target for the
// HtlcConfirmations specifies the targeted confirmation target for the
Copy link
Contributor

Choose a reason for hiding this comment

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

field name not actually changed

Copy link
Contributor

Choose a reason for hiding this comment

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

also, the comment is a bit weird, maybe use something similar to the one for loop out below?

interface.go Outdated
@@ -216,7 +216,7 @@ type LoopInQuoteRequest struct {
// include the swap and miner fee.
Amount btcutil.Amount

// HtlcConfTarget specifies the targeted confirmation target for the
// HtlcConfirmations specifies the targeted confirmation target for the
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, this is actually find and replace gone wild, shouldn't have been renamed in the first place, removed.

interface.go Outdated
@@ -64,6 +64,10 @@ type OutRequest struct {
// client sweep tx.
SweepConfTarget int32

// HtlcConfTarget specifies the number of confirmations we require for
// on chain loop out htlcs.
HtlcConfTarget int32
Copy link
Contributor

Choose a reason for hiding this comment

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

should this one be renamed as well?

@@ -182,6 +182,12 @@ message LoopOutRequest {
*/
int32 sweep_conf_target = 9;

/*
The number of confirmations that we require for the on chain htlc that will
be published by the server.
Copy link
Contributor

Choose a reason for hiding this comment

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

add "before we reveal the preimage"?

To allow users to specify differing confirmation targets, we store the
swap conf target per-swap. This makes us restart safe, so we do not
forget confirmation values for swaps that are in flight when we restart.
Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@carlaKC carlaKC merged commit a240c69 into lightninglabs:master Aug 5, 2020
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.

None yet

3 participants