func (b *BlockChain) FetchSpendJournal(targetBlock *cashutil.Block) ([]SpentTxOut, error) {
	b.chainLock.RLock()
	defer b.chainLock.RUnlock()
	var spendEntries []SpentTxOut
	err := b.db.View(func(dbTx database.Tx) error {
		var err error
		spendEntries, err = dbFetchSpendJournalEntry(dbTx, targetBlock)
		return err
	})
	if err != nil {
		return nil, err
	}
	return spendEntries, nil
}
FetchSpendJournal attempts to retrieve the spend journal, or the set of
outputs spent for the target block. This provides a view of all the outputs
that will be consumed once the target block is connected to the end of the
main chain.

This function is safe for concurrent access.
package blockchain
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"math/big"
	"sync"
	"time"
	"github.com/bcext/cashutil"
	"github.com/bcext/gcash/chaincfg/chainhash"
	"github.com/bcext/gcash/database"
	"github.com/bcext/gcash/wire"
)
const (
	blockHdrSize = wire.MaxBlockHeaderPayload
	latestUtxoSetBucketVersion = 2
	latestSpendJournalBucketVersion = 1
)
var (
	blockIndexBucketName = []byte("blockheaderidx")
	hashIndexBucketName = []byte("hashidx")
	heightIndexBucketName = []byte("heightidx")
	chainStateKeyName = []byte("chainstate")
	spendJournalVersionKeyName = []byte("spendjournalversion")
	spendJournalBucketName = []byte("spendjournal")
	utxoSetVersionKeyName = []byte("utxosetversion")
	utxoSetBucketName = []byte("utxosetv2")
	byteOrder = binary.LittleEndian
)
type errNotInMainChain string
func (e errNotInMainChain) Error() string {
	return string(e)
}
func isNotInMainChainErr(err error) bool {
	_, ok := err.(errNotInMainChain)
	return ok
}
type errDeserialize string
func (e errDeserialize) Error() string {
	return string(e)
}
func isDeserializeErr(err error) bool {
	_, ok := err.(errDeserialize)
	return ok
}
func isDbBucketNotFoundErr(err error) bool {
	dbErr, ok := err.(database.Error)
	return ok && dbErr.ErrorCode == database.ErrBucketNotFound
}
func dbFetchVersion(dbTx database.Tx, key []byte) uint32 {
	serialized := dbTx.Metadata().Get(key)
	if serialized == nil {
		return 0
	}
	return byteOrder.Uint32(serialized[:])
}
func dbPutVersion(dbTx database.Tx, key []byte, version uint32) error {
	var serialized [4]byte
	byteOrder.PutUint32(serialized[:], version)
	return dbTx.Metadata().Put(key, serialized[:])
}
func dbFetchOrCreateVersion(dbTx database.Tx, key []byte, defaultVersion uint32) (uint32, error) {
	version := dbFetchVersion(dbTx, key)
	if version == 0 {
		version = defaultVersion
		err := dbPutVersion(dbTx, key, version)
		if err != nil {
			return 0, err
		}
	}
	return version, nil
}
type SpentTxOut struct {
	Amount int64
	PkScript []byte
	Height int32
	IsCoinBase bool
}