From 3a3571ba6f7f7445dced9bb2e86689f632a1ad4f Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 15 Oct 2020 09:15:12 +0200 Subject: [PATCH] labels: add on-chain labels for loop in/out --- labels/lnd_labels.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 labels/lnd_labels.go diff --git a/labels/lnd_labels.go b/labels/lnd_labels.go new file mode 100644 index 0000000..c21dee5 --- /dev/null +++ b/labels/lnd_labels.go @@ -0,0 +1,37 @@ +package labels + +import "fmt" + +const ( + // loopdLabelPattern is the pattern that loop uses to label on-chain + // transactions in the lnd backend. + loopdLabelPattern = "loopd -- %s(swap=%s)" + + // loopOutSweepSuccess is the label used for loop out swaps to sweep + // the HTLC in the success case. + loopOutSweepSuccess = "OutSweepSuccess" + + // loopInHtlc is the label used for loop in swaps to publish an HTLC. + loopInHtlc = "InHtlc" + + // loopInTimeout is the label used for loop in swaps to sweep an HTLC + // that has timed out. + loopInSweepTimeout = "InSweepTimeout" +) + +// LoopOutSweepSuccess returns the label used for loop out swaps to sweep the +// HTLC in the success case. +func LoopOutSweepSuccess(swapHash string) string { + return fmt.Sprintf(loopdLabelPattern, loopOutSweepSuccess, swapHash) +} + +// LoopInHtlcLabel returns the label used for loop in swaps to publish an HTLC. +func LoopInHtlcLabel(swapHash string) string { + return fmt.Sprintf(loopdLabelPattern, loopInHtlc, swapHash) +} + +// LoopInSweepTimeout returns the label used for loop in swaps to sweep an HTLC +// that has timed out. +func LoopInSweepTimeout(swapHash string) string { + return fmt.Sprintf(loopdLabelPattern, loopInSweepTimeout, swapHash) +}