diff --git a/blockchain/indexers/cfindex.go b/blockchain/indexers/cfindex.go index 378fcd5c..01523e7f 100644 --- a/blockchain/indexers/cfindex.go +++ b/blockchain/indexers/cfindex.go @@ -107,7 +107,8 @@ func (idx *CfIndex) Create(dbTx database.Tx) error { } // makeBasicFilter() builds a block's basic filter, which consists of all -// outpoints referenced by transactions within the block. +// outpoints and pkscript data pushes referenced by transactions within the +// block. func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) { b := builder.WithKeyHash(block.Hash()) _, err := b.Key() @@ -129,6 +130,27 @@ func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) { return f.Bytes(), nil } +// makeExtendedFilter() builds a block's extended filter, which consists of +// all tx hashes and sigscript data pushes contained in the block. +func makeExtendedFilterForBlock(block *btcutil.Block) ([]byte, error) { + b := builder.WithKeyHash(block.Hash()) + _, err := b.Key() + if err != nil { + return nil, err + } + for _, tx := range block.Transactions() { + b.AddHash(tx.Hash()) + for _, txIn := range tx.MsgTx().TxIn { + b.AddScript(txIn.SignatureScript) + } + } + f, err := b.Build() + if err != nil { + return nil, err + } + return f.Bytes(), nil +} + // ConnectBlock is invoked by the index manager when a new block has been // connected to the main chain. This indexer adds a hash-to-cf mapping for // every passed block. This is part of the Indexer interface.