comparison README.md @ 30:dbf757904681

CHnage info files
author Dennis <dennis@denniscm.com>
date Fri, 11 Aug 2023 16:36:36 +0000
parents d9537541d623
children 58692905e183
comparison
equal deleted inserted replaced
29:d9537541d623 30:dbf757904681
1 <!--suppress HtmlDeprecatedAttribute, HtmlRequiredAltAttribute -->
2 <p align="center">
3 <img src="https://user-images.githubusercontent.com/66180929/136657868-0ec6971b-ed76-43f3-9689-f643e8893706.png" />
4 </p>
5
6 1
7 # bitcaviar-plus [DEPRECATED] 2 # bitcaviar-plus [DEPRECATED]
8 3
9 A Bitcoin blockchain parser written in Python. 4 A Bitcoin blockchain parser written in Python.
10 5
11 ## Installation 6 - Docs: <https://denniscm.com/proj/bitcaviar-plus.html>
12 7 - Main repo on SourceHut: <https://git.sr.ht/~denniscmartin/bitcaviar-plus>
13 ### Recommended 8 - Mirrors:
14 9 - Github: <https://github.com/denniscmartin/bitcaviar-plus>
15 ```bash 10 - Gitlab: <https://gitlab.com/denniscmartin/bitcaviar-plus>
16 pip install bitcaviar-plus
17 ```
18
19 ### Manual
20
21 ```bash
22 python setup.py install
23 ```
24
25 ## Usage
26
27 ### Deserialize Genesis block
28
29 ```python
30 from bitcaviar_plus.block import deserialize_block
31 11
32 12
33 def parse_genesis_block(): 13 ## Attribution
34 with open('path/to/file/blk00000.dat', 'rb') as f:
35 block = deserialize_block(f)
36 print(block)
37 ```
38 14
39 ### Deserialize entire blockchain 15 - [blockchain-parser](https://github.com/ragestack/blockchain-parser/blob/master/blockchain-parser.py)
16 - [bitcoinbook](https://github.com/bitcoinbook/bitcoinbook)
17 - [learnmeabitcoin.com](https://learnmeabitcoin.com/)
40 18
41 ```python
42 import os
43 from bitcaviar_plus.block import deserialize_block
44 from bitcaviar_plus.errors import InvalidMagicBytes
45
46
47 def parse_entire_blockchain():
48 file_counter = -1
49 while True:
50 file_counter += 1
51 file_name = 'path/to/file/blk{}.dat'.format(str(file_counter).zfill(5))
52 with open(file_name, 'rb') as f:
53 file_size = os.path.getsize(file_name)
54 while f.tell() < file_size:
55 try:
56 block = deserialize_block(f)
57 except InvalidMagicBytes as e:
58 print(e)
59 ```
60
61 ### Example output
62
63 ```json
64 {
65 "magic_number":"f9beb4d9",
66 "size":"0000011d",
67 "id":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
68 "transaction_count":"01",
69 "header":{
70 "version":"00000001",
71 "previous_block_id":"0000000000000000000000000000000000000000000000000000000000000000",
72 "merkle_root":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
73 "time":"495fab29",
74 "bits":"1d00ffff",
75 "nonce":"7c2bac1d"
76 },
77 "transactions":[
78 {
79 "version":"00000001",
80 "input_count":"01",
81 "output_count":"01",
82 "lock_time":"00000000",
83 "id":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
84 "inputs":[
85 {
86 "id":"0000000000000000000000000000000000000000000000000000000000000000",
87 "vout":"ffffffff",
88 "script_sig_size":"4d",
89 "script_sig":"04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
90 "sequence":"ffffffff"
91 }
92 ],
93 "outputs":[
94 {
95 "value":"000000012a05f200",
96 "script_pub_key_size":"43",
97 "script_pub_key":"4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac"
98 }
99 ]
100 }
101 ]
102 }
103 ```
104
105 ## Attribution
106 - [blockchain-parser](https://github.com/ragestack/blockchain-parser/blob/master/blockchain-parser.py)
107 - [bitcoinbook](https://github.com/bitcoinbook/bitcoinbook)
108 - [LearnMeABitcoin.com](https://learnmeabitcoin.com)