From 61959aa96421204e9b7e9ab9177cb0c54de21130 Mon Sep 17 00:00:00 2001 From: octobocto Date: Sat, 8 Aug 2026 06:53:59 -0700 Subject: [PATCH] server: add WithCookiePath for cookie auth --- server/server.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/server.go b/server/server.go index 5f4659e..10f1a2f 100644 --- a/server/server.go +++ b/server/server.go @@ -70,6 +70,7 @@ type config struct { allowPrivateDescriptorsExport bool // default to the safe option, denying logging func(ctx context.Context) *zerolog.Logger withoutInitialConnectionCheck bool + cookiePath string } func newConfig(opts []Option) config { @@ -99,6 +100,16 @@ func WithAllowPrivateDescriptorsExport() Option { } } +// WithCookiePath authenticates via Core's cookie file instead of a static +// user/pass. The cookie is re-read when it changes, so callers survive a Core +// restart (which rewrites the cookie) without reconnecting. Ignored when a +// non-empty pass is also supplied. +func WithCookiePath(path string) Option { + return func(c *config) { + c.cookiePath = path + } +} + // WithoutInitialConnectionCheck disables the initial connection check to // Bitcoin Core. This allows you to succeed in starting up the server, even // if the underlying Core node is not reachable. @@ -135,6 +146,7 @@ func NewBitcoind( rpcConf := rpcclient.ConnConfig{ User: user, Pass: pass, + CookiePath: conf.cookiePath, DisableTLS: !conf.enableTLS, Host: host,