forked from petertodd/python-bitcoinlib
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmsg-serializable.py
More file actions
executable file
·29 lines (23 loc) · 854 Bytes
/
Copy pathmsg-serializable.py
File metadata and controls
executable file
·29 lines (23 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# Copyright (C) 2014 The python-bitcoinlib developers
#
# This file is part of python-bitcoinlib.
#
# It is subject to the license terms in the LICENSE file found in the top-level
# directory of this distribution.
#
# No part of python-bitcoinlib, including this file, may be copied, modified,
# propagated, or distributed except according to the terms contained in the
# LICENSE file.
"""Serialize some bitcoin datastructures and show them in serialized and repr form."""
from bitcoin import SelectParams
from bitcoin.messages import msg_version, msg_tx, msg_block
SelectParams('mainnet')
for c in [msg_version, msg_tx, msg_block]:
# Instanciate the message with some default values
msg = c()
name = c.__name__
print(name + " repr:")
print(msg)
print(name + " serialized:")
print(msg.to_bytes())