예제 #1
0
    def unpack(self, data):
        """unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        data_size = len(data)
        try:
            ptr, self.asset_group_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["asset_group_id"] = len(self.asset_group_id)
            ptr, self.transaction_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["transaction_id"] = len(self.transaction_id)
            ptr, self.event_index_in_ref = bbclib_binary.get_n_byte_int(ptr, 2, data)
            ptr, signum = bbclib_binary.get_n_byte_int(ptr, 2, data)
            self.sig_indices = []
            for i in range(signum):
                ptr, idx = bbclib_binary.get_n_byte_int(ptr, 2, data)
                self.sig_indices.append(idx)
                if ptr > data_size:
                    return False
        except:
            return False
        return True
예제 #2
0
    def unpack(self, data):
        """Unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        try:
            ptr, self.domain_id = bbclib_binary.get_bigint(ptr, data)
            ptr, self.transaction_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["transaction_id"] = len(self.transaction_id)
        except:
            return False
        return True
예제 #3
0
    def unpack(self, data):
        """Unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        id_length_asgid = 32
        id_length_userid = 32
        data_size = len(data)
        try:
            ptr, self.asset_group_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["asset_group_id"] = len(self.asset_group_id)
            ptr, ref_num = bbclib_binary.get_n_byte_int(ptr, 2, data)
            self.reference_indices = []
            for i in range(ref_num):
                ptr, idx = bbclib_binary.get_n_byte_int(ptr, 2, data)
                self.reference_indices.append(idx)
                if ptr >= data_size:
                    return False
            ptr, appr_num = bbclib_binary.get_n_byte_int(ptr, 2, data)
            self.mandatory_approvers = []
            for i in range(appr_num):
                ptr, appr = bbclib_binary.get_bigint(ptr, data)
                self.idlen_conf["user_id"] = len(appr)
                self.mandatory_approvers.append(appr)
                if ptr >= data_size:
                    return False
            ptr, self.option_approver_num_numerator = bbclib_binary.get_n_byte_int(ptr, 2, data)
            ptr, self.option_approver_num_denominator = bbclib_binary.get_n_byte_int(ptr, 2, data)
            self.option_approvers = []
            for i in range(self.option_approver_num_denominator):
                ptr, appr = bbclib_binary.get_bigint(ptr, data)
                self.idlen_conf["user_id"] = len(appr)
                self.option_approvers.append(appr)
                if ptr >= data_size:
                    return False
            ptr, astsize = bbclib_binary.get_n_byte_int(ptr, 4, data)
            ptr, astdata = bbclib_binary.get_n_bytes(ptr, astsize, data)
            self.asset = BBcAsset()
            self.asset.unpack(astdata)
        except:
            return False
        return True
예제 #4
0
    def unpack(self, data, version=2):
        """Unpack data into transaction object

        Args:
            data (bytes): packed binary data
            version (int): version of the data format
        Returns:
            bool: True if successful
        """
        ptr = 0
        self.version = version
        data_size = len(data)
        try:
            ptr, self.asset_group_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["asset_group_id"] = len(self.asset_group_id)
            ptr, pt_num = bbclib_binary.get_n_byte_int(ptr, 2, data)
            self.pointers = list()
            for i in range(pt_num):
                ptr, size = bbclib_binary.get_n_byte_int(ptr, 2, data)
                ptr, ptdata = bbclib_binary.get_n_bytes(ptr, size, data)
                if ptr >= data_size:
                    return False
                pt = BBcPointer()
                if not pt.unpack(ptdata):
                    return False
                self.pointers.append(pt)
            self.asset = None
            ptr, astsize = bbclib_binary.get_n_byte_int(ptr, 4, data)
            if astsize > 0:
                self.asset = BBcAsset()
                ptr, astdata = bbclib_binary.get_n_bytes(ptr, astsize, data)
                if not self.asset.unpack(astdata):
                    return False

            if version >= 2:
                self.asset_raw = None
                ptr, astsize = bbclib_binary.get_n_byte_int(ptr, 4, data)
                if astsize > 0:
                    self.asset_raw = BBcAssetRaw()
                    ptr, astdata = bbclib_binary.get_n_bytes(
                        ptr, astsize, data)
                    if not self.asset_raw.unpack(astdata):
                        return False
                self.asset_hash = None
                ptr, astsize = bbclib_binary.get_n_byte_int(ptr, 4, data)
                if astsize > 0:
                    self.asset_hash = BBcAssetHash()
                    ptr, astdata = bbclib_binary.get_n_bytes(
                        ptr, astsize, data)
                    if not self.asset_hash.unpack(astdata):
                        return False

        except:
            return False
        return True
예제 #5
0
    def unpack(self, data):
        """Unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        try:
            ptr, self.asset_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["asset_id"] = len(self.asset_id)
            ptr, self.user_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["user_id"] = len(self.user_id)
            ptr, noncelen = bbclib_binary.get_n_byte_int(ptr, 2, data)
            self.idlen_conf["nonce"] = noncelen
            ptr, self.nonce = bbclib_binary.get_n_bytes(ptr, noncelen, data)
            ptr, self.asset_file_size = bbclib_binary.get_n_byte_int(
                ptr, 4, data)
            if self.asset_file_size > 0:
                ptr, self.asset_file_digest = bbclib_binary.get_bigint(
                    ptr, data)
            else:
                self.asset_file_digest = None
            ptr, dict_flag = bbclib_binary.get_n_byte_int(ptr, 2, data)
            if dict_flag != 1:
                ptr, self.asset_body_size = bbclib_binary.get_n_byte_int(
                    ptr, 2, data)
                if self.asset_body_size > 0:
                    ptr, self.asset_body = bbclib_binary.get_n_bytes(
                        ptr, self.asset_body_size, data)
            else:
                ptr, sz = bbclib_binary.get_n_byte_int(ptr, 2, data)
                ptr, astbdy = bbclib_binary.get_n_bytes(ptr, sz, data)
                self.asset_body = msgpack.loads(astbdy)
                self.asset_body_size = len(self.asset_body)

        except:
            traceback.print_exc()
            return False
        return True
예제 #6
0
    def unpack(self, data):
        """Unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        try:
            ptr, self.transaction_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["transaction_id"] = len(self.transaction_id)
            ptr, num = bbclib_binary.get_n_byte_int(ptr, 2, data)
            if num == 1:
                ptr, self.asset_id = bbclib_binary.get_bigint(ptr, data)
                self.idlen_conf["asset_id"] = len(self.asset_id)
            else:
                self.asset_id = None
        except:
            return False
        return True
예제 #7
0
    def unpack(self, data):
        """Unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        try:
            ptr, num_ids = bbclib_binary.get_n_byte_int(ptr, 2, data)
            for i in range(num_ids):
                ptr, asset_id = bbclib_binary.get_bigint(ptr, data)
                self.asset_ids.append(asset_id)
                self.idlen_conf["asset_id"] = len(asset_id)
        except:
            traceback.print_exc()
            return False
        return True
예제 #8
0
    def unpack(self, data):
        """Unpack into this object

        Args:
            data (bytes): packed binary data
        Returns:
            bool: True if successful
        """
        ptr = 0
        try:
            ptr, self.asset_id = bbclib_binary.get_bigint(ptr, data)
            self.idlen_conf["asset_id"] = len(self.asset_id)
            ptr, self.asset_body_size = bbclib_binary.get_n_byte_int(
                ptr, 2, data)
            if self.asset_body_size > 0:
                ptr, self.asset_body = bbclib_binary.get_n_bytes(
                    ptr, self.asset_body_size, data)
        except:
            traceback.print_exc()
            return False
        return True