コード例 #1
0
 def serialize(self, signed=True):
     return rlp.encode([encode_int(self.nonce),
                        encode_int(self.value),
                        encode_int(self.gasprice),
                        encode_int(self.startgas),
                        utils.coerce_addr_to_bin(self.to),
                        self.data,
                        encode_int(self.v),
                        encode_int(self.r),
                        encode_int(self.s)][:9 if signed else 6])
コード例 #2
0
 def serialize(self, signed=True):
     return rlp.encode([
         encode_int(self.nonce),
         encode_int(self.value),
         encode_int(self.gasprice),
         encode_int(self.startgas),
         utils.coerce_addr_to_bin(self.to), self.data,
         encode_int(self.v),
         encode_int(self.r),
         encode_int(self.s)
     ][:9 if signed else 6])
コード例 #3
0
 def __init__(*args):
     self = args[0]
     if len(args) == 2:
         self.parse(args[1])
     else:
         self.nonce = args[1]
         self.value = args[2]
         self.gasprice = args[3]
         self.startgas = args[4]
         self.to = utils.coerce_addr_to_bin(args[5])
         self.data = args[6]
         # includes signature
         if len(args) > 7:
             self.v, self.r, self.s = args[7:10]
             if self.r > 0 and self.s > 0:
                 rawhash = sha3(rlp.encode(self.serialize(False)))
                 pub = encode_pubkey(
                     ecdsa_raw_recover(rawhash, (self.v, self.r, self.s)), 'bin')
                 self.sender = sha3(pub[1:])[-20:].encode('hex')
         # does not include signature
         else:
             self.v, self.r, self.s = 0,0,0
             self.sender = 0
コード例 #4
0
 def __init__(*args):
     self = args[0]
     if len(args) == 2:
         self.parse(args[1])
     else:
         self.nonce = args[1]
         self.value = args[2]
         self.gasprice = args[3]
         self.startgas = args[4]
         self.to = utils.coerce_addr_to_bin(args[5])
         self.data = args[6]
         # includes signature
         if len(args) > 7:
             self.v, self.r, self.s = args[7:10]
             if self.r > 0 and self.s > 0:
                 rawhash = sha3(rlp.encode(self.serialize(False)))
                 pub = encode_pubkey(
                     ecdsa_raw_recover(rawhash, (self.v, self.r, self.s)),
                     'bin')
                 self.sender = sha3(pub[1:])[-20:].encode('hex')
         # does not include signature
         else:
             self.v, self.r, self.s = 0, 0, 0
             self.sender = 0