1
- # Copyright (C) 2012-2014 The python-bitcoinlib developers
1
+ # Copyright (C) 2012-2015 The python-bitcoinlib developers
2
2
#
3
3
# This file is part of python-bitcoinlib.
4
4
#
33
33
from bitcoin .core import *
34
34
from bitcoin .core .serialize import *
35
35
from bitcoin .net import *
36
- from bitcoin import MainParams
36
+ import bitcoin
37
37
38
38
MSG_TX = 1
39
39
MSG_BLOCK = 2
@@ -52,11 +52,11 @@ def msg_ser(self, f):
52
52
def msg_deser (cls , f , protover = PROTO_VERSION ):
53
53
raise NotImplementedError
54
54
55
- def to_bytes (self , params = MainParams () ):
55
+ def to_bytes (self ):
56
56
f = _BytesIO ()
57
57
self .msg_ser (f )
58
58
body = f .getvalue ()
59
- res = params .MESSAGE_START
59
+ res = bitcoin . params .MESSAGE_START
60
60
res += self .command
61
61
res += b"\x00 " * (12 - len (self .command ))
62
62
res += struct .pack (b"<I" , len (body ))
@@ -75,13 +75,14 @@ def from_bytes(cls, b, protover=PROTO_VERSION):
75
75
return MsgSerializable .stream_deserialize (f , protover = protover )
76
76
77
77
@classmethod
78
- def stream_deserialize (cls , f , params = MainParams (), protover = PROTO_VERSION ):
78
+ def stream_deserialize (cls , f , protover = PROTO_VERSION ):
79
79
recvbuf = ser_read (f , 4 + 12 + 4 + 4 )
80
80
81
81
# check magic
82
- if recvbuf [:4 ] != params .MESSAGE_START :
83
- raise ValueError ("Invalid message start '%s', expected '%s'" %
84
- (b2x (recvbuf [:4 ]), b2x (params .MESSAGE_START )))
82
+ if recvbuf [:4 ] != bitcoin .params .MESSAGE_START :
83
+ raise ValueError (
84
+ "Invalid message start '%s', expected '%s'" %
85
+ (b2x (recvbuf [:4 ]), b2x (bitcoin .params .MESSAGE_START )))
85
86
86
87
# remaining header fields: command, msg length, checksum
87
88
command = recvbuf [4 :4 + 12 ].split (b"\x00 " , 1 )[0 ]
0 commit comments