func NewLoader(chainParams *chaincfg.Params, dbDirPath string,
	noFreelistSync bool, recoveryWindow uint32) *Loader {
	waddrmgr.KeyScopeBIP0044.Coin = chainParams.HDCoinType
	waddrmgr.DefaultKeyScopes[0] = waddrmgr.KeyScopeBIP0044
	waddrmgr.ScopeAddrMap = map[waddrmgr.KeyScope]waddrmgr.ScopeAddrSchema{
		waddrmgr.KeyScopeBIP0044: {
			InternalAddrType: waddrmgr.PubKeyHash,
			ExternalAddrType: waddrmgr.PubKeyHash,
		},
	}
	return &Loader{
		chainParams:    chainParams,
		dbDirPath:      dbDirPath,
		noFreelistSync: noFreelistSync,
		recoveryWindow: recoveryWindow,
	}
}
NewLoader constructs a Loader with an optional recovery window. If the
recovery window is non-zero, the wallet will attempt to recovery addresses
starting from the last SyncedTo height.
package wallet
import (
	"errors"
	"os"
	"path/filepath"
	"sync"
	"time"
	"github.com/gcash/bchd/chaincfg"
	"github.com/gcash/bchwallet/internal/prompt"
	"github.com/gcash/bchwallet/waddrmgr"
	"github.com/gcash/bchwallet/walletdb"
)
const (
	walletDbName = "wallet.db"
)
var (
	ErrLoaded = errors.New("wallet already loaded")
	ErrNotLoaded = errors.New("wallet is not loaded")
	ErrExists = errors.New("wallet already exists")
)
type Loader struct {
	callbacks      []func(*Wallet)
	chainParams    *chaincfg.Params
	dbDirPath      string
	noFreelistSync bool
	recoveryWindow uint32
	wallet         *Wallet
	db             walletdb.DB
	mu             sync.Mutex
}