diff --git a/block.go b/block.go index 5a16baf..f62d9b8 100644 --- a/block.go +++ b/block.go @@ -93,7 +93,7 @@ func (b *Block) Sha() (*btcwire.ShaHash, error) { // properties such as caching the hash so subsequent calls are more efficient. func (b *Block) Tx(txNum int) (*Tx, error) { // Ensure the requested transaction is in range. - numTx := b.msgBlock.Header.TxnCount + numTx := uint64(len(b.msgBlock.Transactions)) if txNum < 0 || uint64(txNum) > numTx { str := fmt.Sprintf("transaction index %d is out of range - max %d", txNum, numTx-1) @@ -131,7 +131,7 @@ func (b *Block) Transactions() []*Tx { // Generate slice to hold all of the wrapped transactions if needed. if len(b.transactions) == 0 { - b.transactions = make([]*Tx, b.msgBlock.Header.TxnCount) + b.transactions = make([]*Tx, len(b.msgBlock.Transactions)) } // Generate and cache the wrapped transactions for all that haven't @@ -184,7 +184,7 @@ func (b *Block) TxShas() ([]*btcwire.ShaHash, error) { // Generate slice to hold all of the transaction hashes if needed. if len(b.txShas) == 0 { - b.txShas = make([]*btcwire.ShaHash, b.msgBlock.Header.TxnCount) + b.txShas = make([]*btcwire.ShaHash, len(b.msgBlock.Transactions)) } // Generate and cache the transaction hashes for all that haven't already diff --git a/block_test.go b/block_test.go index 2dd4e7e..a21c624 100644 --- a/block_test.go +++ b/block_test.go @@ -380,7 +380,6 @@ var Block100000 = btcwire.MsgBlock{ Timestamp: time.Unix(1293623863, 0), // 2010-12-29 11:57:43 +0000 UTC Bits: 0x1b04864c, // 453281356 Nonce: 0x10572b0f, // 274148111 - TxnCount: 4, }, Transactions: []*btcwire.MsgTx{ &btcwire.MsgTx{