Netidee Blog Bild
Bitcoin Blockchain Format mit extended Transaction Format
blk-Dateiformat der Bitcoin Blockchain mit erweitertem Format (01.02.2018)
Förderjahr 2017 / Project Call #12 / ProjektID: 2200 / Projekt: BlockNinjas

Eine Pythonimplementierung haben wir hier: https://github.com/mrqc/bitcoin-blk-file-reader

 

Remarks: All values are little endian except magic number

read inputs (count of inputs):
	for each input:
		previous transaction hash = 32 byte
		out ID = 4 byte
		script length = varbytes()
		script = „script length“ bytes
		sequence number = 4 byte

read outputs (count of outputs):
	for each output:
		value = 8 byte value
		script length = varbytes()
		

varbytes ():
	first value = 1 byte
	if first value < 0xfd:
		return first value
	else if first value == 0xfd
		return next 2 byte
	else if first value == 0xfe
		return next 4 byte
	else if first value == 0xff
		return next 6 byte
Until EOF:
	magic number = 4 byte
	if magic number == 00000000:
		raise „last saved block was read“
	block size = 4 byte
	version = 4 byte
	previous block hash = 32 byte
	markle hash = 32 byte
	block timestamp = 4 byte
	bits = 4 byte
	nonce = 4 byte
	number of transactions = varbytes()
	for each transaction:
		version =  4 byte
		count of inputs = varbytes()
		if count of inputs == 0:
			flags = 1 byte
			if flags != 0:
				count of inputs = varbytes()
				read inputs(count of inputs)
				count of outputs = varbytes()
				read outputs(count of outputs)
				if flags & 1:
					for each input:
						count of stack items = varbytes()
						for each count of stack item:
							stack length = varbytes()
							stack item = „stack length“ byte
		else:
			read inputs(count of inputs)
			count of outputs = varbytes()
			read outputs(count of outputs)
	lock time = 4 byte

 

 

 

Erhard Dinhobl

Profile picture for user erhard.dinhobl

Skills:

Software Engineering
,
Machine Learning
,
blockchain
,
Bitcoin
,
C++
,
C
,
Python
,
Java
CAPTCHA
Diese Frage dient der Überprüfung, ob Sie ein menschlicher Besucher sind und um automatisierten SPAM zu verhindern.

    Weitere Blogbeiträge