def get_funds_fields_from_struct(self, buf: bytes) -> bytes: """ Gets all funds fields for a transaction from a buffer. :param buf: Bytes of a serialized transaction :type buf: bytes :return: A buffer containing the remaining struct bytes :rtype: bytes :raises ValueError: when the sequence of bytes is incorect """ (self.version, tokens_len, inputs_len, outputs_len), buf = unpack(_FUNDS_FORMAT_STRING, buf) for _ in range(tokens_len): token_uid, buf = unpack_len(TX_HASH_SIZE, buf) self.tokens.append(token_uid) for _ in range(inputs_len): txin, buf = TxInput.create_from_bytes(buf) self.inputs.append(txin) for _ in range(outputs_len): txout, buf = TxOutput.create_from_bytes(buf) self.outputs.append(txout) return buf
def get_funds_fields_from_struct(self, buf: bytes) -> bytes: """ Gets all funds fields for a block from a buffer. :param buf: Bytes of a serialized block :type buf: bytes :return: A buffer containing the remaining struct bytes :rtype: bytes :raises ValueError: when the sequence of bytes is incorect """ (self.version, outputs_len), buf = unpack(_FUNDS_FORMAT_STRING, buf) for _ in range(outputs_len): txout, buf = TxOutput.create_from_bytes(buf) self.outputs.append(txout) return buf