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
@@ -51,11 +51,11 @@ def msg_ser(self, f):
51
51
def msg_deser (cls , f , protover = PROTO_VERSION ):
52
52
raise NotImplementedError
53
53
54
- def to_bytes (self , params = MainParams () ):
54
+ def to_bytes (self ):
55
55
f = _BytesIO ()
56
56
self .msg_ser (f )
57
57
body = f .getvalue ()
58
- res = params .MESSAGE_START
58
+ res = bitcoin . params .MESSAGE_START
59
59
res += self .command
60
60
res += b"\x00 " * (12 - len (self .command ))
61
61
res += struct .pack (b"<I" , len (body ))
@@ -74,13 +74,13 @@ def from_bytes(cls, b, protover=PROTO_VERSION):
74
74
return MsgSerializable .stream_deserialize (f , protover = protover )
75
75
76
76
@classmethod
77
- def stream_deserialize (cls , f , params = MainParams (), protover = PROTO_VERSION ):
77
+ def stream_deserialize (cls , f , protover = PROTO_VERSION ):
78
78
recvbuf = ser_read (f , 4 + 12 + 4 + 4 )
79
79
80
80
# check magic
81
- if recvbuf [:4 ] != params .MESSAGE_START :
81
+ if recvbuf [:4 ] != bitcoin . params .MESSAGE_START :
82
82
raise ValueError ("Invalid message start '%s', expected '%s'" %
83
- (b2x (recvbuf [:4 ]), b2x (params .MESSAGE_START )))
83
+ (b2x (recvbuf [:4 ]), b2x (bitcoin . params .MESSAGE_START )))
84
84
85
85
# remaining header fields: command, msg length, checksum
86
86
command = recvbuf [4 :4 + 12 ].split (b"\x00 " , 1 )[0 ]
0 commit comments