From 1da48ba8161c0499a229e6ba00680f9a30bf1139 Mon Sep 17 00:00:00 2001 From: gz-c Date: Wed, 6 Dec 2017 23:49:52 +0800 Subject: [PATCH] Check len(RawTx) != 0 --- cmd/btcd/btcd.go | 1 + src/scanner/btc.go | 4 ++-- src/scanner/store.go | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/btcd/btcd.go b/cmd/btcd/btcd.go index 206939b1..73c2205d 100644 --- a/cmd/btcd/btcd.go +++ b/cmd/btcd/btcd.go @@ -309,6 +309,7 @@ func convertBlockToGetBlockVerboseResult(block *btcutil.Block) *btcjson.GetBlock for _, tx := range txRawResults { result.Tx = append(result.Tx, tx.Hash) } + result.Tx = nil return &result } diff --git a/src/scanner/btc.go b/src/scanner/btc.go index 2d4906a6..edf3d7f8 100644 --- a/src/scanner/btc.go +++ b/src/scanner/btc.go @@ -22,7 +22,7 @@ var ( // ErrBtcdTxindexDisabled is returned if RawTx is missing from GetBlockVerboseResult, // which happens if txindex is not enabled in btcd. - ErrBtcdTxindexDisabled = errors.New("len(block.RawTx) != len(block.Tx), make sure txindex is enabled in btcd") + ErrBtcdTxindexDisabled = errors.New("len(block.RawTx) == 0, make sure txindex is enabled in btcd") ) const ( @@ -112,7 +112,7 @@ func (s *BTCScanner) Run() error { return err } - if len(initialBlock.RawTx) != len(initialBlock.Tx) { + if len(initialBlock.RawTx) == 0 { err := ErrBtcdTxindexDisabled log.WithError(err).Error("Txindex looks disabled, aborting") return err diff --git a/src/scanner/store.go b/src/scanner/store.go index 109f41d6..2ed85dac 100644 --- a/src/scanner/store.go +++ b/src/scanner/store.go @@ -256,8 +256,7 @@ func (s *BTCStore) ScanBlock(block *btcjson.GetBlockVerboseResult) ([]Deposit, e // ScanBTCBlock scan the given block and returns the next block hash or error func ScanBTCBlock(block *btcjson.GetBlockVerboseResult, depositAddrs []string) ([]Deposit, error) { - // Assert that RawTx matches Tx - if len(block.RawTx) != len(block.Tx) { + if len(block.RawTx) == 0 { return nil, ErrBtcdTxindexDisabled }