func New(cfg *Config) *Watcher {
	return &Watcher{
		cfg:          *cfg,
		expiryReqs:   make(chan *expiryReq),
		quit:         make(chan struct{}),
		spendCancels: make(map[[33]byte]func()),
		confCancels:  make(map[[33]byte]func()),
	}
}
New instantiates a new chain watcher backed by the given config.
package watcher
import (
	"context"
	"errors"
	"sync"
	"github.com/btcsuite/btcd/btcec"
	"github.com/btcsuite/btcd/chaincfg/chainhash"
	"github.com/btcsuite/btcd/wire"
	"github.com/lightninglabs/lndclient"
	"github.com/lightningnetwork/lnd/chainntnfs"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)
type expiryReq struct {
	traderKey *btcec.PublicKey
	expiry uint32
}
type Config struct {
	ChainNotifier lndclient.ChainNotifierClient
	HandleAccountConf func(*btcec.PublicKey, *chainntnfs.TxConfirmation) error
	HandleAccountSpend func(*btcec.PublicKey, *chainntnfs.SpendDetail) error
	HandleAccountExpiry func(*btcec.PublicKey, uint32) error
}
type Watcher struct {
	started sync.Once
	stopped sync.Once
	cfg Config
	expiryReqs chan *expiryReq
	wg         sync.WaitGroup
	quit       chan struct{}
	ctxCancels []func()
	cancelMtx    sync.Mutex
	spendCancels map[[33]byte]func()
	confCancels  map[[33]byte]func()
}