Skip to content

Commit 2b59f05

Browse files
committed
Issue #29 & #105 solved: get_transaction() returns block header
1 parent c06f420 commit 2b59f05

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

blockchain_parser/blockchain.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .block import Block
2525
from .index import DBBlockIndex
2626
from .utils import format_hash
27+
from .block_header import BlockHeader
2728

2829

2930
# Constant separating blocks in the .blk files
@@ -243,13 +244,15 @@ def get_transaction(self, txid, db):
243244
offset = tx_idx.block_offset
244245

245246
transaction_data = raw_hex[80:]
247+
block_header_data = raw_hex[:80]
246248
# Try from 1024 (1KiB) -> 1073741824 (1GiB) slice widths
247249
for j in range(0, 20):
248250
try:
251+
block_header = BlockHeader.from_hex(block_header_data)
249252
offset_e = offset + (1024 * 2 ** j)
250253
transaction = Transaction.from_hex(
251254
transaction_data[offset:offset_e])
252-
return transaction
255+
return [block_header, transaction]
253256
except Exception:
254257
continue
255258

0 commit comments

Comments
 (0)