Skip to content

Commit a49a775

Browse files
authored
Merge pull request #165 from gz-c/rawtx-check
Check len(RawTx) != 0
2 parents fe6bd52 + 1da48ba commit a49a775

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cmd/btcd/btcd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ func convertBlockToGetBlockVerboseResult(block *btcutil.Block) *btcjson.GetBlock
309309
for _, tx := range txRawResults {
310310
result.Tx = append(result.Tx, tx.Hash)
311311
}
312+
result.Tx = nil
312313

313314
return &result
314315
}

src/scanner/btc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222

2323
// ErrBtcdTxindexDisabled is returned if RawTx is missing from GetBlockVerboseResult,
2424
// which happens if txindex is not enabled in btcd.
25-
ErrBtcdTxindexDisabled = errors.New("len(block.RawTx) != len(block.Tx), make sure txindex is enabled in btcd")
25+
ErrBtcdTxindexDisabled = errors.New("len(block.RawTx) == 0, make sure txindex is enabled in btcd")
2626
)
2727

2828
const (
@@ -112,7 +112,7 @@ func (s *BTCScanner) Run() error {
112112
return err
113113
}
114114

115-
if len(initialBlock.RawTx) != len(initialBlock.Tx) {
115+
if len(initialBlock.RawTx) == 0 {
116116
err := ErrBtcdTxindexDisabled
117117
log.WithError(err).Error("Txindex looks disabled, aborting")
118118
return err

src/scanner/store.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ func (s *BTCStore) ScanBlock(block *btcjson.GetBlockVerboseResult) ([]Deposit, e
256256

257257
// ScanBTCBlock scan the given block and returns the next block hash or error
258258
func ScanBTCBlock(block *btcjson.GetBlockVerboseResult, depositAddrs []string) ([]Deposit, error) {
259-
// Assert that RawTx matches Tx
260-
if len(block.RawTx) != len(block.Tx) {
259+
if len(block.RawTx) == 0 {
261260
return nil, ErrBtcdTxindexDisabled
262261
}
263262

0 commit comments

Comments
 (0)