Commit Graph

70 Commits (master)

Author SHA1 Message Date
Andras Banki-Horvath 5294b4ff07
loop: clean up server cost calculation for slightly better UX
Previously we'd calculate the server costs (swap fees) by accounting for
both the on-chain HTLC and the off-chain payment which was confusing as
server cost fluctuated by the amount of the swap itself. Now we'll only
add the actual cost when the swap happened, so the server cost will go
form zero to the actual fee value paid.
2 months ago
Slyghtning 3db464955d
loopin: sweep incorrect htlc amount after timeout 2 months ago
George Tsagkarelis b43fa11cc1
utils: add htlc & swap related helpers 3 months ago
Slyghtning caa646367f
loopin: finalize swap if unsifficient confirmed funds 5 months ago
Slyghtning c0b419346c
loopin: restore abandon chan on restart 5 months ago
Slyghtning 5e91c446b8
loopd: abandon loop-ins 5 months ago
Slyghtning 20316042d9
trivial: clean up typos and comments 9 months ago
George Tsagkarelis 921f4d06e7
multi: integrate initiator string to various calls 9 months ago
Slyghtning c8848a2e46
loopin: fix typos 10 months ago
sputn1ck becc8a38d8
multi: use context in loopdb call
This commit adds a context to our loopdb interface, which we should use
in the sqlite migration.
10 months ago
Andras Banki-Horvath b47f67a6de
loopin: push the htlc internal key if the invoice is swept
This commit adds key reveal to MuSig2 loopin swaps' success path. In
this case the client reveals their internal HTLC key to the server when
the swap invoice is settled. With this key the server can sweep the swap
HTLC without any more interaction from the client. We'll do this every
block (after the invoice has been settled).
1 year ago
Andras Banki-Horvath 90ae922adf
loopin: generate and send internal key for MuSig2 swaps
This commit changes how we create loopin swaps if the client activates
the experimental MuSig2 features. When creating a new loopin swap the
client will create (and store) a new key that will be used as the
sender's internal key when constructing the HTLC. The client will send
the public part to the server and will also receive (and store) the
server's (receiver) internal public key.
1 year ago
Andras Banki-Horvath da4bcbea10
loopdb: refactor the SwapContract to hold all HTLC keys
This commit adds a new struct to hold all HTLC keys and refactors the
SwapContract which is used by both loopin and loopout swaps to use this
new struct. The newly added internal keys will for now hold the script
keys to keep everything equivalent but are already stored and read back
if the protocol version is set to MuSig2.
1 year ago
Andras Banki-Horvath a7451622e5
mod: bump LND and lndclient to include musig2 1.0rc2 changes
This commit bumps LND and lndclient to make it possible to upgrade
taproot HTLC construction with a MuSig2 version. This is required to
support both old (MuSig2 0.4) and new (MuSig2 1.0) clients.
1 year ago
sputn1ck 4baf88c414
multi: fix linter issues
This commit fixes outstanding linter issues, that we're not found by
running `make lint` locally. The linter issues were found by running
`docker run -v $(pwd):/build loop-tools golangci-lint run --whole-files`

I added the `revive` to the excludes as it would be to much of a
refactor and IMO seems unneccesary. E.g.
`interface.go:222:6: exported: type name will be used as
loop.LoopInTerms by other packages, and that stutters; consider
 calling this InTerms (revive)`. I think `loop.LoopInTerms` is fine.
1 year ago
Andras Banki-Horvath bdb4b773ed
swap: refactor htlc construction to allow passing of internal keys
This commit is a refactor of how we construct htlcs to make it possible
to pass in internal keys for the sender and receiver when creating P2TR
htlcs. Furthermore the commit also cleans up constructors to not pass in
script versions and output types to make the code more readable.
1 year ago
Andras Banki-Horvath 88956455b4
multi: completely remove support for NP2WSH htlcs
This commit removes all code related to NP2WSH htlcs. These were
historically used when segwit adoption was very sporadic and are not
used anywhere anymore. Some historical swaps stored in the DB may be
listed with incorrect htlc adresses from here on.
1 year ago
sputn1ck 0f924b36cd
multi: bump lndclient and lnd version to latest
Co-authored-by: Oliver Gugger <gugger@gmail.com>
2 years ago
Andras Banki-Horvath a252e2c706
loopdb: add the local pubkey's keylocator to the persisted contract 2 years ago
Andras Banki-Horvath 901a935514
loopin: enable p2tr htlcs without keyspend 2 years ago
Andras Banki-Horvath 00cf4bf71c
multi: make the next protocol version optional 2 years ago
Carla Kirk-Cohen c7ef4297c0
multi: update sweeping to allow different sighashes and claim scripts
Taproot spends require a different sighash, so we update our HtlcScript
interface to provide the appropriate sighash when sweeping. We also add
distinct Timeout/Success Script functions to allow for tapleaf spends
which have different locking scripts for different paths. Note that the
timeout and success paths will be the same for segwit v0 htlcs, because
it has a single branched script containing all spend paths.

