From e3017c9aab7950dd6c71055986021ab550ea620f Mon Sep 17 00:00:00 2001 From: Yuchuan Date: Fri, 29 Nov 2019 16:36:56 +0800 Subject: [PATCH] Update block.go Fix bound check in block.tx(txNum int) --- block.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.go b/block.go index 2749353..7d38abc 100644 --- a/block.go +++ b/block.go @@ -114,7 +114,7 @@ func (b *Block) Hash() *chainhash.Hash { func (b *Block) Tx(txNum int) (*Tx, error) { // Ensure the requested transaction is in range. numTx := uint64(len(b.msgBlock.Transactions)) - if txNum < 0 || uint64(txNum) > numTx { + if txNum < 0 || uint64(txNum) >= numTx { str := fmt.Sprintf("transaction index %d is out of range - max %d", txNum, numTx-1) return nil, OutOfRangeError(str)