From f0f2052f4454d1fcc14267f1fdc1fbeb7d504b68 Mon Sep 17 00:00:00 2001 From: Romern Date: Tue, 23 Jun 2020 15:03:01 +0200 Subject: [PATCH 1/3] Support for dogecoin dogecoin uses AuxPOW, which uses a different block format: https://en.bitcoin.it/wiki/Merged_mining_specification --- blockchain_parser/block.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/blockchain_parser/block.py b/blockchain_parser/block.py index cb7d29c..52c0241 100644 --- a/blockchain_parser/block.py +++ b/blockchain_parser/block.py @@ -20,6 +20,33 @@ def get_block_transactions(raw_hex, blockchain_type): """ # Skipping the header transaction_data = raw_hex[80:] + # Check if the block is AuxPOW (then after the 80 byte header there is an immediate coinbase transaction) + #print("".join(hex(ord(x)) for x in transaction_data[:4])) + if blockchain_type.symbol == "doge" and ((transaction_data[:4] == b'\x01\x00\x00\x00') or (transaction_data[:4] == b'\x02\x00\x00\x00')): # it is indeed an AuxPOW block + #print("AuxPOW") + transaction = None + # Try from 1024 (1KiB) -> 1073741824 (1GiB) slice widths + for j in range(0, 20): + try: + offset_e = 1024 * 2 ** j + transaction = Transaction.from_hex( + transaction_data[:offset_e], blockchain_type) + break + except: + continue + #print(transaction.hash) + offset = transaction.size + 32 + # coinbase_branch + branch_length, size = decode_varint(transaction_data[offset:]) + offset += size + branch_length*32 + offset += 4 + # blockchain_branch + branch_length, size = decode_varint(transaction_data[offset:]) + offset += size + branch_length*32 + offset += 4 + # parent_block header + offset += 80 + transaction_data = transaction_data[offset:] # Decoding the number of transactions, offset is the size of # the varint (1 to 9 bytes) From 9ffed2351547c64f5a02ef34eefbfa8e54f361c1 Mon Sep 17 00:00:00 2001 From: Romern Date: Tue, 23 Jun 2020 16:39:46 +0200 Subject: [PATCH 2/3] Apparently some other tx version is also used --- blockchain_parser/block.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain_parser/block.py b/blockchain_parser/block.py index 52c0241..2ceda82 100644 --- a/blockchain_parser/block.py +++ b/blockchain_parser/block.py @@ -22,7 +22,7 @@ def get_block_transactions(raw_hex, blockchain_type): transaction_data = raw_hex[80:] # Check if the block is AuxPOW (then after the 80 byte header there is an immediate coinbase transaction) #print("".join(hex(ord(x)) for x in transaction_data[:4])) - if blockchain_type.symbol == "doge" and ((transaction_data[:4] == b'\x01\x00\x00\x00') or (transaction_data[:4] == b'\x02\x00\x00\x00')): # it is indeed an AuxPOW block + if blockchain_type.symbol == "doge" and transaction_data[:4] in [b'\x01\x00\x00\x00', b'\x02\x00\x00\x00', b'\x02\x00\x00\x20']: # it is indeed an AuxPOW block #print("AuxPOW") transaction = None # Try from 1024 (1KiB) -> 1073741824 (1GiB) slice widths From ce6e478023fd85054ea3fb9ff9a7972c23bfd378 Mon Sep 17 00:00:00 2001 From: Romern Date: Tue, 23 Jun 2020 17:00:18 +0200 Subject: [PATCH 3/3] More versions Maybe there is a better way of identifiying the transactions? --- blockchain_parser/block.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain_parser/block.py b/blockchain_parser/block.py index 2ceda82..c5f8e6d 100644 --- a/blockchain_parser/block.py +++ b/blockchain_parser/block.py @@ -22,7 +22,7 @@ def get_block_transactions(raw_hex, blockchain_type): transaction_data = raw_hex[80:] # Check if the block is AuxPOW (then after the 80 byte header there is an immediate coinbase transaction) #print("".join(hex(ord(x)) for x in transaction_data[:4])) - if blockchain_type.symbol == "doge" and transaction_data[:4] in [b'\x01\x00\x00\x00', b'\x02\x00\x00\x00', b'\x02\x00\x00\x20']: # it is indeed an AuxPOW block + if blockchain_type.symbol == "doge" and transaction_data[:4] in [b'\x01\x00\x00\x00', b'\x02\x00\x00\x00', b'\x02\x00\x00\x20', b'\x02\x10\x00\x20']: # it is indeed an AuxPOW block #print("AuxPOW") transaction = None # Try from 1024 (1KiB) -> 1073741824 (1GiB) slice widths