From 9780ef5997b3294723ef31fc8b456adf81147da8 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 2 Feb 2017 10:44:22 -0700 Subject: [PATCH] Skip TxIn on coinbase transaction when indexing --- blockchain/indexers/cfindex.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/blockchain/indexers/cfindex.go b/blockchain/indexers/cfindex.go index 104aaec3..d9beb637 100644 --- a/blockchain/indexers/cfindex.go +++ b/blockchain/indexers/cfindex.go @@ -160,9 +160,12 @@ func makeBasicFilterForBlock(block *btcutil.Block) ([]byte, error) { if err != nil { return nil, err } - for _, tx := range block.Transactions() { - for _, txIn := range tx.MsgTx().TxIn { - b.AddOutPoint(txIn.PreviousOutPoint) + for i, tx := range block.Transactions() { + // Skip the inputs for the coinbase transaction + if i != 0 { + for _, txIn := range tx.MsgTx().TxIn { + b.AddOutPoint(txIn.PreviousOutPoint) + } } for _, txOut := range tx.MsgTx().TxOut { b.AddScript(txOut.PkScript) @@ -183,10 +186,13 @@ func makeExtendedFilterForBlock(block *btcutil.Block) ([]byte, error) { if err != nil { return nil, err } - for _, tx := range block.Transactions() { + for i, tx := range block.Transactions() { b.AddHash(tx.Hash()) - for _, txIn := range tx.MsgTx().TxIn { - b.AddScript(txIn.SignatureScript) + // Skip the inputs for the coinbase transaction + if i != 0 { + for _, txIn := range tx.MsgTx().TxIn { + b.AddScript(txIn.SignatureScript) + } } } f, err := b.Build()