mirror of
https://github.com/lightninglabs/loop
synced 2024-11-09 19:10:47 +00:00
loopd: add initiator to swap requests
This commit is contained in:
parent
2a732a4385
commit
8758d00862
@ -100,6 +100,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
|
|||||||
int64(in.SwapPublicationDeadline), 0,
|
int64(in.SwapPublicationDeadline), 0,
|
||||||
),
|
),
|
||||||
Label: in.Label,
|
Label: in.Label,
|
||||||
|
Initiator: in.Initiator,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
@ -496,6 +497,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
|
|||||||
HtlcConfTarget: htlcConfTarget,
|
HtlcConfTarget: htlcConfTarget,
|
||||||
ExternalHtlc: in.ExternalHtlc,
|
ExternalHtlc: in.ExternalHtlc,
|
||||||
Label: in.Label,
|
Label: in.Label,
|
||||||
|
Initiator: in.Initiator,
|
||||||
}
|
}
|
||||||
if in.LastHop != nil {
|
if in.LastHop != nil {
|
||||||
lastHop, err := route.NewVertexFromBytes(in.LastHop)
|
lastHop, err := route.NewVertexFromBytes(in.LastHop)
|
||||||
|
@ -8,6 +8,7 @@ package loop
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -64,6 +65,13 @@ func UserAgent(initiator string) string {
|
|||||||
cleanInitiator = fmt.Sprintf(",initiator=%s", cleanInitiator)
|
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.
|
// Assemble full string, including the commit hash of current build.
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"%s/v%s/commit=%s%s", AgentName, semanticVersion(), Commit,
|
"%s/v%s/commit=%s%s", AgentName, semanticVersion(), Commit,
|
||||||
|
Loading…
Reference in New Issue
Block a user