We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 06f1ef4 commit 6517104Copy full SHA for 6517104
lnutils/log.go
@@ -1,8 +1,11 @@
1
package lnutils
2
3
import (
4
+ "log/slog"
5
"strings"
6
7
+ "github.com/btcsuite/btcd/btcec/v2"
8
+ "github.com/btcsuite/btclog/v2"
9
"github.com/davecgh/go-spew/spew"
10
)
11
@@ -36,3 +39,14 @@ func NewSeparatorClosure() LogClosure {
36
39
return strings.Repeat("=", 80)
37
40
}
38
41
42
+
43
+// LogPubKey returns a slog attribute for logging a public key in hex format.
44
+func LogPubKey(key string, pubKey *btcec.PublicKey) slog.Attr {
45
+ // Handle nil pubkey gracefully, although callers should ideally prevent
46
+ // this.
47
+ if pubKey == nil {
48
+ return btclog.Fmt(key, "<nil>")
49
+ }
50
51
+ return btclog.Hex6(key, pubKey.SerializeCompressed())
52
+}
0 commit comments