Пример #1
0
 def serialize(self):
     return b''.join(
         (pack_le_uint16(self.version), pack_le_uint16(self.txtype),
          pack_varint(len(self.inputs)), b''.join(tx_in.serialize()
                                                  for tx_in in self.inputs),
          pack_varint(len(self.outputs)),
          b''.join(tx_out.serialize() for tx_out in self.outputs),
          pack_le_uint32(self.locktime)))
Пример #2
0
 def serialize(self):
     assert (len(self.proTxHash) == 32 and len(self.inputsHash) == 32
             and len(self.payloadSig) == 96)
     return (pack_le_uint16(self.version) +  # version
             self.proTxHash +  # proTxHash
             pack_le_uint16(self.reason) +  # reason
             self.inputsHash +  # inputsHash
             self.payloadSig  # payloadSig
             )
Пример #3
0
 def serialize(self):
     assert (len(self.proTxHash) == 32 and len(self.PubKeyOperator) == 48
             and len(self.KeyIdVoting) == 20 and len(self.inputsHash) == 32)
     return (pack_le_uint16(self.version) +  # version
             self.proTxHash +  # proTxHash
             pack_le_uint16(self.mode) +  # mode
             self.PubKeyOperator +  # PubKeyOperator
             self.KeyIdVoting +  # KeyIdVoting
             pack_varbytes(self.scriptPayout) +  # scriptPayout
             self.inputsHash +  # inputsHash
             pack_varbytes(self.payloadSig)  # payloadSig
             )
Пример #4
0
 def serialize(self):
     assert (len(self.proTxHash) == 32
             and len(self.ipAddress) == 16
             and len(self.inputsHash) == 32
             and len(self.payloadSig) == 96)
     return (
         pack_le_uint16(self.version) +              # version
         self.proTxHash +                            # proTxHash
         self.ipAddress +                            # ipAddress
         pack_le_uint16(self.port) +                 # port
         pack_varbytes(self.scriptOperatorPayout) +  # scriptOperatorPayout
         self.inputsHash +                           # inputsHash
         self.payloadSig                             # payloadSig
     )
Пример #5
0
    def serialize(self):
        nLocktime = pack_le_uint32(self.locktime)
        txins = (pack_varint(len(self.inputs)) +
                 b''.join(tx_in.serialize() for tx_in in self.inputs))
        txouts = (pack_varint(len(self.outputs)) +
                  b''.join(tx_out.serialize() for tx_out in self.outputs))

        if self.tx_type:
            uVersion = pack_le_uint16(self.version)
            uTxType = pack_le_uint16(self.tx_type)
            vExtra = self._serialize_extra_payload()
            return uVersion + uTxType + txins + txouts + nLocktime + vExtra
        else:
            nVersion = pack_le_int32(self.version)
            return nVersion + txins + txouts + nLocktime
Пример #6
0
 def serialize(self):
     assert len(self.merkleRootMNList) == 32
     return (
         pack_le_uint16(self.version) +              # version
         pack_le_uint32(self.height) +               # height
         self.merkleRootMNList                       # merkleRootMNList
     )
Пример #7
0
 def serialize(self):
     assert (len(self.pubKey) == 48 and len(self.payloadSig) == 96)
     return (pack_le_uint16(self.version) +  # version
             pack_varbytes(self.userName) +  # userName
             self.pubKey +  # pubKey
             self.payloadSig  # payloadSig
             )
Пример #8
0
 def serialize(self):
     assert (len(self.ipAddress) == 16 and len(self.KeyIdOwner) == 20
             and len(self.PubKeyOperator) == 48
             and len(self.KeyIdVoting) == 20 and len(self.inputsHash) == 32)
     return (pack_le_uint16(self.version) +  # version
             pack_le_uint16(self.type) +  # type
             pack_le_uint16(self.mode) +  # mode
             self.collateralOutpoint.serialize() +  # collateralOutpoint
             self.ipAddress +  # ipAddress
             pack_be_uint16(self.port) +  # port
             self.KeyIdOwner +  # KeyIdOwner
             self.PubKeyOperator +  # PubKeyOperator
             self.KeyIdVoting +  # KeyIdVoting
             pack_le_uint16(self.operatorReward) +  # operatorReward
             pack_varbytes(self.scriptPayout) +  # scriptPayout
             self.inputsHash +  # inputsHash
             pack_varbytes(self.payloadSig)  # payloadSig
             )
Пример #9
0
 def serialize(self):
     assert (len(self.regTxHash) == 32 and len(self.hashPrevSubTx) == 32
             and len(self.payloadSig) == 96)
     return (pack_le_uint16(self.version) +  # version
             self.regTxHash +  # regTxHash
             self.hashPrevSubTx +  # hashPrevSubTx
             pack_le_int64(self.creditFee) +  # creditFee
             self.payloadSig  # payloadSig
             )
Пример #10
0
 def serialize(self):
     assert len(self.merkleRootMNList) == 32
     res = (
         pack_le_uint16(self.version) +  # version
         pack_le_uint32(self.height) +  # height
         self.merkleRootMNList  # merkleRootMNList
     )
     if self.version > 1:
         assert len(self.merkleRootQuorums) == 32
         res += self.merkleRootQuorums  # merkleRootQuorums
     return res
Пример #11
0
    def push_data(cls, data):
        '''Returns the opcodes to push the data on the stack.'''
        assert isinstance(data, (bytes, bytearray))

        n = len(data)
        if n < OpCodes.OP_PUSHDATA1:
            return bytes([n]) + data
        if n < 256:
            return bytes([OpCodes.OP_PUSHDATA1, n]) + data
        if n < 65536:
            return bytes([OpCodes.OP_PUSHDATA2]) + pack_le_uint16(n) + data
        return bytes([OpCodes.OP_PUSHDATA4]) + pack_le_uint32(n) + data
Пример #12
0
 def serialize(self):
     return b''.join((
         self.prev_hash,
         pack_le_uint16(self.prev_idx),
         pack_le_uint32(self.sequence),
     ))
Пример #13
0
 def serialize(self):
     assert len(self.regTxHash) == 32
     return (
         pack_le_uint16(self.version) +              # version
         self.regTxHash                              # regTxHash
     )