1- # Copyright (C) 2012-2014 The python-bitcoinlib developers
1+ # Copyright (C) 2012-2015 The python-bitcoinlib developers
22#
33# This file is part of python-bitcoinlib.
44#
3333from bitcoin .core import *
3434from bitcoin .core .serialize import *
3535from bitcoin .net import *
36- from bitcoin import MainParams
36+ import bitcoin
3737
3838MSG_TX = 1
3939MSG_BLOCK = 2
@@ -52,11 +52,11 @@ def msg_ser(self, f):
5252 def msg_deser (cls , f , protover = PROTO_VERSION ):
5353 raise NotImplementedError
5454
55- def to_bytes (self , params = MainParams () ):
55+ def to_bytes (self ):
5656 f = _BytesIO ()
5757 self .msg_ser (f )
5858 body = f .getvalue ()
59- res = params .MESSAGE_START
59+ res = bitcoin . params .MESSAGE_START
6060 res += self .command
6161 res += b"\x00 " * (12 - len (self .command ))
6262 res += struct .pack (b"<I" , len (body ))
@@ -75,13 +75,14 @@ def from_bytes(cls, b, protover=PROTO_VERSION):
7575 return MsgSerializable .stream_deserialize (f , protover = protover )
7676
7777 @classmethod
78- def stream_deserialize (cls , f , params = MainParams (), protover = PROTO_VERSION ):
78+ def stream_deserialize (cls , f , protover = PROTO_VERSION ):
7979 recvbuf = ser_read (f , 4 + 12 + 4 + 4 )
8080
8181 # 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 )))
8586
8687 # remaining header fields: command, msg length, checksum
8788 command = recvbuf [4 :4 + 12 ].split (b"\x00 " , 1 )[0 ]
0 commit comments