Browse Source

loopd: add initiator to swap requests

pull/316/head
Oliver Gugger 2 months ago
parent
commit
8758d00862
No known key found for this signature in database GPG Key ID: 8E4256593F177720
2 changed files with 11 additions and 1 deletions
  1. +3
    -1
      loopd/swapclient_server.go
  2. +8
    -0
      version.go

+ 3
- 1
loopd/swapclient_server.go View File

@ -99,7 +99,8 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
SwapPublicationDeadline: time.Unix(
int64(in.SwapPublicationDeadline), 0,
),
Label: in.Label,
Label: in.Label,
Initiator: in.Initiator,
}
switch {
@ -496,6 +497,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
HtlcConfTarget: htlcConfTarget,
ExternalHtlc: in.ExternalHtlc,
Label: in.Label,
Initiator: in.Initiator,
}
if in.LastHop != nil {
lastHop, err := route.NewVertexFromBytes(in.LastHop)

+ 8
- 0
version.go View File

@ -8,6 +8,7 @@ package loop
import (
"bytes"
"fmt"
"math"
"strings"
)
@ -64,6 +65,13 @@ func UserAgent(initiator string) string {
cleanInitiator = fmt.Sprintf(",initiator=%s", cleanInitiator)
}
// The whole user agent string is limited to 255 characters server side
// and also consists of the agent name, version and commit. So we only
// want to take up at most 150 characters for the initiator. Anything
// more will just be dropped.
strLen := len(cleanInitiator)
cleanInitiator = cleanInitiator[:int(math.Min(float64(strLen), 150))]
// Assemble full string, including the commit hash of current build.
return fmt.Sprintf(
"%s/v%s/commit=%s%s", AgentName, semanticVersion(), Commit,

Loading…
Cancel
Save