func scopeFromBytes(scopeBytes []byte) KeyScope {
	return KeyScope{
		Purpose: binary.LittleEndian.Uint32(scopeBytes[:]),
		Coin:    binary.LittleEndian.Uint32(scopeBytes[4:]),
	}
}
scopeFromBytes decodes a serializes manager scope into its concrete manager
scope struct.
package waddrmgr
import (
	"crypto/sha256"
	"encoding/binary"
	"errors"
	"fmt"
	"time"
	"github.com/gcash/bchd/chaincfg/chainhash"
	"github.com/gcash/bchwallet/walletdb"
)
const (
	MaxReorgDepth = 10000
)
var (
	LatestMgrVersion = getLatestVersion()
	latestMgrVersion = LatestMgrVersion
)
type ObtainUserInputFunc func() ([]byte, error)
func maybeConvertDbError(err error) error {
	if _, ok := err.(ManagerError); ok {
		return err
	}
	return managerError(ErrDatabase, err.Error(), err)
}
type syncStatus uint8
const (
	ssNone    syncStatus = 0  
	ssPartial syncStatus = 1
	ssFull    syncStatus = 2
)
type addressType uint8
const (
	adtChain  addressType = 0
	adtImport addressType = 1  
	adtScript addressType = 2
)
type accountType uint8
const (
	accountDefault accountType = 0  
)
type dbAccountRow struct {
	acctType accountType
	rawData  []byte  
}
type dbDefaultAccountRow struct {
	dbAccountRow
	pubKeyEncrypted   []byte
	privKeyEncrypted  []byte
	nextExternalIndex uint32
	nextInternalIndex uint32
	name              string
}
type dbAddressRow struct {
	addrType   addressType
	account    uint32
	addTime    uint64
	syncStatus syncStatus
	rawData    []byte  
}
type dbChainAddressRow struct {
	dbAddressRow
	branch uint32
	index  uint32
}
type dbImportedAddressRow struct {
	dbAddressRow
	encryptedPubKey  []byte
	encryptedPrivKey []byte
}
type dbScriptAddressRow struct {
	dbAddressRow
	encryptedHash   []byte
	encryptedScript []byte
}
var (
	nullVal = []byte{0}
	scopeSchemaBucketName = []byte("scope-schema")
	scopeBucketName = []byte("scope")
	coinTypePrivKeyName = []byte("ctpriv")
	coinTypePubKeyName = []byte("ctpub")
	acctBucketName = []byte("acct")
	addrBucketName = []byte("addr")
	addrAcctIdxBucketName = []byte("addracctidx")
	acctNameIdxBucketName = []byte("acctnameidx")
	acctIDIdxBucketName = []byte("acctididx")
	usedAddrBucketName = []byte("usedaddrs")
	metaBucketName = []byte("meta")
	lastAccountName = []byte("lastaccount")
	mainBucketName = []byte("main")
	masterHDPrivName = []byte("mhdpriv")
	masterHDPubName = []byte("mhdpub")
	syncBucketName = []byte("sync")
	mgrVersionName    = []byte("mgrver")
	mgrCreateDateName = []byte("mgrcreated")
	masterPrivKeyName   = []byte("mpriv")
	masterPubKeyName    = []byte("mpub")
	cryptoPrivKeyName   = []byte("cpriv")
	cryptoPubKeyName    = []byte("cpub")
	cryptoScriptKeyName = []byte("cscript")
	watchingOnlyName    = []byte("watchonly")
	syncedToName              = []byte("syncedto")
	startBlockName            = []byte("startblock")
	birthdayName              = []byte("birthday")
	birthdayBlockName         = []byte("birthdayblock")
	birthdayBlockVerifiedName = []byte("birthdayblockverified")
)
func uint32ToBytes(number uint32) []byte {
	buf := make([]byte, 4)
	binary.LittleEndian.PutUint32(buf, number)
	return buf
}
func uint64ToBytes(number uint64) []byte {
	buf := make([]byte, 8)
	binary.LittleEndian.PutUint64(buf, number)
	return buf
}
func stringToBytes(s string) []byte {
	size := len(s)
	buf := make([]byte, 4+size)
	copy(buf[0:4], uint32ToBytes(uint32(size)))
	copy(buf[4:4+size], s)
	return buf
}
const scopeKeySize = 8
func scopeToBytes(scope *KeyScope) [scopeKeySize]byte {
	var scopeBytes [scopeKeySize]byte
	binary.LittleEndian.PutUint32(scopeBytes[:], scope.Purpose)
	binary.LittleEndian.PutUint32(scopeBytes[4:], scope.Coin)
	return scopeBytes
}