func (c *Client) Start() error {
	if !atomic.CompareAndSwapUint32(&c.started, 0, 1) {
		return nil
	}
	serverConn, err := grpc.Dial(c.cfg.ServerAddress, c.cfg.DialOpts...)
	if err != nil {
		return fmt.Errorf("unable to connect to RPC server: %v",
			err)
	}
	c.serverConn = serverConn
	c.client = auctioneerrpc.NewChannelAuctioneerClient(serverConn)
	c.hashMailClient = auctioneerrpc.NewHashMailClient(serverConn)
	c.errChanSwitch.Start()
	return nil
}
Start starts the client, establishing the connection to the server.
package auctioneer
import (
	"bytes"
	"context"
	"crypto/tls"
	"errors"
	"fmt"
	"io"
	"math"
	"net"
	"sync"
	"sync/atomic"
	"time"
	"github.com/btcsuite/btcd/btcec"
	"github.com/btcsuite/btcd/chaincfg/chainhash"
	"github.com/btcsuite/btcd/wire"
	"github.com/btcsuite/btcutil"
	"github.com/lightninglabs/lndclient"
	"github.com/lightninglabs/pool/account"
	"github.com/lightninglabs/pool/auctioneerrpc"
	"github.com/lightninglabs/pool/order"
	"github.com/lightninglabs/pool/poolrpc"
	"github.com/lightninglabs/pool/sidecar"
	"github.com/lightninglabs/pool/terms"
	"github.com/lightningnetwork/lnd/keychain"
	"github.com/lightningnetwork/lnd/lntypes"
	"github.com/lightningnetwork/lnd/lnwallet/chainfee"
	"github.com/lightningnetwork/lnd/tor"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/credentials"
	"google.golang.org/grpc/status"
)
const (
	reconnectRetries = math.MaxInt16
	maxUnusedAccountKeyLookup = 50
)
var (
	ErrServerShutdown = errors.New("server shutting down")
	ErrServerErrored = errors.New("server sent unexpected error")
	ErrClientShutdown = errors.New("client shutting down")
	ErrAuthCanceled = errors.New("authentication was canceled")
)
type Config struct {
	ServerAddress string
	ProxyAddress string
	Insecure bool
	TLSPathServer string
	DialOpts []grpc.DialOption
	Signer lndclient.SignerClient
	MinBackoff time.Duration
	MaxBackoff time.Duration
	BatchSource BatchSource
	BatchCleaner BatchCleaner
	GenUserAgent func(context.Context) string
	ConnectSidecar bool
}
type Client struct {
	cfg *Config
	started uint32
	stopped uint32
	StreamErrChan  chan error
	errChanSwitch  *ErrChanSwitch
	FromServerChan chan *auctioneerrpc.ServerAuctionMessage
	serverConn     *grpc.ClientConn
	client         auctioneerrpc.ChannelAuctioneerClient
	hashMailClient auctioneerrpc.HashMailClient
	quit         chan struct{}
	wg           sync.WaitGroup
	serverStream auctioneerrpc.ChannelAuctioneer_SubscribeBatchAuctionClient
	streamMutex  sync.Mutex
	streamCancel func()
	subscribedAccts    map[[33]byte]*acctSubscription
	subscribedAcctsMtx sync.Mutex
}
func NewClient(cfg *Config) (*Client, error) {
	var err error
	cfg.DialOpts, err = getAuctionServerDialOpts(
		cfg.Insecure, cfg.ProxyAddress, cfg.TLSPathServer, cfg.DialOpts...,
	)
	if err != nil {
		return nil, err
	}
	mainErrChan := make(chan error)
	errChanSwitch := NewErrChanSwitch(mainErrChan)
	return &Client{
		cfg:             cfg,
		FromServerChan:  make(chan *auctioneerrpc.ServerAuctionMessage),
		StreamErrChan:   mainErrChan,
		errChanSwitch:   errChanSwitch,
		quit:            make(chan struct{}),
		subscribedAccts: make(map[[33]byte]*acctSubscription),
	}, nil
}