Skip to content

Commit

Permalink
Merge pull request #165 from gz-c/rawtx-check
Browse files Browse the repository at this point in the history
Check len(RawTx) != 0
  • Loading branch information
gz-c authored Dec 6, 2017
2 parents fe6bd52 + 1da48ba commit a49a775
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/btcd/btcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/scanner/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/scanner/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a49a775

Please sign in to comment.