Skip to content

Commit 8758d00

Browse files
committed
loopd: add initiator to swap requests
1 parent 2a732a4 commit 8758d00

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

loopd/swapclient_server.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
9999
SwapPublicationDeadline: time.Unix(
100100
int64(in.SwapPublicationDeadline), 0,
101101
),
102-
Label: in.Label,
102+
Label: in.Label,
103+
Initiator: in.Initiator,
103104
}
104105

105106
switch {
@@ -496,6 +497,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
496497
HtlcConfTarget: htlcConfTarget,
497498
ExternalHtlc: in.ExternalHtlc,
498499
Label: in.Label,
500+
Initiator: in.Initiator,
499501
}
500502
if in.LastHop != nil {
501503
lastHop, err := route.NewVertexFromBytes(in.LastHop)

version.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package loop
88
import (
99
"bytes"
1010
"fmt"
11+
"math"
1112
"strings"
1213
)
1314

@@ -64,6 +65,13 @@ func UserAgent(initiator string) string {
6465
cleanInitiator = fmt.Sprintf(",initiator=%s", cleanInitiator)
6566
}
6667

68+
// The whole user agent string is limited to 255 characters server side
69+
// and also consists of the agent name, version and commit. So we only
70+
// want to take up at most 150 characters for the initiator. Anything
71+
// more will just be dropped.
72+
strLen := len(cleanInitiator)
73+
cleanInitiator = cleanInitiator[:int(math.Min(float64(strLen), 150))]
74+
6775
// Assemble full string, including the commit hash of current build.
6876
return fmt.Sprintf(
6977
"%s/v%s/commit=%s%s", AgentName, semanticVersion(), Commit,

0 commit comments

Comments
 (0)