In future iterations, this differentiation of claim scripts can also
be used to use musig2 to collaboratively keyspend P2TR htlcs with the
server. This script can be expressed as PriorityScript (because we'll
try to keyspend as a priority, and then fall back to a tap leaf spend).
As we've done here, segwit v0 spends would just return their single
script for PriorityScript, and the claim would be no different from
our other claims.
2 years ago
Oliver Gugger d5952f1202
multi: bump all dependency to use lnd 0.15.0-beta.rc4
This commit bumps all dependencies to be in line with what's required
for the current release candidate of lnd 0.15.0-beta.
2 years ago
sputn1ck efb6f75d60
swap: add lasthop, outgoingchanids to swapinfo 2 years ago
Harsha Goli dec6dd7e70
swap: HTLCV3 added
In this commit we add the version 3 htlc, which is implemented with
taproot script spending the two payment paths: the claim path case, and
the timeout case.
2 years ago
Harsha Goli 7a16e3b25d
multi: bump btcec/v2 and btcutil to new versions 2 years ago
Harsha Goli f1a7d8fb49
multi: pass private, routehints from loopcli - loopd - loop server
This commit passes routehints all the way from when/if the user passes
them from the cli all the way to the backend loop server. If private is
used, this commit passes that boolean down to different stages, where it
is then converted into routehints.

main: add --private and --route_hints to quote

Adds --private and --route_hints flags to quote cli
2 years ago
Andras Banki-Horvath 0e7ed91d5d
loop: integrate the probe api with loop-in quote
In this commit we add a call to the new probe endpoint directly into the
loop-in quote call. Furthermore we add an option to include private
channels in the loopin swap payment request. This is also useful for when
users quote/probe directly using the client API and specify hop hints.
3 years ago
Andras Banki-Horvath f786aaa016
loop: add support for the probe API 3 years ago
carla d1c26a20da
multi: surface server swap initiation grpc error codes
Formatting our error was stifling any grpc error returned by the
server. Instead, we bubble up our grpc error, setting an unknown
code if the server did not specifically return an error code.
3 years ago
carla 0e72c2bf92
loopin: handle EOF case for SubscribeSingleInvoice
From lnd 0.13.0, the SubscribeSingleInvoice rpc will return an EOF
once it has served a final state to the stream. This is handled in
our lndclient wrapper by closing the channels that we send updates/
errors on. When we are exclusively consuming updates from these
streams, we don't need to handle this case because we will receive
our final update and exit. However, in the case where we continue
to listen on the update channels after consuming the final update,
we need to handle this EOF/closed channels case. This is done by
setting the channels to nil after they're closed so that we no
longer select on them but can continue waiting for our other cases
to complete.

We have similar handling in loopout's waitForHtlcSpendConfirmed.
3 years ago
carla 4911130671
loopin: store loop in on-chain fees 3 years ago
Oliver Gugger 2a732a4385
loop: add initiator string to user agent 4 years ago
Oliver Gugger 38ddbfb45d
mod+loopin+loopout: update lndclient, add labels to TXs
We update to the latest lndclient that now requires a label when
publishing an on-chain transaction. Instead of just adding an empty
string, we use the proper labels added in a previous commit.
4 years ago
carla 7b56804bbe
multi: move label validation to rpc and simplify validation function
Previously labels with reserved prefixes were added to provide us
with a way to identify automatically dispatched loops. This commit moves
the validation of these labels to the rpc level so that it will only
apply to user-initiated swaps.
4 years ago
Joost Jager c8666caf20
loopin: mpp pre-swap probe 4 years ago
Andras Banki-Horvath 133f3cac5f multi: integrate the new htlc v2 scripts to loop in/out
This commit bumps the current protocol version and integrates htlc v2
with loop in/out for new swaps, while keeping htlc v1 for any pending
swaps with previous protocol versions.
4 years ago
Andras Banki-Horvath 71a7dec649
sweeper: set sequence to be able to sweep htlc v2 utxo 4 years ago
Andras Banki-Horvath cd0a5f9f06
swap: extend swap to be able to create the V2 htlc 4 years ago
carla 9678c7817d
multi: add swap label to SwapContract and store under separate key
This commits adds an optional label to our swaps, and writes it to
disk under a separate key in our swap bucket. This approach is chosen
rather than an on-the-fly addition to our existing swap contract field
so that we do not need to deal with EOF checking in the future. To allow
creation of unique internal labels, we add a reserved prefix which can
be used by the daemon to set labels that are distinct from client set
ones.
4 years ago
carla cd2b08aec6
multi: consume and log sever state updates 4 years ago
Joost Jager 1869ad670f
looprpc: expose server message to clients 4 years ago
Joost Jager 8b215edaa2
multi: create init result structs 4 years ago
Joost Jager c6c30e2988
multi: log server message 4 years ago
Joost Jager f91422d188
loopin: record htlx tx hash 4 years ago
Joost Jager a3b7fa5977
loopin: fail swap when htlc amount is incorrect
Previously the swap would get stuck in a state where it wouldn't ever
progress because the server rejected the htlc.
4 years ago
Joost Jager e33d2fb762
loopin: extract persistState 4 years ago
Joost Jager 6b8fcc547c
loopin: rename to persistAndAnnounceState 4 years ago
Joost Jager 60b907a34f
loopin: refactor htlc conf event loop 4 years ago
Joost Jager 0c9fcd790e
lndclient: move to github.com/lightninglabs/lndclient 4 years ago